BCESolve
|
Class for iterating through arrays. More...
#include <bcecounter.hpp>
Public Member Functions | |
BCECounter () | |
Default constructor. | |
BCECounter (int _numStates, const vector< int > &_numActions, const vector< int > &_numTypes, const vector< int > &_stateConditions, const vector< vector< int > > &_actionConditions, const vector< vector< int > > &_typeConditions, bool _stateMarginal, const vector< bool > &_actionMarginal, const vector< bool > &_typeMarginal) | |
Constructor. More... | |
void | initialize () |
Initialization routine. More... | |
bool | operator++ () |
Increments the counter. More... | |
int | getNumMarginal () |
Returns the maximum marginal index. | |
int | getVariable () const |
Return the variable index. | |
int | getMarginal () const |
Return the marginal index. | |
int | getState () const |
Return the current state. | |
const vector< int > & | getTypes () const |
Return the current vector of types. | |
const vector< int > & | getActions () const |
Return the current vector of actions. | |
Private Attributes | |
int | variable |
Variable counter. More... | |
int | marginal |
Marginal counter. More... | |
int | stateType |
State/type counter. More... | |
int | numPlayers |
The number of players, always 2. | |
int | state |
Current index of the state. | |
vector< int > | actions |
Current action profile. | |
vector< int > | types |
Current type profile. | |
int | stateIndex |
Index of the current state. More... | |
vector< int > | actionIndices |
Indices of the current actions. More... | |
vector< int > | typeIndices |
Indices of the current types. More... | |
int | numMarginalVariables |
Maximum marginal index. More... | |
int | numVariables |
Maximum variable index. More... | |
vector< int > | stateConditions |
Conditions on the state. More... | |
vector< vector< int > > | actionConditions |
Conditions on the action profile. More... | |
vector< vector< int > > | typeConditions |
Conditions on the type profile. More... | |
bool | stateMarginal |
Determines if the state is a marginal dimension. More... | |
vector< bool > | actionMarginal |
Determines if actions are marginal dimensions. More... | |
vector< bool > | typeMarginal |
Determines if types are marginal directions. More... | |
int | numStates |
The number of states. | |
vector< int > | numActions |
Each player's number ofactions. | |
vector< int > | numTypes |
Each player's number of types. | |
vector< int > | actionIncrements |
Variable index increment when actions increase. | |
vector< int > | typeIncrements |
Variable index increment when types increase. | |
vector< int > | actionDecrements |
Variable index decrement when actions decrease. | |
vector< int > | typeDecrements |
Variable index decrement when actions decrease. | |
int | stateIncrementMarginal |
Marginal index increment when state increases. | |
vector< int > | actionIncrementsMarginal |
Marginal index increment when actions increase. | |
vector< int > | typeIncrementsMarginal |
Marginal index increment when types increase. | |
vector< int > | actionDecrementsMarginal |
Marginal index decrement when actions decrease. | |
vector< int > | typeDecrementsMarginal |
Marginal index decrement when types decrease. | |
vector< int > | actionIncrementsStateType |
State/type index increment when actions increase. | |
vector< int > | typeIncrementsStateType |
State/type index increment when types increase. | |
vector< int > | typeDecrementsStateType |
State/type index decrement when types decrease. | |
Class for iterating through arrays.
This class defines a "standard" order for quickly iterating through arrays indexed by states, actions profiles, and type profiles. The class contains functionality for iterating only through subsets of types and actions, to facilitate the computation of marginal and conditional distributions, assist with construction of constraints in BCESolver::populate, etc.
|
inline |
Constructor.
Initializes a new BCECounter for a game with the given numbers of states, actions, and types. When the counter iterates, it will skip those indices that do not satisfy the various state, action, and type conditions. If a given condition is empty, that means that all types will be allowed. The counter also calculates the marginal index over the dimensions specified in the various marginal arrays.
_numStates | The number of states. |
_numActions | The number of actions for each player. |
_numTypes | The number of types for each player. |
_stateConditions | A vector of permissible values for the state. If this vector is empty, any state value is allowed. |
_actionConditions | A vector of vectors. _actionConditions[player] is a vector of admissible values for that player's action. If _actionConditions[player] is empty, any action is allowed. |
_typeConditions | A vector of vectors. _typeConditions[player] is a vector of admissible values for that player's type. If _typeConditions[player] is empty, any type is allowed. |
_stateMarginal | A bool. If true, the state is one of the dimensions over which the marginal index iterates. |
_actionMarginal | A vector of bools. If _actionMarginal[player] is true, the marginal index will iterate over that player's action. |
_typeMarginal | A vector of bools. If _typeMarginal[player] is true, the marginal index will iterate over that player's type. |
See also the descriptions of corresponding property values.
void BCECounter::initialize | ( | ) |
Initialization routine.
This method is called by the constructor to initialize the counter. If any of the conditions vectors are empty, they are replaced with vectors allowing every possible condition. It calculates the increments that shoudld be used for the different indices when they are incremented, and initializes the indices to the appropriate values, given the conditions and marginals.
bool BCECounter::operator++ | ( | ) |
Increments the counter.
This method increments each of the indices in the counter. If the counter is at the end, it returns false, and otherwise it returns true.
|
private |
Conditions on the action profile.
actionConditions[k] is a vector of admissible values for player k's actions.
|
private |
Indices of the current actions.
actionIndices[k] is the index of that player k's current action in the array actionConditions[k].
|
private |
Determines if actions are marginal dimensions.
If actionMarginal[k] is true, the marginal index will iterate when player k's action changes.
|
private |
Marginal counter.
Marginal index over the subset of dimensions specified by marginal conditions.
|
private |
Maximum marginal index.
The maximum marginal index, or equivalently, the number of combinations of the variables whose marginal is true.
|
private |
Maximum variable index.
The maximum variable index, or equivalently, the total number of combinations of states, action profiles, and type profiles.
|
private |
Conditions on the state.
A vector of admissible values for the state.
|
private |
Index of the current state.
The index of the current state within the stateConditions array.
|
private |
Determines if the state is a marginal dimension.
If ture, the marginal index will iterate when the state changes.
|
private |
State/type counter.
Marginal index over the state and types.
|
private |
Conditions on the type profile.
typeConditions[k] is a vector of admissible values for player k's types.
|
private |
Indices of the current types.
typeIndices[k] is the index of that player k's current type in the array typeConditions[k].
|
private |
Determines if types are marginal directions.
If typeMarginal[k] is true, the marginal index will iterate when player k's action changes.
|
private |
Variable counter.
Index of the variable over all state/action profile/type profile combinations.