User’s API
- class MoranProcess.MoranProcess(size_list, label_list, BirthPayoffMatrix, DeathPayoffMatrix, TransitionMatrix=None)
General Moran Process with multiple types of individuals.
- __init__(size_list, label_list, BirthPayoffMatrix, DeathPayoffMatrix, TransitionMatrix=None)
Class initializer.
- Parameters:
size_list (list of int) – cardinalities of subpopulations.
label_list (list of str) – distinct labels of subpopulations.
BirthPayoffMatrix (np.array) – payoff matrix for the birth process.
DeathPayoffMatrix (np.array) – payoff matrix for the death process.
TransitionMatrix (np.array, optional) – transition probabilities between types. Defaults to None.
- population
entire population.
- Type:
list of Individual
- init_size_list
cardinalities of initial subpopulations.
- Type:
list of int
- curr_size_list
cardinalities of current subpopulations.
- Type:
list of int
- init_label_list
distinct labels of initial subpopulations.
- Type:
list of str
- BirthPayoffMatrix
payoff matrix for the birth process.
- Type:
np.array
- DeathPayoffMatrix
payoff matrix for the death process.
- Type:
np.array
- w
selection pressure weight for the fitness calculation.
- Type:
float
- AvgBirthPayoffDict
current average birth payoffs for distinct subpopulations.
- Type:
dict of str-float
- AvgDeathPayoffDict
current average death payoffs for distinct subpopulations.
- Type:
dict of str-float
- BirthFitnessDict
current birth fitnesses for distinct subpopulations.
- Type:
dict of str-float
- DeathFitnessDict
current death fitnesses for distinct subpopulations.
- Type:
dict of str-float
- Entropy
current entropy of the whole population.
- Type:
float
- TransitionMatrix
transition probabilities between types. Defaults to None.
- Type:
np.array, optional
- Raises:
AssertionError – on invalid arguments.
IncorrectValueError – on wrong values in the Transition Matrix.
- property population
Python getter.
- property init_size_list
Python getter.
- property curr_size_list
Python getter.
- property init_label_list
Python getter.
- property BirthPayoffMatrix
Python getter.
- property DeathPayoffMatrix
Python getter.
- property w
Python getter.
- property AvgBirthPayoffDict
Python getter.
- property AvgDeathPayoffDict
Python getter.
- property BirthFitnessDict
Python getter.
- property DeathFitnessDict
Python getter.
- property Entropy
Python getter.
- property TransitionMatrix
Python getter.
- simulate(generations)
Simulate population evolution.
Simulate population evolution: Birth-Death process with fitness-based selection of individuals.
- Parameters:
generations (int) – number of time steps.
- Returns:
table with simulation logs.
- Return type:
pd.DataFrame
- PlotSize(df, path)
Plot the sub-populations’ sizes after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotAvgBirthPayoff(df, path)
Plot the sub-populations’ AvgBirthPayoff after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotAvgDeathPayoff(df, path)
Plot the sub-populations’ AvgDeathPayoff after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotBirthFitness(df, path)
Plot the sub-populations’ BirthFitness after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotDeathFitness(df, path)
Plot the sub-populations’ DeathFitness after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotEntropy(df, path)
Plot the whole populations entropy after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- class MoranProcess2D.MoranProcess2D(size_list, label_list, grid, BirthPayoffMatrix, DeathPayoffMatrix, TransitionMatrix=None)
2D Moran Process with multiple types of individuals.
- __init__(size_list, label_list, grid, BirthPayoffMatrix, DeathPayoffMatrix, TransitionMatrix=None)
Class initializer.
- Parameters:
size_list (list of int) – cardinalities of subpopulations.
label_list (list of str) – distinct labels of subpopulations.
grid (np.array) – subpopulations’ position in 2D.
BirthPayoffMatrix (np.array) – payoff matrix for the birth process.
DeathPayoffMatrix (np.array) – payoff matrix for the death process.
TransitionMatrix (np.array, optional) – transition probabilities between types. Defaults to None.
- population
entire population.
- Type:
list of Individual
- init_size_list
cardinalities of initial subpopulations.
- Type:
list of int
- curr_size_list
cardinalities of current subpopulations.
- Type:
list of int
- init_label_list
distinct labels of initial subpopulations.
- Type:
list of str
- BirthPayoffMatrix
payoff matrix for the birth process.
- Type:
np.array
- DeathPayoffMatrix
payoff matrix for the death process.
- Type:
np.array
- w
selection pressure weight for the fitness calculation.
- Type:
float
- Entropy
current entropy of the whole population.
- Type:
float
- TransitionMatrix
transition probabilities between types. Defaults to None.
- Type:
np.array, optional
- init_grid
subpopulations’ initial position in 2D.
- Type:
np.array
- curr_grid
subpopulations’ initial position in 2D.
- Type:
np.array
- Raises:
AssertionError – on invalid arguments.
IncorrectValueError – on wrong values in the Transition Matrix.
- property population
Python getter.
- property init_size_list
Python getter.
- property curr_size_list
Python getter.
- property init_label_list
Python getter.
- property init_grid
Python getter.
- property curr_grid
Python getter.
- property BirthPayoffMatrix
Python getter.
- property DeathPayoffMatrix
Python getter.
- property w
Python getter.
- property Entropy
Python getter.
- property TransitionMatrix
Python getter.
- simulate(generations)
Simulate 2D population evolution.
Simulate 2D population evolution: Birth-Death process with fitness-based selection of individuals.
- Parameters:
generations (int) – number of time steps.
- Returns:
table with simulation logs.
- Return type:
pd.DataFrame
- PlotSize2D(df, path)
Plot the sub-populations’ sizes after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotEntropy2D(df, path)
Plot the whole populations entropy after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotPopulationSnapshot2D(path)
Plot a grid snapshot of the current state of the whole population.
- Parameters:
path (str) – path for the plot.
- class MoranProcess3D.MoranProcess3D(size_list, label_list, grid, BirthPayoffMatrix, DeathPayoffMatrix, TransitionMatrix=None)
3D Moran Process with multiple types of individuals.
- __init__(size_list, label_list, grid, BirthPayoffMatrix, DeathPayoffMatrix, TransitionMatrix=None)
Class initializer.
- Parameters:
size_list (list of int) – cardinalities of subpopulations.
label_list (list of str) – distinct labels of subpopulations.
grid (np.array) – subpopulations’ position in 3D.
BirthPayoffMatrix (np.array) – payoff matrix for the birth process.
DeathPayoffMatrix (np.array) – payoff matrix for the death process.
TransitionMatrix (np.array, optional) – transition probabilities between types. Defaults to None.
- population
entire population.
- Type:
list of Individual
- init_size_list
cardinalities of initial subpopulations.
- Type:
list of int
- curr_size_list
cardinalities of current subpopulations.
- Type:
list of int
- init_label_list
distinct labels of initial subpopulations.
- Type:
list of str
- BirthPayoffMatrix
payoff matrix for the birth process.
- Type:
np.array
- DeathPayoffMatrix
payoff matrix for the death process.
- Type:
np.array
- w
selection pressure weight for the fitness calculation.
- Type:
float
- Entropy
current entropy of the whole population.
- Type:
float
- TransitionMatrix
transition probabilities between types. Defaults to None.
- Type:
np.array, optional
- init_grid
subpopulations’ initial position in 3D.
- Type:
np.array
- curr_grid
subpopulations’ initial position in 3D.
- Type:
np.array
- Raises:
AssertionError – on invalid arguments.
IncorrectValueError – on wrong values in the Transition Matrix.
- property population
Python getter.
- property init_size_list
Python getter.
- property curr_size_list
Python getter.
- property init_label_list
Python getter.
- property init_grid
Python getter.
- property curr_grid
Python getter.
- property BirthPayoffMatrix
Python getter.
- property DeathPayoffMatrix
Python getter.
- property w
Python getter.
- property Entropy
Python getter.
- property TransitionMatrix
Python getter.
- simulate(generations)
Simulate 3D population evolution.
Simulate 3D population evolution: Birth-Death process with fitness-based selection of individuals.
- Parameters:
generations (int) – number of time steps.
- Returns:
table with simulation logs.
- Return type:
pd.DataFrame
- PlotSize3D(df, path)
Plot the sub-populations’ sizes after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.
- PlotEntropy3D(df, path)
Plot the whole populations entropy after a simulation.
- Parameters:
df (pd.DataFrame) – table with simulation logs.
path (str) – path for the plot.