SGSolve
SGAbstractGame Class Referenceabstract

A virtual class for constructing games. More...

#include <sgabstractgame.hpp>

Inheritance diagram for SGAbstractGame:

Public Member Functions

 SGAbstractGame (int _numPlayers, double _delta, int _numStates, vector< vector< int > > _numActions)
 Constructor for the pure virtual class.
 
 SGAbstractGame (double _delta, int _numStates, vector< vector< int > > _numActions)
 Constructor for the pure virtual class. More...
 
virtual SGPoint payoffs (int state, const vector< int > &actions) const =0
 The payoff function. More...
 
virtual double probability (int state, const vector< int > &actions, int statep) const =0
 Transition probabilities. More...
 
virtual bool isEquilibriumAction (int state, const vector< int > &actions) const
 
virtual bool constrained (int player) const
 Returns true if the given player is incentive constrained. More...
 
SGPoint payoffs (int state, int action) const
 An overloaded version of payoffs that uses a linear action index. More...
 
double probability (int state, int action, int statep) const
 
bool isEquilibriumAction (int state, int action) const
 
int getNumPlayers () const
 Returns the number of players.
 
double getDelta () const
 Returns the discount factor.
 
double getNumStates () const
 Returns the number of states.
 
const vector< vector< int > > getNumActions () const
 Returns the number of actions array.
 

Protected Member Functions

vector< int > indexToActions (int index, int state) const
 Converts a linear index to multiindex. More...
 

Protected Attributes

int numPlayers
 The number of players, always 2.
 
double delta
 The discount factor.
 
int numStates
 The number of states.
 
vector< vector< int > > numActions
 The numbers of actions in each state. More...
 

Detailed Description

A virtual class for constructing games.

The SGGame class has a constructor that constructs an SGGame object from any class that inherits SGAbstractGame. So you can inherit from this class as a convenience for building SGGame objects. For an example of how this is done, see risksharing.hpp. The user provides definitions of a payoffs method and a probability method that return the flow payoffs of the players and the transition probabilities between states, respectively. The value in this is that the user can provide rules for how these quantities are generated, rather than having to generate arrays of these values for passing to the SGGame constructor. See also SGGame::SGGame.

Constructor & Destructor Documentation

◆ SGAbstractGame()

SGAbstractGame::SGAbstractGame ( double  _delta,
int  _numStates,
vector< vector< int > >  _numActions 
)
inline

Constructor for the pure virtual class.

Grandfather in old code that is specialized to two players.

Member Function Documentation

◆ constrained()

virtual bool SGAbstractGame::constrained ( int  player) const
inlinevirtual

Returns true if the given player is incentive constrained.

The default definition of this method always returns true, so that both players' behavior is subject to incentive constraints. By making this method return false for one or both players, the user can implement models in which players can commit to their actions. When both players are not constrained, the algorithm will compute the feasible payoff correspondence.

◆ indexToActions()

vector<int> SGAbstractGame::indexToActions ( int  index,
int  state 
) const
inlineprotected

Converts a linear index to multiindex.

This function takes the linear index of an action pair in state s and returns a multiindex that gives each player's action.

◆ isEquilibriumAction() [1/2]

virtual bool SGAbstractGame::isEquilibriumAction ( int  state,
const vector< int > &  actions 
) const
inlinevirtual

Returns true if the given action pair can be played in equilibrium

The default definition of this method always returns true, so that all action pairs can be played in equilibrium. By redefining this method, the user can create models in which only a subset of action pairs are played on the equilibrium path.

Reimplemented in RiskSharingGame, RiskSharingGame_3Player, and RiskSharingGame_3Player_Merged.

◆ isEquilibriumAction() [2/2]

bool SGAbstractGame::isEquilibriumAction ( int  state,
int  action 
) const
inline

An overloaded version of isEquilibriumAction that uses a linear action index

This method converts the linear action index into an action pair and then returns the result of the user defined isEquilibriumAction method.

◆ payoffs() [1/2]

virtual SGPoint SGAbstractGame::payoffs ( int  state,
const vector< int > &  actions 
) const
pure virtual

The payoff function.

A class that is derived from SGAbstractGame must define the payoffs method, which returns, for a given state and action pair, the flow payoffs that the players receive as an SGPoint.

Implemented in RiskSharingGame, RiskSharingGame_3Player, RiskSharingGame_3Player_Merged, and ContributionGame.

◆ payoffs() [2/2]

SGPoint SGAbstractGame::payoffs ( int  state,
int  action 
) const
inline

An overloaded version of payoffs that uses a linear action index.

This method converts the linear action index into an action pair and then returns the result of the user defined payoffs method.

◆ probability() [1/2]

virtual double SGAbstractGame::probability ( int  state,
const vector< int > &  actions,
int  statep 
) const
pure virtual

Transition probabilities.

A class that derives from SGAbstractGame must define the probability method, which gives, for each state and action pair and new state, the probability of reaching the new state tomorrow when starting from the given state and when the given action pair is played.

Implemented in ContributionGame, RiskSharingGame, RiskSharingGame_3Player, and RiskSharingGame_3Player_Merged.

◆ probability() [2/2]

double SGAbstractGame::probability ( int  state,
int  action,
int  statep 
) const
inline

An overloaded version of probability that uses a linear action index

This method converts the linear action index into an action pair and then returns the result of the user defined probability method.

Member Data Documentation

◆ numActions

vector< vector<int> > SGAbstractGame::numActions
protected

The numbers of actions in each state.

numActions[s][s] is the number of actions that player i can take in state s.


The documentation for this class was generated from the following file: