-
Notifications
You must be signed in to change notification settings - Fork 13
GameDynamicsWrapper
A helper class that combines a dynamics class and a game class and provides helper methods for simulation. The object associated with it can be created by specifying the game to be simulated along with the dynamics. Optional keyword arguments associated to the game and dynamics may be specified to over-ride the defaults.
For example:
s=GameDynamicsWrapper(HawkDove,Moran,dynamics_kwargs={'pop_size'=1000})
This class provides two class methods for simulation,
-
simulate
: Simulate the game for a given number of generations. -
simulate_many
: Simulate the game for a given number of generations for multiple iterations.
The simulate method is used to run a basic simulation.
It has no required parameters and if none are specified, it will run the default number of generations in a simulation.
Optional parameters:
-
num_gens
: The number of generations for the simulation. -
pop_size
: Total population size. -
start_state
: Initial frequency distribution of the population. It is a multidimensional list of size m * n * l where m is the number of groups, n is the number of player types and l is the number of player strategies. -
graph=dict(options)
: The graph options to be included, see 'Graph' page for more details. -
return_labeled
: Whether or not the graph should be labeled. -
class_end=False
: Whether you wish to classify only the last generation or every generation. 'False' classifies every generation.
It is used to run several simulations of a single game and classifies the resulting equilibria. This also doesn't require any parameters and can run on defaults if not specified.
Optional parameters,
-
num_iterations
: Number of times to repeat the simulation -
num_gens
: The number of generations in each simulation. -
pop_size
: Total population size. -
start_state
: Initial frequency distribution of the population. Same form as above. -
graph=dict(options)
: The graph options to be included, see 'Graph' page for more details. -
histogram
: If True, plots the histogram of final population sizes over the iterations for each strategy of each player. Both graph and histogram can't be plotted at the same time. -
return_labeled
: Whether or not the graph should be labeled. -
parallelize
: Whether or not to parallelize the simulation across all available cores. -
class_end=True
: Whether you wish to classify only the last generation or every generation. 'True' classifies only the last generation.
Calculates the fraction of runs where a given strategy dominates by the end of the simulation as defined by the equilibrium_tolerance
in a symmetric game. It runs the simulate method num_iterations
times, where the start state consists of one player from the strategy of interest in the population of other player strategies. This approximates the fixation probability for large enough iterations and number of generations when the equilibrium_tolerance
is 0.
Required parameters,
-
strategy_indx
: Index of the strategy whose fixation probability is to be computed.
Optional parameters,
-
num_iterations
: Number of times to repeat the simulation -
num_gens
: The number of generations in each simulation. -
pop_size
: Total population size. -
parallelize
: Whether or not to parallelize the simulation across all available cores.