Class Moran
- All Implemented Interfaces:
Runnable
,IBS.HasIBS
,MilestoneListener
,ODE.HasDE
,ODE.HasODE
,PDE.HasPDE
,SDE.HasSDE
,Features
,Features.Static
,HasHistogram
,HasHistogram.Degree
,HasHistogram.Fitness
,HasHistogram.StatisticsProbability
,HasHistogram.StatisticsStationary
,HasHistogram.StatisticsTime
,HasMean
,HasMean.Fitness
,HasMean.Strategy
,HasPop2D
,HasPop2D.Fitness
,HasPop2D.Strategy
,HasPop3D
,HasPop3D.Fitness
,HasPop3D.Strategy
,CLOProvider
- Direct Known Subclasses:
simMoran
In structured populations the situation gets even more interesting in that certain population structures can act as evolutionary amplifiers or evolutionary suppressors by increasing or decreasing the fixation probabilities of advantageous mutants.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested classes/interfaces inherited from interface Features
Features.Groups, Features.Pairs, Features.Static
Nested classes/interfaces inherited from interface HasHistogram
HasHistogram.Degree, HasHistogram.Fitness, HasHistogram.StatisticsProbability, HasHistogram.StatisticsStationary, HasHistogram.StatisticsTime, HasHistogram.Strategy
Nested classes/interfaces inherited from interface HasMean
HasMean.Fitness, HasMean.Strategy
Nested classes/interfaces inherited from interface HasPop2D
HasPop2D.Fitness, HasPop2D.Strategy
Nested classes/interfaces inherited from interface HasPop3D
HasPop3D.Fitness, HasPop3D.Strategy
Nested classes/interfaces inherited from interface IBS.HasIBS
IBS.HasIBS.CGroups, IBS.HasIBS.CPairs, IBS.HasIBS.DGroups, IBS.HasIBS.DPairs, IBS.HasIBS.MCGroups, IBS.HasIBS.MCPairs
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CLOption
Command line option to set the fitness values for residents and mutants.static final int
The trait (and index) value of mutants.static final int
The trait (and index) value of residents.(package private) double
Store fixation probability ofi
individuals of typeA
.(package private) double
Store fixation time ofi
individuals of typeA
.(package private) double
Store absorption time ofi
individuals of typeA
.protected double[]
The array with the scores for each trait.Fields inherited from class Discrete
cloMonoStop, monoStop, mutation, species
Fields inherited from class Module
active, cloDeathRate, cloGeometry, cloNGroup, cloNPopulation, cloPhase2DAxis, cloSpeciesUpdateRate, cloTraitColors, cloTraitDisable, cloTraitNames, competition, deathRate, defaultColor, engine, ibs, ID, interaction, logger, map2fitness, markers, model, nActive, name, nGroup, nPopulation, nTraits, opponent, playerUpdate, speciesUpdateRate, structure, traitColor, traitName, trajectoryColor, VACANT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
avgScores
(double[] density, int n, double[] avgscores) Calculate the average payoff/score for the frequency of traits/strategies specified in the arraydensity
for interactions in groups of sizen
.void
collectCLO
(CLOParser parser) All providers of command line options must implement this method to collect their options.Returns a string with information about the authors of the module.double[]
getCustomLevels
(Data type, int trait) Some models may provide reference values for histograms as a horizontal line marking a particular value.int
Get the index of dependent type or-1
if Module does not have an dependent type.double[]
Get the array of fitness values for residents and mutants.double
getFitness
(int aType) Get the fitness value for traitaType
.double
Calculates and returns the maximum payoff/score of an individual.double
Calculates and returns the minimum payoff/score of an individual.double
getMonoGameScore
(int type) Calculate and return the payoff/score of individuals in monomorphic populations with trait/strategytype
.private double[]
getReferenceProb
(int trait) Helper method to retrieve the reference fixation probabilities for traittrait
for the initial number of mutants according toinit
.private double[]
getReferenceTime
(int trait) Helper method to retrieve the reference fixation times for traittrait
for the initial number of mutants according toinit
.double[]
Gets the static scores for the different types.getTitle()
Returns title of active module, e.g.void
load()
Load new module and perform basic initializations.void
Called when the settings of the EvoLudo model changed but no reset was necessary.protected double
rhoA
(int i, int n) The fixation probability ofi
mutants in a population of constant sizeN
(andN-i
residents).void
setFitness
(double[] aValue) Set the fitness values for residents and mutants.void
setFitness
(double aValue, int aType) Set the fitness value for traitaType
toaValue
.protected double
t1
(double rhoA, int n) The absorbtion time (in generations) of a single mutant in a population of constant sizeN
(andN-1
residents).protected double
tA1
(int n) The conditional fixation time of a single mutant in a population of fixed sizeN
(andN-1
residents) measured in generations.protected double
tAi
(int i, int n, double rhoA, double tA1) The conditional fixation time ofi
mutants in a population of fixed sizeN
(andN-i
residents) measured in generations.protected double
ti
(int i, int n, double t1) The absorbtion time (in generations) ofi
mutants in a population of constant sizeN
(andN-i
residents).private double
Tplus
(int i, int n) Transition probability to go fromi
toi+1
mutants in a population of sizeN
.private double
Tratio
(int i) The ratio of transition probabilities to go fromi
toi+1
mutants over the reverse, i.e.void
unload()
Unload module and free all resources.Methods inherited from class Discrete
add, getMaxMonoGameScore, getMinMonoGameScore, getMonoStop, getMutation, setMonoStop
Methods inherited from class Module
check, createGeometry, createIBSPop, getActiveTraits, getCompetitionGeometry, getDeathRate, getGeometry, getIBSPopulation, getID, getInteractionGeometry, getKey, getMapToFitness, getMarkers, getMeanColors, getModelTypes, getNActive, getName, getNGroup, getNPopulation, getNRoles, getNSpecies, getNTraits, getOpponent, getPlayerUpdate, getSpecies, getSpecies, getSpeciesUpdateRate, getTraitColor, getTraitColors, getTraitName, getTraitNames, getTrajectoryColor, getVacant, init, isNeutral, processColorMap, reset, run, setActiveTraits, setDeathRate, setGeometries, setIBSPopulation, setModel, setName, setNGroup, setNPopulation, setNTraits, setOpponent, setSpeciesUpdateRate, setTraitColors, setTraitNames, setTrajectoryColor
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface CLOProvider
adjustCLO
Methods inherited from interface Features
isPairwise
Methods inherited from interface Features.Static
isStatic
Methods inherited from interface HasHistogram
getNTraits, getTraitColors
Methods inherited from interface IBS.HasIBS
createIBS
Methods inherited from interface MilestoneListener
modelDidInit, modelDidReset, modelLoaded, modelRelaxed, modelRunning, modelStopped, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloaded
Methods inherited from interface ODE.HasODE
createODE
Methods inherited from interface PDE.HasPDE
createPDE
Methods inherited from interface SDE.HasSDE
createSDE
-
Field Details
-
RESIDENT
public static final int RESIDENTThe trait (and index) value of residents.- See Also:
-
MUTANT
public static final int MUTANTThe trait (and index) value of mutants.- See Also:
-
typeScores
protected double[] typeScoresThe array with the scores for each trait. -
rhoAi
double rhoAiStore fixation probability ofi
individuals of typeA
. -
tAi
double tAiStore fixation time ofi
individuals of typeA
. -
taui
double tauiStore absorption time ofi
individuals of typeA
. -
cloFitness
Command line option to set the fitness values for residents and mutants.
-
-
Constructor Details
-
Moran
Create a new instance of the module for the Moran process.- Parameters:
engine
- the manager of modules and pacemaker for running the model
-
-
Method Details
-
load
public void load()Description copied from class:Module
Load new module and perform basic initializations. -
unload
public void unload()Description copied from class:Module
Unload module and free all resources. -
getAuthors
Description copied from class:Module
Returns a string with information about the authors of the module.- Overrides:
getAuthors
in classModule
- Returns:
- the names of the authors
-
getTitle
Description copied from class:Module
Returns title of active module, e.g. 2x2 games inTBT
returns "2x2 Games". -
getDependent
public int getDependent()Description copied from class:Module
Get the index of dependent type or-1
if Module does not have an dependent type.Notes:
- Dependent types are used by replicator type models where the frequencies of all types must sum up to one. Currently only used by Discrete modules.
- Density modules do not have dependent types.
- By default use vacant type as the dependent
- Specified by:
getDependent
in interfaceODE.HasDE
- Overrides:
getDependent
in classModule
- Returns:
- the index of the vacant type
-
getMinGameScore
public double getMinGameScore()Description copied from class:Module
Calculates and returns the minimum payoff/score of an individual. This value is important for converting payoffs/scores into probabilities, for scaling graphical output and some optimizations.- Specified by:
getMinGameScore
in classModule
- Returns:
- the minimum payoff/score
- See Also:
-
getMaxGameScore
public double getMaxGameScore()Description copied from class:Module
Calculates and returns the maximum payoff/score of an individual. This value is important for converting payoffs/scores into probabilities, for scaling graphical output and some optimizations.- Specified by:
getMaxGameScore
in classModule
- Returns:
- the maximum payoff/score
- See Also:
-
getMonoGameScore
public double getMonoGameScore(int type) Description copied from class:Discrete
Calculate and return the payoff/score of individuals in monomorphic populations with trait/strategytype
.Note: Optional implementation. Returns
Double#NaN
if not defined or not implemented.- Overrides:
getMonoGameScore
in classDiscrete
- Parameters:
type
- trait/strategy- Returns:
- payoff/score in monomorphic population with trait/strategy
type
-
getStaticScores
public double[] getStaticScores()Description copied from interface:Features.Static
Gets the static scores for the different types.- Specified by:
getStaticScores
in interfaceFeatures.Static
- Returns:
- the array with the static scores
-
avgScores
public void avgScores(double[] density, int n, double[] avgscores) Description copied from interface:ODE.HasDE
Calculate the average payoff/score for the frequency of traits/strategies specified in the arraydensity
for interactions in groups of sizen
. The average payoffs/scores for each of thenTraits
traits/strategies must be stored and returned in the arrayavgscores
.Note: needs to be thread safe for parallel processing of PDE's.
IMPORTANT: one of
should be implemented in modules that advertise the model typesODE, SDE
orPDE
.Alternatively, the method
ODE.getDerivatives(double, double[], double[], double[])
may be overridden in a subclass ofODE
, which may prevent calls toavgScores(...)
altogether. -
setFitness
public void setFitness(double[] aValue) Set the fitness values for residents and mutants.- Parameters:
aValue
- the array with fitness values
-
setFitness
public void setFitness(double aValue, int aType) Set the fitness value for traitaType
toaValue
.- Parameters:
aValue
- the fitness for traitaType
aType
- the trait to set the fitness
-
getFitness
public double[] getFitness()Get the array of fitness values for residents and mutants.- Returns:
- the array of fitness values
-
getFitness
public double getFitness(int aType) Get the fitness value for traitaType
.- Parameters:
aType
- the trait to get the fitness- Returns:
- the fitness value
-
getCustomLevels
Description copied from interface:HasHistogram
Some models may provide reference values for histograms as a horizontal line marking a particular value. For example this is the case for statistics of fixation probabilities or times in theorg.evoludo.simulator.modules.Moran Moran
module where the analytical results are provided as a reference to highlight the effects of population structures.- Specified by:
getCustomLevels
in interfaceHasHistogram
- Parameters:
type
- the type of data shown in the histogramtrait
- the index of the trait- Returns:
- the array of levels for reference
-
modelSettings
public void modelSettings()Description copied from interface:MilestoneListener
Called when the settings of the EvoLudo model changed but no reset was necessary.- Specified by:
modelSettings
in interfaceMilestoneListener
-
getReferenceProb
private double[] getReferenceProb(int trait) Helper method to retrieve the reference fixation probabilities for traittrait
for the initial number of mutants according toinit
. In order to optimize repeated calls the result is stored in the fieldstatRefProb
and storage allocated as necessary.- Parameters:
trait
- the trait for which to get the reference fixation probability- Returns:
- the reference fixation probability
- See Also:
-
getReferenceTime
private double[] getReferenceTime(int trait) Helper method to retrieve the reference fixation times for traittrait
for the initial number of mutants according toinit
. In order to optimize repeated calls the result is stored in the fieldstatRefTime
and storage allocated as necessary.- Parameters:
trait
- the trait for which to get the reference fixation time- Returns:
- the reference fixation time
- See Also:
-
collectCLO
Description copied from interface:CLOProvider
All providers of command line options must implement this method to collect their options.Each command line option is (uniquely) identified by it's name (see
CLOption.getName()
), which corresponds to the long version of the option. If an attempt is made to add an option with a name that already exists, theparser
issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and callsuper.collectCLO(CLOParser)
at the end such that subclasses are able to override command line options specified in a parental class.Override this method in subclasses to add further command line options. Subclasses must make sure that they include a call to super.
- Specified by:
collectCLO
in interfaceCLOProvider
- Overrides:
collectCLO
in classDiscrete
- Parameters:
parser
- the reference to parser that manages command line options- See Also:
-
Tplus
private double Tplus(int i, int n) Transition probability to go fromi
toi+1
mutants in a population of sizeN
.- Parameters:
i
- the number of mutantsn
- the size of the population- Returns:
- the transition probability
-
Tratio
private double Tratio(int i) The ratio of transition probabilities to go fromi
toi+1
mutants over the reverse, i.e. \(T_i^-/T_i^+). In the classical Moran process this is simply a constant and, in particular, independent ofi
.- Parameters:
i
- the number of mutants- Returns:
- the ratio of transition probabilities
-
rhoA
protected double rhoA(int i, int n) The fixation probability ofi
mutants in a population of constant sizeN
(andN-i
residents).- Parameters:
i
- the number of mutantsn
- the size of the population- Returns:
- the fixation probability
-
t1
protected double t1(double rhoA, int n) The absorbtion time (in generations) of a single mutant in a population of constant sizeN
(andN-1
residents).- Parameters:
rhoA
- the fixation probability of a single mutantn
- the size of the population- Returns:
- the absorbtion time
- See Also:
-
ti
protected double ti(int i, int n, double t1) The absorbtion time (in generations) ofi
mutants in a population of constant sizeN
(andN-i
residents).- Parameters:
i
- the number of mutantsn
- the size of the populationt1
- the absorbtion time of a single mutant- Returns:
- the absorbtion time of
i
mutants - See Also:
-
tA1
protected double tA1(int n) The conditional fixation time of a single mutant in a population of fixed sizeN
(andN-1
residents) measured in generations.- Parameters:
n
- the size of the population- Returns:
- the conditional fixation time
-
tAi
protected double tAi(int i, int n, double rhoA, double tA1) The conditional fixation time ofi
mutants in a population of fixed sizeN
(andN-i
residents) measured in generations.- Parameters:
i
- the number of mutantsn
- the size of the populationrhoA
- the fixation probability of a single mutanttA1
- the fixation time of a single mutant- Returns:
- the conditional fixation time
-