-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFunctions.cpp
More file actions
136 lines (127 loc) · 4.17 KB
/
testFunctions.cpp
File metadata and controls
136 lines (127 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include<iostream>
#include<vector>
#include<utility>
#include "proj_func.h"
#include "trie_map.h"
#include "rgg.h"
using std::vector;
using std::cout;
using std::endl;
int main() {
/*trie_map<double> m;
vector<int> t {1,2,3};
m.insert(std::make_pair(t, 2.4));
cout << (*m.find(t)).second;*/
vector<vector<vector<int>>> neweqMatrices(2);
vector<vector<vector<int>>> newLtMatrices{};
vector<vector<int>> neweqVectors(2);
vector<vector<int>> newltVectors{};
vector<vector<int>> neighbors = rgg::createSelfLoopGraph(3);
rgg* r = rgg::makeRandomRGG(2, 3, neweqMatrices, neweqVectors, newLtMatrices, newltVectors, neighbors);
cout << "Testing Create Complete Graph With 3 Resource Nodes" << endl;
for(auto a: rgg::createCompleteGraph(3)) {
for(auto b: a) {
cout << b << " ";
}
cout << endl;
}
cout << "Testing Self Loop Graph With 3 Resource Nodes" << endl;
for(auto a: rgg::createSelfLoopGraph(3)) {
for(auto b: a) {
cout << b << " ";
cout << endl;
}
}
cout << "Created a game with 2 players, 3 resource nodes and a complete graph" << endl;
cout << "Testing getNumPlayers():" << endl;
cout << r->getNumPlayers() << endl;
cout << endl;
cout << "Testing Utility Functions Creation From makeRandomRGG" << endl;
for(auto a: r->utilityFunctions) {
for(auto b: a) {
for(auto c: b.first) {
cout << c << " ";
}
cout << b.second;
cout << endl;
}
cout << endl;
}
cout << endl;
cout << "Testing addDefaultLT() Function:" << endl;
cout << "Making Sure LT Matrices are correct:" << endl;
r->addDefaultLT();
for(int i=0;i<2; i++) {
cout << "Checking Player " << i << endl;
for(auto a:(r->ltMatrices)[i]){
for(auto b: a){
cout << b << " ";
}
cout << endl;
}
cout << endl;
}
//Need to check LT Vectors as well
cout << "Making sure LT Vectors are correct:" << endl;
for(int i = 0; i<2; i++) {
cout << "Checking Player " << i << endl;
for(auto a: (r->ltVectors)[i]) {
cout << a << " ";
}
cout << endl << endl;
}
cout << endl;
cout << "Checking size of EQ Matrix" << endl;
cout << r->eqMatrices.size();
cout << endl << endl;
cout << "Testing isFeasible Function:" << endl;
vector<int> vec{1,1,1};
std::tuple<bool, valarray<bool>, valarray<bool>> feas = r->isFeasible(0, vec);
cout << std::get<0>(feas) << endl;
for(auto a: std::get<1>(feas)) {
cout << a << " ";
}
cout << endl;
for(auto a: std::get<2>(feas)) {
cout << a << " ";
}
cout << endl << endl;
cout << "Testing getPureStrategyUtility:" << endl;
vector<vector<int>> pureStrategyProfile;
pureStrategyProfile.push_back(vector<int>{1,0,1});
pureStrategyProfile.push_back(vector<int>{1,0,1});
cout << r->getPureStrategyUtility(0, pureStrategyProfile) << endl << endl;
cout << "Testing getUtilityGradient:" << endl;
for(auto a: r->getUtilityGradient(0, pureStrategyProfile)) {
cout << a << " ";
}
cout << endl << endl;
cout << "Testing multiLinearSolve()" << endl;
r->multiLinearSolve();
cout << endl;
cout << "Creating Normal Form Rep " << endl;
Gambit::GameTableRep* nfg = r->toNormalForm();
cout << "Printing Normal Form Rep " << endl;
r->printNormalFormGame(nfg);
//std::ostringstream f;
//Gambit::StrategySupportProfile(nfg).WriteNfgFile(f);
//cout << f.str();
Gambit::StrategyProfileIterator iter{Gambit::StrategySupportProfile(nfg)};
Gambit::PureStrategyProfile p = *iter;
Gambit::List<Gambit::GameStrategy> bestResponseList = r->normalFormBestResponseList(0, p, nfg);
//need to actually get pureStrategyProfile in order to do this test
//vector<int> nfgBestResponse = r->nfBestResponseListContainsRGGBestResponse(0, bestResponseList, pureStrategyProfile[0]);
cout << endl << endl << "NFG Best Response: " << endl;
for(auto n: nfgBestResponse) {
cout << n << " ";
}
cout << endl;
//rgg::pureStrategy ps = r->convertNFGStrategyToRGGStrategy(0, r->normalFormFirstBestResponse(0,nfg));
//cout << "Best Normal Form Strategy:" << endl;
//for(auto x: ps)
// cout << x << " ";
//cout << endl;
//normalFormR->GetAction(1);
//Need to test normal form representation here
return 0;
}