Class SDE
- All Implemented Interfaces:
Discrete,CLOProvider
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested classes/interfaces inherited from class ODE
ODE.InitTypeNested classes/interfaces inherited from class Model
Model.HasDE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ModuleConvenience variable: module associated with this model (useful as long as SDE models are restricted to single species).Fields inherited from class ODE
accuracy, cloAdjustedDynamics, cloDEAccuracy, cloDEdt, cloInit, cloTimeReversed, dependents, dstate, dt, dtTaken, dtTry, dyt, forward, ft, idxSpecies, initType, invFitRange, isAdjustedDynamics, isDensity, monoStop, mutation, names, nDim, staticfit, y0, yout, ytFields inherited from class Model
cloSamples, cloTimeRelax, cloTimeStep, cloTimeStop, connect, converged, engine, fixData, isMultispecies, isRelaxing, logger, mode, nSamples, nSpecies, nStatisticsFailed, nStatisticsSamples, rng, species, statisticsSampleNew, time, timeRelax, timeStep, timeStop, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheck()Check consistency of parameters and adjust if necessary (and possible).booleancheckConvergence(double dist2) Helper method to check whether the squared distancedist2qualifies to signal convergence.voidcollectCLO(CLOParser parser) All providers of command line options must implement this method to collect their options.protected doubledeStep(double step) Attempts a numerical integration step of sizestep.private doublegetEffectiveNoise(Module mod, int skip) Helper method to determine the effective demographic noise for a given module based on the current population size.voidload()Milestone: Load this model and allocate resources (if applicable).booleannext()Advance model by one step.booleanCheck if the current model settings permit sample statistics.booleanCheck if the current model settings permit update statistics.private voidprocess2DNoise(int skip, double step, double sqrtdt, double mu, double noise) Helper method to process noise with two dependent traits.voidSignal that statistics sample is ready to process.voidreset()Milestone: Reset this modelvoidReset statistics and get ready to start new collection.voidunload()Milestone: Unload this model and free resources (if applicable).Methods inherited from class ODE
encodeFitness, encodeState, encodeTraits, getAccuracy, getDerivatives, getDt, getFitnessData, getFitnessHistogramData, getInitialTraits, getInitialTraits, getMaxFitness, getMaxScore, getMeanFitness, getMeanFitness, getMeanTraits, getMeanTraits, getMinFitness, getMinScore, getMonoScore, getNMean, getNMean, getStatus, getStatus, getTraitData, init, isDensity, isMonomorphic, isTimeReversed, normalizeState, parse, permitsTimeReversal, restoreFitness, restoreState, restoreTraits, setAccuracy, setAdjustedDynamics, setDt, setInitialTraits, setInitialTraits, setTimeReversed, update, updateBest, updateBestResponse, updateEcology, updateImitate, updateImitateBetter, updateProportional, updateThermalMethods inherited from class Model
debugStep, getCounter, getFitnessNameAt, getFixationData, getLogger, getMeanFitnessAt, getMeanName, getMeanNames, getMeanTraitAt, getMode, getNextHalt, getNSamples, getNSpecies, getNStatisticsFailed, getNStatisticsSamples, getScoreNameAt, getSpecies, getTime, getTimeRelax, getTimeStep, getTimeStop, getTraitNameAt, getType, hasConverged, initStatisticsFailed, initStatisticsSample, isConnected, isContinuous, isRelaxing, permitsDebugStep, permitsMode, relax, requestMode, setMode, setNSamples, setTimeRelax, setTimeStep, setTimeStop, useSchedulingMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CLOProvider
adjustCLO
-
Field Details
-
module
Convenience variable: module associated with this model (useful as long as SDE models are restricted to single species).
-
-
Constructor Details
-
SDE
Constructs a new model for the numerical integration of the system of stochastic differential equations representing the dynamics specified by theModulemoduleusing theEvoLudopacemakerengineto control the numerical evaluations. The integrator implements Euler's method (fixed step size).Important: for reproducibility the shared random number generator should be used.
- Parameters:
engine- the pacemaker for running the model- See Also:
-
-
Method Details
-
load
public void load()Description copied from class:ModelMilestone: Load this model and allocate resources (if applicable). -
unload
public void unload()Description copied from class:ModelMilestone: Unload this model and free resources (if applicable). -
check
public boolean check()Description copied from class:ModelCheck consistency of parameters and adjust if necessary (and possible). All issues and modifications should be reported throughlogger. Some parameters can be adjusted while the model remains active or even while running, whereas others require a reset. An example of the former category is in general simple adjustments of payoffs, while an example of the latter category is a change of the population structure. -
reset
public void reset()Description copied from class:ModelMilestone: Reset this model -
next
public boolean next()Description copied from class:ODEAdvance model by one step. The details of what happens during one step depends on the modelsTypeas well as itsMode.Implementation Notes:
Before:ytcurrent stateftcurrent fitnessdytcurrent derivatives fitnessdtTrysize of time step attempting to make
ytnext stateftnext fitnessdytnext derivativesyoutcontains previous state (i.e.ytwhen entering method)stepTakenthe time betweenytandyout
- Overrides:
nextin classODE- Returns:
trueifnext()can be called again. Typicallyfalseis returned if the model requires attention, such as the following conditions:- the model has converged
- the model turned monomorphic (stops only if requested)
- a statistics sample is available
- a preset time has been reached
- See Also:
-
checkConvergence
public boolean checkConvergence(double dist2) Helper method to check whether the squared distancedist2qualifies to signal convergence.Implementation Notes:
- ODE's can converge even with non-zero mutation rates
- step size may keep decreasing without ever reaching the accuracy
threshold (or reach step). This scenario requires an emergency brake
(otherwise the browser becomes completely unresponsive - nasty!). Emergency
brake triggered if
stepTakenis so small that more than1/(accuracy * stepTaken)updates are required to completedt. stepTaken < 0may hold but irrelevant because only the squared value is used.
Note: SDE's only converge to absorbing states (including extinction), if there are any. Moreover, SDE's cannot converge with non-zero mutation rates (except extinction).
- Overrides:
checkConvergencein classODE- Parameters:
dist2- the squared distance between the current and previous states(y[t+dt]-y[t])2.- Returns:
trueif convergence criteria passed
-
deStep
protected double deStep(double step) Attempts a numerical integration step of sizestep. The baseline are steps of fixed size following Euler's method. For stochastic differential equations Gaussian distributed white noise is added.Implementation Notes:
Integration of SDEs can be optimized in 1 and 2 dimensions. For replicator systems this means 2 or 3 traits. Currently noise implemented only for replicator type dynamics. -
process2DNoise
private void process2DNoise(int skip, double step, double sqrtdt, double mu, double noise) Helper method to process noise with two dependent traits.- Parameters:
skip- the start index of the two traitsstep- the step sizesqrtdt- the square root of the step sizemu- the mutation ratenoise- the noise to be processed
-
getEffectiveNoise
Helper method to determine the effective demographic noise for a given module based on the current population size.- Parameters:
mod- the module to determine the effective noiseskip- the starting index for the entries inytfor this module- Returns:
- the effective noise for the given module
-
readStatisticsSample
public void readStatisticsSample()Description copied from class:ModelSignal that statistics sample is ready to process.- Overrides:
readStatisticsSamplein classModel
-
resetStatisticsSample
public void resetStatisticsSample()Description copied from class:ModelReset statistics and get ready to start new collection.- Overrides:
resetStatisticsSamplein classModel
-
permitsSampleStatistics
public boolean permitsSampleStatistics()Check if the current model settings permit sample statistics. Fixation probabilities and times are examples of statistics based on samples.- Overrides:
permitsSampleStatisticsin classModel- Returns:
trueif sample statistics are permitted- See Also:
-
permitsUpdateStatistics
public boolean permitsUpdateStatistics()Description copied from class:ModelCheck if the current model settings permit update statistics. Sojourn times are an example of statistics based on updates.- Overrides:
permitsUpdateStatisticsin classModel- Returns:
trueif update statistics are permitted
-
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 classODE- Parameters:
parser- the reference to parser that manages command line options- See Also:
-