Class SDE
- All Implemented Interfaces:
Discrete
,CLOProvider
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface for modules that implement stochastic differential equations (SDE).Nested classes/interfaces inherited from class ODE
ODE.HasDE, ODE.HasODE, ODE.InitType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Module
Convenience 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, monoStop, mutation, names, nDim, rates, staticfit, y0, yout, yt
Fields 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 TypeMethodDescriptionboolean
check()
Check consistency of parameters and adjust if necessary (and possible).boolean
checkConvergence
(double dist2) Helper method to check whether the squared distancedist2
qualifies to signal convergence.void
collectCLO
(CLOParser parser) All providers of command line options must implement this method to collect their options.protected double
deStep
(double step) Attempts a numerical integration step of sizestep
.void
load()
Milestone: Load this model and allocate resources (if applicable).boolean
next()
Advance model by one step.boolean
Check if the current model settings permit sample statistics.boolean
Check if the current model settings permit update statistics.void
Signal that statistics sample is ready to process.void
reset()
Milestone: Reset this modelvoid
Reset statistics and get ready to start new collection.void
unload()
Milestone: Unload this model and free resources (if applicable).Methods inherited from class ODE
encodeFitness, encodeState, encodeStrategies, getAccuracy, getDerivatives, getDt, getFitnessData, getFitnessHistogramData, getInitialTraits, getInitialTraits, getMaxFitness, getMaxScore, getMeanFitness, getMeanFitness, getMeanTraits, getMeanTraits, getMinFitness, getMinScore, getMonoScore, getNMean, getNMean, getStatus, getTraitData, init, isDensity, isMonomorphic, isTimeReversed, normalizeState, parse, permitsTimeReversal, restoreFitness, restoreState, restoreStrategies, setAccuracy, setAdjustedDynamics, setDt, setInitialTraits, setInitialTraits, setTimeReversed, update, updateBest, updateBestResponse, updateEcology, updateImitate, updateImitateBetter, updateProportional, updateThermal
Methods 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, isDE, isIBS, isODE, isPDE, isRelaxing, isSDE, isType, permitsDebugStep, permitsMode, relax, requestMode, setMode, setNSamples, setTimeRelax, setTimeStep, setTimeStop, useScheduling
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 theModule
module
using theEvoLudo
pacemakerengine
to 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:Model
Milestone: Load this model and allocate resources (if applicable). -
unload
public void unload()Description copied from class:Model
Milestone: Unload this model and free resources (if applicable). -
check
public boolean check()Description copied from class:Model
Check 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:Model
Milestone: Reset this model -
next
public boolean next()Description copied from class:ODE
Advance model by one step. The details of what happens during one step depends on the modelsType
as well as itsMode
.Implementation Notes:
Before:yt
current stateft
current fitnessdyt
current derivatives fitnessdtTry
size of time step attempting to make
yt
next stateft
next fitnessdyt
next derivativesyout
contains previous state (i.e.yt
when entering method)stepTaken
the time betweenyt
andyout
- Overrides:
next
in classODE
- Returns:
true
ifnext()
can be called again. Typicallyfalse
is 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 distancedist2
qualifies 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
stepTaken
is so small that more than1/(accuracy * stepTaken)
updates are required to completedt
. stepTaken < 0
may 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:
checkConvergence
in classODE
- Parameters:
dist2
- the squared distance between the current and previous states(y[t+dt]-y[t])2
.- Returns:
true
if 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 strategies. Currently noise implemented only for replicator type dynamics. -
readStatisticsSample
public void readStatisticsSample()Description copied from class:Model
Signal that statistics sample is ready to process.- Overrides:
readStatisticsSample
in classModel
-
resetStatisticsSample
public void resetStatisticsSample()Description copied from class:Model
Reset statistics and get ready to start new collection.- Overrides:
resetStatisticsSample
in 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:
permitsSampleStatistics
in classModel
- Returns:
true
if sample statistics are permitted- See Also:
-
permitsUpdateStatistics
public boolean permitsUpdateStatistics()Description copied from class:Model
Check if the current model settings permit update statistics. Sojourn times are an example of statistics based on updates.- Overrides:
permitsUpdateStatistics
in classModel
- Returns:
true
if update statistics are permitted
-
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 classODE
- Parameters:
parser
- the reference to parser that manages command line options- See Also:
-