egttools.numerical.structure.AbstractStructure¶
- class AbstractStructure(self: egttools.numerical.numerical_.structure.AbstractStructure)¶
Bases:
pybind11_object
Abstract class which must be implemented by any new population structure.
This class provides a common interface for classes that implement general behavioral updates for a population of a given structure.
A population structure in egttools is meant to contain a population (which may be structure in any way in function of the implementation) and whose state (the behaviors of the individuals) are updated according to a given function.
For this reason, a Structure class must expose a method to initialize the population (specific implementations may add other initialization methods), a method to update the population given its current state, a method that returns the number of possible strategies in the population, and a method that returns the mean state of the population, i.e., how many individuals, in total, in the population adopt each strategy.
Moreover, we encourage specific implementations to also expose the structure of the population and the changes in the behavior of each individual to the user.
You must implement the following methods: - initialize() - update_population() - mean_population_state() - nb_strategies()
See also
egttools.numerical.structures.Network
Note
This is still a first implementation. This class might be renamed in the future and the API might change.
Methods
Initializes each element of the structure.
Returns the mean population state.
Returns the maximum number of strategies that can be present in the population.
Updates the population for one generation.
- __init__(self: egttools.numerical.numerical_.structure.AbstractStructure) None ¶
Abstract class which must be implemented by any new population structure.
This class provides a common interface for classes that implement general behavioral updates for a population of a given structure.
A population structure in egttools is meant to contain a population (which may be structure in any way in function of the implementation) and whose state (the behaviors of the individuals) are updated according to a given function.
For this reason, a Structure class must expose a method to initialize the population (specific implementations may add other initialization methods), a method to update the population given its current state, a method that returns the number of possible strategies in the population, and a method that returns the mean state of the population, i.e., how many individuals, in total, in the population adopt each strategy.
Moreover, we encourage specific implementations to also expose the structure of the population and the changes in the behavior of each individual to the user.
You must implement the following methods: - initialize() - update_population() - mean_population_state() - nb_strategies()
See also
egttools.numerical.structures.Network
Note
This is still a first implementation. This class might be renamed in the future and the API might change.
- __new__(**kwargs)¶
- initialize(self: egttools.numerical.numerical_.structure.AbstractStructure) None ¶
Initializes each element of the structure.
In Evolutionary games, this means that each individual in the structure is assigned a strategy according to some algorithm (generally it will be a random assignment). It is recommended that subclasses which wish to implement other assignment types, create different methods with more concrete name, e.g., initialize_all_black, would initialize each individual with the black strategy.
- mean_population_state(self: egttools.numerical.numerical_.structure.AbstractStructure) numpy.ndarray[numpy.uint64[m, 1]] ¶
Returns the mean population state.
- Returns:
The total counts of each strategy in the population.
- Return type:
- nb_strategies(self: egttools.numerical.numerical_.structure.AbstractStructure) int ¶
Returns the maximum number of strategies that can be present in the population.
- Returns:
The maximum number of strategies that can be present in the population.
- Return type:
- update_population(self: egttools.numerical.numerical_.structure.AbstractStructure) None ¶
Updates the population for one generation.
The developer has freedom to implement this method. All that is required is that it applies some change to the population every time it is called given the current population state.
- __annotations__ = {}¶