Class Moran
- All Implemented Interfaces:
Runnable,IBS.HasIBS,MilestoneListener,Model.HasDE,Model.HasDE.EM,Model.HasDE.ODE,Model.HasDE.PDE,Model.HasDE.PDEADV,Model.HasDE.PDERD,Model.HasDE.RK5,Model.HasDE.SDE,Features,Features.Payoffs,Features.Static,HasHistogram,HasHistogram.Degree,HasHistogram.Fitness,HasHistogram.StatisticsProbability,HasHistogram.StatisticsStationary,HasHistogram.StatisticsTime,HasMean,HasMean.Fitness,HasMean.Traits,HasPop2D,HasPop2D.Fitness,HasPop2D.Traits,HasPop3D,HasPop3D.Fitness,HasPop3D.Traits,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.Multispecies, Features.Pairs, Features.Payoffs, Features.StaticNested classes/interfaces inherited from interface HasHistogram
HasHistogram.Degree, HasHistogram.Fitness, HasHistogram.StatisticsProbability, HasHistogram.StatisticsStationary, HasHistogram.StatisticsTime, HasHistogram.StrategyNested classes/interfaces inherited from interface HasMean
HasMean.Fitness, HasMean.TraitsNested classes/interfaces inherited from interface HasPop2D
HasPop2D.Fitness, HasPop2D.TraitsNested classes/interfaces inherited from interface HasPop3D
HasPop3D.Fitness, HasPop3D.TraitsNested classes/interfaces inherited from interface IBS.HasIBS
IBS.HasIBS.CGroups, IBS.HasIBS.CPairs, IBS.HasIBS.DGroups, IBS.HasIBS.DPairs, IBS.HasIBS.MCGroups, IBS.HasIBS.MCPairsNested classes/interfaces inherited from interface Model.HasDE
Model.HasDE.DGroups, Model.HasDE.DPairs, Model.HasDE.DualDynamics, Model.HasDE.EM, Model.HasDE.ODE, Model.HasDE.PDE, Model.HasDE.PDEADV, Model.HasDE.PDERD, Model.HasDE.RK5, Model.HasDE.SDE -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CLOptionCommand line option to set the fitness values for residents and mutants.static final intThe trait (and index) value of mutants.static final intThe trait (and index) value of residents.(package private) doubleStore fixation probability ofiindividuals of typeA.(package private) doubleStore fixation time ofiindividuals of typeA.(package private) doubleStore absorption time ofiindividuals of typeA.protected double[]The array with the scores for each trait.Fields inherited from class Discrete
cloMonoStop, monoStop, mutation, speciesFields inherited from class Module
active, cloDeathRate, cloGeometry, cloNGroup, cloNPopulation, cloPhase2DAxes, cloTraitColors, cloTraitDisable, cloTraitNames, competition, deathRate, defaultColor, engine, ibs, ID, interaction, logger, map2fitness, markers, model, nActive, name, nGroup, nPopulation, nTraits, opponent, playerUpdate, structure, traitColor, traitName, trajectoryColor, VACANT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcollectCLO(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.intFor replicator dynamics the frequencies of all traits must sum up to one.double[]Get the array of fitness values for residents and mutants.doublegetFitness(int aType) Get the fitness value for traitaType.doubleCalculates and returns the maximum payoff/score of an individual.doubleCalculates and returns the minimum payoff/score of an individual.doublegetMonoPayoff(int type) Calculate and return the payoff/score of individuals in monomorphic populations with traittype.private double[]getReferenceProb(int trait) Helper method to retrieve the reference fixation probabilities for traittraitfor the initial number of mutants according toinit.private double[]getReferenceTime(int trait) Helper method to retrieve the reference fixation times for traittraitfor the initial number of mutants according toinit.double[]Gets the static scores for the different types.getTitle()Returns title of active module, e.g.voidload()Load new module and perform basic initializations.voidCalled when the settings of the EvoLudo model changed but no reset was necessary.protected doublerhoA(int i, int n) The fixation probability ofimutants in a population of constant sizeN(andN-iresidents).voidsetFitness(double[] aValue) Set the fitness values for residents and mutants.voidsetFitness(double aValue, int aType) Set the fitness value for traitaTypetoaValue.protected doublet1(double rhoA, int n) The absorbtion time (in generations) of a single mutant in a population of constant sizeN(andN-1residents).protected doubletA1(int n) The conditional fixation time of a single mutant in a population of fixed sizeN(andN-1residents) measured in generations.protected doubletAi(int i, int n, double rhoA, double tA1) The conditional fixation time ofimutants in a population of fixed sizeN(andN-iresidents) measured in generations.protected doubleti(int i, int n, double t1) The absorbtion time (in generations) ofimutants in a population of constant sizeN(andN-iresidents).private doubleTplus(int i, int n) Transition probability to go fromitoi+1mutants in a population of sizeN.private doubleTratio(int i) The ratio of transition probabilities to go fromitoi+1mutants over the reverse, i.e.voidunload()Unload module and free all resources.Methods inherited from class Discrete
add, getMaxMonoPayoff, getMinMonoPayoff, getMonoStop, getMutation, setMonoStopMethods inherited from class Module
check, createGeometry, createIBSPop, createModel, getActiveTraits, getCompetitionGeometry, getDeathRate, getGeometry, getIBSPopulation, getID, getInteractionGeometry, getKey, getMap2Fitness, getMarkers, getMeanColors, getModelTypes, getNActive, getName, getNGroup, getNPopulation, getNRoles, getNSpecies, getNTraits, getOpponent, getPlayerUpdate, getSpecies, getSpecies, getTraitColor, getTraitColors, getTraitName, getTraitNames, getTrajectoryColor, getVacant, init, processColorMap, reset, run, setActiveTraits, setDeathRate, setGeometries, setIBSPopulation, setModel, setName, setNGroup, setNPopulation, setNTraits, setOpponent, setTraitColors, setTraitNames, setTrajectoryColorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CLOProvider
adjustCLOMethods inherited from interface Features
isMultispecies, isPairwiseMethods inherited from interface Features.Payoffs
getMap2Fitness, getMaxMonoPayoff, getMinMonoPayoff, isNeutralMethods inherited from interface Features.Static
isStaticMethods inherited from interface HasHistogram
getNTraits, getTraitColorsMethods inherited from interface IBS.HasIBS
createIBSMethods inherited from interface MilestoneListener
modelDidInit, modelDidReset, modelLoaded, modelRelaxed, modelRunning, modelStopped, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloaded
-
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 ofiindividuals of typeA. -
tAi
double tAiStore fixation time ofiindividuals of typeA. -
taui
double tauiStore absorption time ofiindividuals 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:ModuleLoad new module and perform basic initializations. -
unload
public void unload()Description copied from class:ModuleUnload module and free all resources. -
getAuthors
Description copied from class:ModuleReturns a string with information about the authors of the module.- Overrides:
getAuthorsin classModule- Returns:
- the names of the authors
-
getTitle
Description copied from interface:FeaturesReturns title of active module, e.g. 2x2 games inTBTreturns "2x2 Games". -
getDependent
public int getDependent()Description copied from interface:Model.HasDEFor replicator dynamics the frequencies of all traits must sum up to one. Hence, fornTraitstraits there are onlynTraits-1degrees of freedom. The index returned bygetDependent()marks the one rate of change that is derived from all the others.Notes:
- Dependent traits are used by models where the frequencies of all types must sum up to one.
- Density modules do not have dependent traits and
getDependent()should return-1. - Currently differential equations implementations are only provided for Discrete modules.
- Specified by:
getDependentin interfaceModel.HasDE- Returns:
- the index of the dependent trait (or
-1if there is none)
-
getMinPayoff
public double getMinPayoff()Description copied from interface:Features.PayoffsCalculates 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:
getMinPayoffin interfaceFeatures.Payoffs- Returns:
- the minimum payoff/score
- See Also:
-
getMaxPayoff
public double getMaxPayoff()Description copied from interface:Features.PayoffsCalculates 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:
getMaxPayoffin interfaceFeatures.Payoffs- Returns:
- the maximum payoff/score
- See Also:
-
getMonoPayoff
public double getMonoPayoff(int type) Description copied from class:DiscreteCalculate and return the payoff/score of individuals in monomorphic populations with traittype.Note: Optional implementation. Returns
Double#NaNif not defined or not implemented.- Overrides:
getMonoPayoffin classDiscrete- Parameters:
type- the index of the trait- Returns:
- payoff/score in monomorphic population with trait
type
-
getStaticScores
public double[] getStaticScores()Description copied from interface:Features.StaticGets the static scores for the different types.- Specified by:
getStaticScoresin interfaceFeatures.Static- Returns:
- the array with the static scores
-
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 traitaTypetoaValue.- Parameters:
aValue- the fitness for traitaTypeaType- 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:HasHistogramSome 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 Moranmodule where the analytical results are provided as a reference to highlight the effects of population structures.- Specified by:
getCustomLevelsin 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:MilestoneListenerCalled when the settings of the EvoLudo model changed but no reset was necessary.- Specified by:
modelSettingsin interfaceMilestoneListener
-
getReferenceProb
private double[] getReferenceProb(int trait) Helper method to retrieve the reference fixation probabilities for traittraitfor the initial number of mutants according toinit. In order to optimize repeated calls the result is stored in the fieldstatRefProband 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 traittraitfor the initial number of mutants according toinit. In order to optimize repeated calls the result is stored in the fieldstatRefTimeand 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:CLOProviderAll 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, theparserissues 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:
collectCLOin interfaceCLOProvider- Overrides:
collectCLOin 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 fromitoi+1mutants 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 fromitoi+1mutants 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 ofimutants in a population of constant sizeN(andN-iresidents).- 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-1residents).- 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) ofimutants in a population of constant sizeN(andN-iresidents).- Parameters:
i- the number of mutantsn- the size of the populationt1- the absorbtion time of a single mutant- Returns:
- the absorbtion time of
imutants - See Also:
-
tA1
protected double tA1(int n) The conditional fixation time of a single mutant in a population of fixed sizeN(andN-1residents) 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 ofimutants in a population of fixed sizeN(andN-iresidents) 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
-