SGSolve
SGSimulator Class Reference

Class for forward simulating equilibria. More...

#include <sgsimulator.hpp>

Collaboration diagram for SGSimulator:

Public Member Functions

 SGSimulator (const SGSolution_PencilSharpening &_soln)
 Constructor.
 
const vector< vector< int > > getActionDistr () const
 Returns the action frequency distributions.
 
const vector< int > getStateDistr () const
 Returns the state frequency distribution.
 
const vector< int > getTupleDistr () const
 Returns the tuple frequency distribution.
 
int getStartOfLastRev () const
 Returns the start of the last revolution.
 
int getNumIter () const
 Returns the number of iterations for the current simulation.
 
void setLogFlag (bool newFlag)
 Mutator method for the log flag.
 
const std::stringstream & getStringStream () const
 Returns the stringstream describing the first 200 periods.
 
const std::stringstream & getTransitionTableStringStream () const
 Returns the stringstream describing the transition table.
 
void initialize ()
 Initializes the transition table.
 
void simulate (int _numSim, int _numIter, int initialState, int initialTuple)
 Forward simulates the equilibrium.
 
SGPoint getLongRunPayoffs ()
 Returns the long run action distribution.
 

Private Types

typedef pair< list< SGIteration_PencilSharpening >::const_iterator, double > transitionPair
 

Private Attributes

const SGSolution_PencilSharpeningsoln
 The associated SGSolution object.
 
list< SGIteration_PencilSharpening >::const_iterator startOfLastRev
 Points to the beginning of the last revolution.
 
vector< vector< list< transitionPair > > > transitionTable
 The transition table. More...
 
vector< vector< int > > actionDistr
 The distribution of actions in each state. More...
 
vector< int > tupleDistr
 
vector< int > stateDistr
 
int numSim
 The number of simulations to run.
 
int numIter
 The number of periods for each simulation.
 
bool logFlag
 True if saving log information to the stringstreams.
 
double weightTol
 Tolerance for computing the transition table.
 
std::stringstream ss
 
std::stringstream transitionTableSS
 Contains a text description of the transition table.
 

Detailed Description

Class for forward simulating equilibria.

This class simulates an equilibrium based on a given SGSolution and initial state and an initial iteration from the final revolution. This iteration describes a basic equilibrium that maximizes in the given iteration's current direction.

In order to simulate, you first have to call the SGSimulator::initialize method in order to construct the "transition table". This table determines, for each iteration in the final revolution and for each state, which action generates the flow payoffs and which continuation equilibrium should be used. If incentive constraints are not binding, the continuation equilibrium is described by the same iteration. Otherwise, some constraint binds, and the transition table decomposes the continuation equilibrium as a lottery over basic equilibria corresponding to tuples on the last revolution. If only one player's incentive constraint binds, then this decomposition is generically unique. If, however, more than one constraint binds or there is some non-genericity in payoffs, then the algorithm selects one decomposition arbitrarily.

Having constructed the transition table, the equilibrium can be forward simulated using SGSimulator::simulate. The arguments to the simulate method are the number of periods for which to simulate, the initial state, and the initial tuple. When forward simulating, the class keeps track of the distributions of tuples (in the final revolution), states, and actions in each state. These can be retrieved using their various get methods. SGSimulator::getLongRunPayoffs will compute average payoffs for the players over the course of the simulation. The class will save a text version of the transition table in transitionTableSS, and it will save a text version of the first 200 periods of the simulation in SS.

TODO: Refine the procedure for constructing the transition table when both incentive constraints bind.

This code is part of the pencil-sharpening algorithm and has not been updated to the max-min-max algorithm.

Member Data Documentation

◆ actionDistr

vector< vector<int> > SGSimulator::actionDistr
private

The distribution of actions in each state.

actionDistr[state][action] is the frequency of that action in the corresponding state over the course of the simulation.

◆ ss

std::stringstream SGSimulator::ss
private

Contains a text description of the first 200 periods of the simulation.

◆ stateDistr

vector<int> SGSimulator::stateDistr
private

The frequency distribution of states over the course of the simulation.

◆ transitionTable

vector< vector< list<transitionPair> > > SGSimulator::transitionTable
private

The transition table.

This table consists of, for each state and tuple, a list transitionTable[tuple][state] of transitionPair data points. Each pair consists of an iterator that points to some continuation iteration, and a double which represents the probability of transitioning to the corresponding continuation equilibrium.

◆ tupleDistr

vector<int> SGSimulator::tupleDistr
private

The frequency distribution of tuples over the course of the simulation.


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