25 #include "sgcommon.hpp"
27 #include "sgexception.hpp"
28 #include "sgtuple.hpp"
29 #include "sgabstractgame.hpp"
30 #include <boost/archive/text_iarchive.hpp>
31 #include <boost/archive/text_oarchive.hpp>
32 #include <boost/serialization/utility.hpp>
94 template <
class Archive>
96 void serialize(Archive& ar,
const unsigned int version)
116 probabilities(1,vector< vector<double> > (1,vector<double> (1,1))),
138 const vector< vector<int> > & _numActions,
139 const vector< vector< vector<double> > > & _payoffs,
140 const vector< vector< vector<double> > > & _probabilities);
145 const vector< vector<int> > & _numActions,
146 const vector< vector< vector<double> > > & _payoffs,
147 const vector< vector< vector<double> > > & _probabilities,
148 const vector<bool> & _unconstrained);
157 const vector< vector<int> > & _numActions,
158 const vector< vector< vector<double> > > & _payoffs,
159 const vector< vector< vector<double> > > & _probabilities,
160 const vector< vector<bool> > & _eqActions,
161 const vector<bool> & _unconstrained);
168 const vector< vector<int> > & _numActions,
169 const vector< vector< vector<double> > > & _payoffs,
170 const vector< vector< vector<double> > > & _probabilities,
171 const vector< vector<bool> > & _eqActions,
172 const vector<bool> & _unconstrained);
210 bool setPayoff(
int state,
int action,
int player,
double payoff);
215 int newState,
double prob);
222 bool addAction(
int state,
int player,
int position);
242 std::ofstream ofs(filename);
246 boost::archive::text_oarchive oa(ofs);
256 std::ifstream ifs(filename);
259 boost::archive::text_iarchive ia(ifs);
266 friend class boost::serialization::access;
267 friend class SGSolver;
void getPayoffBounds(SGPoint &UB, SGPoint &LB) const
Definition: sggame.cpp:167
vector< bool > unconstrained
Definition: sggame.hpp:89
int getNumPlayers() const
Returns SGGame::numPlayers, the number of players.
Definition: sggame.hpp:177
const vector< vector< SGPoint > > & getPayoffs() const
Returns a const reference to the payoffs.
Definition: sggame.hpp:191
bool setConstrained(const vector< bool > &_unconstrained)
Sets whether or not players are incentive constrained.
Definition: sggame.cpp:380
void serialize(Archive &ar, const unsigned int version)
Serializes the game using boost.
Definition: sggame.hpp:96
double getDelta() const
Returns SGGame::delta, the discount factor.
Definition: sggame.hpp:175
Describes a stochastic game.
Definition: sggame.hpp:40
SGGame()
Default constructor.
Definition: sggame.hpp:111
@ FAILED_OPEN
Definition: sgnamespace.hpp:32
bool addState(int position)
Adds a new state.
Definition: sggame.cpp:327
static void save(const SGGame &game, const char *filename)
Static method for saving an SGGame object to the file filename.
Definition: sggame.hpp:240
const vector< int > & getNumActions_total() const
Definition: sggame.hpp:185
SGSolve specific exceptions.
Definition: sgexception.hpp:36
const vector< vector< int > > & getNumActions() const
Sets the argument _numActions equal to SGGame::numActions.
Definition: sggame.hpp:181
vector< vector< bool > > eqActions
Definition: sggame.hpp:77
bool setDiscountFactor(double newDelta)
Set discount factor.
Definition: sggame.cpp:192
bool setProbability(int state, int action, int newState, double prob)
Set probability.
Definition: sggame.cpp:215
bool profitableDeviation(vector< int > &input, SGGame game)
Check if there exists a profitable deviation.
Definition: sggame.cpp:408
A virtual class for constructing games.
Definition: sgabstractgame.hpp:41
vector< vector< int > > numActions
Definition: sggame.hpp:45
vector< vector< SGPoint > > payoffs
Definition: sggame.hpp:58
const vector< vector< bool > > & getEquilibriumActions() const
Returns a const reference to the equilibrium actions.
Definition: sggame.hpp:194
vector< vector< vector< double > > > probabilities
Definition: sggame.hpp:65
const vector< vector< vector< double > > > & getProbabilities() const
Returns a const reference to probabilities.
Definition: sggame.hpp:188
bool addAction(int state, int player, int position)
Adds a new action.
Definition: sggame.cpp:229
double delta
Definition: sggame.hpp:42
A vector in .
Definition: sgpoint.hpp:35
bool removeState(int state)
Removes the given state.
Definition: sggame.cpp:356
bool transitionProbsSumToOne(double tolerance=1e-3) const
Check if transition probabilities sum to one.
Definition: sggame.cpp:390
int getNumStates() const
Returns the number of states.
Definition: sggame.hpp:179
const vector< bool > & getConstrained() const
Returns the unconstrained vector.
Definition: sggame.hpp:201
int numStates
Definition: sggame.hpp:44
static void load(SGGame &game, const char *filename)
Static method for loading an SGGame object from the file filename.
Definition: sggame.hpp:254
bool setPayoff(int state, int action, int player, double payoff)
Set payoffs.
Definition: sggame.cpp:202
vector< int > numActions_total
Definition: sggame.hpp:55
bool removeAction(int state, int player, int action)
Removes the given action.
Definition: sggame.cpp:279
int numPlayers
Definition: sggame.hpp:43