-
Notifications
You must be signed in to change notification settings - Fork 13
VariedGame
The VariedGame
class is used when we wish to study the impact of a parameter(s) on the game in consideration.
def vary(self, game_kwargs=None, dynamics_kwargs=None, num_iterations=DEFAULT_ITERATIONS, num_gens=DEFAULT_GENERATIONS, burn=0, graph=False, parallelize=True)
The vary
method can be used to vary any number of parameters associated with the game, the dynamics or any number of indirect inputs. Each of these parameters must be an iterable of dictionaries in the form:
game_kwargs = [{INDEPENDENT},{DEPENDENT}, {INDIRECT}]
.
-
INDEPENDENT: Each key must be the string of the param name, as seen in the constructor. Each value is an iterable of 3 values (lower_bound, upper_bound, num_steps)
-
DEPENDENT: Each key must be the string of the param name, as seen in the constructor, cannot have any of the keys in the keys of the INDEPENDENT dict. Each value is a function that takes in kwargs for the namespace
-
INDIRECT: Each key must be the string of the param name, as seen in the constructor, cannot have any of the keys in the keys of the INDEPENDENT or DEPENDENT dicts
For example:
wf_varied = VariedGame(CWOL,WrightFisher,dynamics_kwargs={'number_groups':5})
wf_varied.vary(dynamics_kwargs={'rate':[0.05,0.5,6]},num_gens=500,num_iterations=100,parallelize=True,graph=dict(area=True,options=['smallfont']))
We first create a VariedGame
object which is going to simulate the 'Cooperate Without Looking' game with Wright-Fisher dynamics in a population that has 5 groups. The next line simulates the process while varying the rate of group selection between each simulation.
vary_param
and vary_2params
are two helper methods that are provided if we wish to just vary one or two parameters associated with the Game
.