Class PDE
- All Implemented Interfaces:
Discrete
,CLOProvider
- Direct Known Subclasses:
Advection
Important: Currently multi-species modules are not supported by PDE models.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Methods that everyModule
must implement, which advertises numerical solutions based on partial differential equations.static enum
Types of initial configurations.Nested classes/interfaces inherited from class ODE
ODE.HasDE, ODE.HasODE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double[]
Helper variable to store the effective diffusion terms.final CLOption
Command line option to set the diffusion coefficients.final CLOption
Command line option to set the linear extension.final CLOption
Command line option to set the discretization as the total number of spatial units to use for the numerical integration of the PDE.final CLOption
Command line option to request preservation of symmetry.protected double[][]
Density distribution of traits as a 2D array.protected int
The index of the dependent trait.protected double[]
The array of diffusion coefficients for each trait.protected int
Discretization of space as the total number of spatial units.protected double[][]
Fitness distribution of traits as a 2D array.(package private) double
The generation when the model execution is halted next.protected PDE.InitType
Type of initial configuration for each species.(package private) boolean
The flag indicating whether the dynamics is symmetric.protected double
The linear extension of the lattice.protected double[]
The array containing the maximum densities of each trait.protected double[]
The array containing the maximum fitness of each trait.protected double[]
The array containing the mean densities of each trait.protected double[]
The array containing the mean fitness of each trait.protected double[]
The array containing the minimum densities of each trait.protected double[]
The array containing the minimum fitness of each trait.protected Module
Convenience variable: module associated with this model (useful as long as PDE models are restricted to single species).protected double[][]
The next density/frequency distribution of traits as a 2D array.(package private) boolean
The flag indicating whether preservation of symmetry in the dynamics is requested.(package private) Comparator
<double[]> In order to preserve symmetry the densities of neighbouring cells in the diffusion step need to be sorted.protected Geometry
Geometry representing the spatial dimensions of this PDE.protected PDESupervisor
The supervisor for the integration of the reaction-diffusion process.Fields inherited from class ODE
accuracy, cloAdjustedDynamics, cloDEAccuracy, cloDEdt, cloInit, cloTimeReversed, dependents, dstate, dt, dtTaken, dtTry, dyt, forward, ft, idxSpecies, 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 TypeMethodDescription(package private) double
Helper method to calculate1 / dx
for different lattice geometries.boolean
check()
Check consistency of parameters and adjust if necessary (and possible).(package private) void
checkDt()
Helper method to check whether the time increment,ODE.dt
, is acceptable.void
collectCLO
(CLOParser parser) All providers of command line options must implement this method to collect their options.void
diffuse
(int start, int end) Diffusion step.void
encodeFitness
(StringBuilder plist) Encodes the fitness of the model in the form of aplist
string.(package private) void
encodeGeometry
(StringBuilder plist) Encodes the geometry of the spatial structure for this PDE in the form of aplist
string.void
encodeState
(StringBuilder plist) Encode the state of the model in aplist
inspiredXML
string.(package private) void
encodeStrategies
(StringBuilder plist) Encodes state of the model in the form of aplist
string.double[]
Gets the diffusion coefficients for all traits as an array.int
Gets the number of units used to discretize the spatial dimensions for numerical integration of the PDE.<T> void
getFitnessData
(int id, T[] colors, ColorMap.Gradient1D<T> colorMap) Translates fitness data into colors using ColorMapcolorMap
.void
getFitnessHistogramData
(int id, double[][] bins) Generates a histogram of fitness data and returns the result in the provided arraybins
.getFitnessNameAt
(int id, int idx) Gets the fitness at locationidx
for species with IDid
as a formatted string.Gets the geometry representing the spatial structure of this PDE.double
Gets the linear extension of the lattice.boolean
getMeanFitness
(int id, double[] mean) Gets the mean fitness values for species with IDid
.double[]
getMeanFitnessAt
(int id, int idx) Gets the mean fitness(es) of this model at locationidx
.double[]
getMeanTraitAt
(int id, int idx) Return mean trait values at locationidx
for species with IDid
.boolean
getMeanTraits
(double[] mean) Collect and return mean trait values for all species.boolean
getMeanTraits
(int id, double[] mean) Return mean trait values for species with IDid
.Returns status message from model.boolean
Gets whether preservation of symmetry was requested.<T> void
getTraitData
(int ID, T[] colors, ColorMap<T> colorMap) Unused interface method.getTraitNameAt
(int id, int idx) Gets the formatted trait names at locationidx
for species with IDid
.boolean
incrementTime
(double incr) Increments time byincr
.void
init()
Milestone: Initialize this modelvoid
initDiffusion
(double deltat) Helper method to initialize the effective rate of diffusion for the time incrementdt
.boolean
Check if population is monomorphic.boolean
Gets whether the model preserves symmetry.void
load()
Milestone: Load this model and allocate resources (if applicable).(package private) static void
minmaxmean
(double[] data, double[] min, double[] max, double[] mean) Utility method to update the trait minimum, maximum and mean based on the provided data array.boolean
next()
Advance model by one step.void
Normalizes the mean density after the diffusion step is complete.void
Normalizes the mean fitnesses after the reaction step is complete.boolean
Parse initializer stringarg
.boolean
Checks if time reversal is permitted.double
react
(int start, int end) Reaction step.void
reset()
Milestone: Reset this modelvoid
Resets minimum, maximum and mean density prior to diffusion step.void
Resets minimum, maximum and mean fitnesses prior to reaction step.boolean
restoreFitness
(Plist plist) Restores the fitness encoded inplist
.(package private) boolean
restoreGeometry
(Plist plist) Restores the geometry of the spatial structure encoded inplist
.boolean
restoreState
(Plist plist) Restore the state encoded in theplist
inspiredmap
ofkey, value
-pairs.boolean
restoreStrategies
(Plist plist) Restores the state encoded inplist
.private void
scaleDensity
(double[] d, double scale) Helper method to scale the density vectord
by the scalar factorscale
.void
Indicates that the numerical integration has converged to a homogeneous state.void
Initializes minimum, maximum and mean density based on current state.void
setDiffusion
(double[] dc) Sets the diffusion coefficients for each trait.void
setDiscretization
(int d) Sets the number of units used to discretize the spatial dimensions for numerical integration of the PDE.void
setLinearExtension
(double l) Sets the linear extension of the lattice.void
setSymmetric
(boolean symmetric) Sets whether symmetries should be preserved.void
unload()
Milestone: Unload this model and free resources (if applicable).void
update()
Update this model.void
updateDensity
(double[] min, double[] max, double[] mean) Update minimum, maximum and mean density during to reaction step.void
updateFitness
(double[] min, double[] max, double[] mean) Update minimum, maximum and mean fitnesses during to reaction step.boolean
GWT models run asynchronously and long running tasks require scheduling to maintain responsive user interface.Methods inherited from class ODE
checkConvergence, deStep, getAccuracy, getDerivatives, getDt, getInitialTraits, getInitialTraits, getMaxFitness, getMaxScore, getMeanFitness, getMinFitness, getMinScore, getMonoScore, getNMean, getNMean, isDensity, isTimeReversed, normalizeState, setAccuracy, setAdjustedDynamics, setDt, setInitialTraits, setInitialTraits, setTimeReversed, updateBest, updateBestResponse, updateEcology, updateImitate, updateImitateBetter, updateProportional, updateThermal
Methods inherited from class Model
debugStep, getCounter, getFixationData, getLogger, getMeanName, getMeanNames, getMode, getNextHalt, getNSamples, getNSpecies, getNStatisticsFailed, getNStatisticsSamples, getScoreNameAt, getSpecies, getTime, getTimeRelax, getTimeStep, getTimeStop, getType, hasConverged, initStatisticsFailed, initStatisticsSample, isConnected, isContinuous, isDE, isIBS, isODE, isPDE, isRelaxing, isSDE, isType, permitsDebugStep, permitsMode, permitsSampleStatistics, permitsUpdateStatistics, readStatisticsSample, relax, requestMode, resetStatisticsSample, setMode, setNSamples, setTimeRelax, setTimeStep, setTimeStop
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 PDE models are restricted to single species). -
supervisor
The supervisor for the integration of the reaction-diffusion process. This abstraction is required due to incompatibilities between JRE and GWT implementations. In particular, JRE allows for parallel execution of certain steps, while GWT uses a scheduling mechanism.- See Also:
-
space
Geometry representing the spatial dimensions of this PDE. -
density
protected double[][] densityDensity distribution of traits as a 2D array. The first entry refers to the index of the node (e.g. location on lattice) and the second entry refers to the different traits at that location.space
defines the geometric arrangement of the nodes.Note: this variable is
protected
to allow direct access fromPDESupervisor
for efficiency reasons. -
next
protected double[][] nextThe next density/frequency distribution of traits as a 2D array. The first entry refers to the index of the node (e.g. location on lattice) and the second entry refers to the different traits at that location.space
defines the geometric arrangement of the nodes.Note: this variable is
protected
to allow direct access fromPDESupervisor
for efficiency reasons. -
fitness
protected double[][] fitnessFitness distribution of traits as a 2D array. The first entry refers to the index of the node (e.g. location on lattice) and the second entry refers to the different traits at that location.space
defines the geometric arrangement of the nodes.Note: this variable is
protected
to allow direct access fromPDESupervisor
for efficiency reasons. -
initType
Type of initial configuration for each species.Note: this variable is deliberately hiding a field from
ODE
because PDE models have their own initialization types. Make sureinitType
is not accessed through calls tosuper
. Since PDE's currently support only single species modelsinitType
is a scalar field.- See Also:
-
discretization
protected int discretizationDiscretization of space as the total number of spatial units. For example, for a square lattice the dimensions aresqrt(discretization)×sqrt(discretization)
.- See Also:
-
linext
protected double linextThe linear extension of the lattice.- See Also:
-
diffcoeff
protected double[] diffcoeffThe array of diffusion coefficients for each trait.- See Also:
-
requestSymmetric
boolean requestSymmetricThe flag indicating whether preservation of symmetry in the dynamics is requested. The model may not be able to honour the request because it requires that the spatial structure permits preservation of symmetry, i.e. the underlying spatial geometry represents a lattice.- See Also:
-
isSymmetric
boolean isSymmetricThe flag indicating whether the dynamics is symmetric. This requires that symmetry preservation was requested, i.e.requestSymmetric==true
and that the spatial structure permits preservation of symmetry, i.e. the underlying spatial geometry represents a lattice.- See Also:
-
minDensity
protected double[] minDensityThe array containing the minimum densities of each trait. Used to set the color range when retrieving the density data.- See Also:
-
maxDensity
protected double[] maxDensityThe array containing the maximum densities of each trait. Used to set the color range when retrieving the density data.- See Also:
-
meanDensity
protected double[] meanDensityThe array containing the mean densities of each trait.- See Also:
-
minFitness
protected double[] minFitnessThe array containing the minimum fitness of each trait. Used to set the color range when retrieving the density data.- See Also:
-
maxFitness
protected double[] maxFitnessThe array containing the maximum fitness of each trait. Used to set the color range when retrieving the density data.- See Also:
-
meanFitness
protected double[] meanFitnessThe array containing the mean fitness of each trait.- See Also:
-
dependent
protected int dependentThe index of the dependent trait. Dependent traits make only sense in replicator type model with frequencies, i.e. normalized states. The dependent trait is the one that gets derived from the changes in all others in order to maintain normalization.Note: This is a simple helper variable and shortcut for
dependents[0]
, which makes sense as long as this model cannot deal with multi-species modules.- See Also:
-
alpha
protected double[] alphaHelper variable to store the effective diffusion terms. This depends not only on the diffusion coefficientsdiffcoeff
but also on the time incrementdt
and the linear extension,linext
.- See Also:
-
sorting
Comparator<double[]> sortingIn order to preserve symmetry the densities of neighbouring cells in the diffusion step need to be sorted. The sorting criteria are essentially irrelevant as long as they are consistently applied. -
gwtHalt
double gwtHaltThe generation when the model execution is halted next. This is needed to keep track of halting for asynchronous execution in GWT. -
cloPdeN
Command line option to set the discretization as the total number of spatial units to use for the numerical integration of the PDE.- See Also:
-
cloPdeL
Command line option to set the linear extension. This is only meaningful lattice type geometries.- See Also:
-
cloPdeDiffusion
Command line option to set the diffusion coefficients.- See Also:
-
cloPdeSymmetric
Command line option to request preservation of symmetry. If request cannot be honoured a warning is issued.- See Also:
-
-
Constructor Details
-
PDE
Constructs a new model for the numerical integration of the system of partial differential equations representing the dynamics specified by theModule
module
using theEvoLudo
pacemakerengine
to control the numerical evaluations. The integrator implements reaction-diffusion steps based on Euler's method (fixed step size).Important: for reproducibility the shared random number generator should be used (in PDE's only used to generate random initial configurations).
Note: requires a supervisor that matches the implementation, i.e. JRE or GWT, respectively, to properly deal with multiple threads or scheduling.
- Parameters:
engine
- the pacemaker for running the model- See Also:
-
-
Method Details
-
getGeometry
Gets the geometry representing the spatial structure of this PDE.- Returns:
- the geometry of the PDE
-
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 -
update
public void update()Update this model. For example called after initialization and when parameters changed.For PDEs simply delegate to supervisor for dealing with multiple threads (JRE) or scheduling (GWT).
-
useScheduling
public boolean useScheduling()Description copied from class:Model
GWT models run asynchronously and long running tasks require scheduling to maintain responsive user interface. In contrast, JRE provides a multi-threaded environment, which allows to run multiple threads synchronously. This parallel execution results in an significant speed-boost (for PDE calculations).- Overrides:
useScheduling
in classModel
- Returns:
true
if model calculations are asynchronous
-
next
public boolean next()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
For PDEs simply delegate to supervisor for dealing with multiple threads (JRE) or scheduling (GWT).
- 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:
-
react
public double react(int start, int end) Reaction step. Update cells with indices betweenstart
(including) andend
(excluding) and return the accumulated/total change in state.Note: At the end, the state in
density
is unchanged, the new density distribution is innext
and the fitness matchingdensity
is updated.Important: must be thread safe for JRE. In particular, no memory can be shared with anyone else!
- Parameters:
start
- the index of the first cell (including)end
- the index of the last cell (excluding)- Returns:
- the accumulated change in state
-
updateFitness
public void updateFitness(double[] min, double[] max, double[] mean) Update minimum, maximum and mean fitnesses during to reaction step. In multi threaded settings each worker reports the minimamin
, maximamax
, and the totalmean
fitness (for the calculation of the mean) of the PDE units it is responsible for.- Parameters:
min
- the array with fitness minimamax
- the array with fitness maximamean
- the array with fitness means
-
normalizeMeanFitness
public void normalizeMeanFitness()Normalizes the mean fitnesses after the reaction step is complete. -
resetFitness
public void resetFitness()Resets minimum, maximum and mean fitnesses prior to reaction step. -
diffuse
public void diffuse(int start, int end) Diffusion step. Update cells with indices betweenstart
(including) andend
(excluding). In order to preserve symmetry, if requested and possible, the neighbouring cells are sorted according to their density before the diffusion step is performed. The sorting is fairly expensive in terms of CPU time but it doesn't matter whether the sorting is ascending or descending.Note: At the end, the state in
next
is unchanged, the new density distribution is indensity
and the fitness is untouched/unused.Important: must be thread safe for JRE. In particular, no memory can be shared with anyone else!
- Parameters:
start
- the index of the first cell (including)end
- the index of the last cell (excluding)
-
resetDensity
public void resetDensity()Resets minimum, maximum and mean density prior to diffusion step. -
setDensity
public void setDensity()Initializes minimum, maximum and mean density based on current state. -
updateDensity
public void updateDensity(double[] min, double[] max, double[] mean) Update minimum, maximum and mean density during to reaction step. In multi threaded settings each worker reports the minimamin
, maximamax
, and the totalmean
density (for the calculation of the mean) of the PDE units it is responsible for.- Parameters:
min
- the array with density minimamax
- the array with density maximamean
- the array with density means
-
normalizeMeanDensity
public void normalizeMeanDensity()Normalizes the mean density after the diffusion step is complete. -
getMeanTraits
public boolean getMeanTraits(double[] mean) Description copied from class:Model
Collect and return mean trait values for all species.NOTE: this is a convenience method for multi-species modules to retrieve states efficiently for further processing or visualization.
- Overrides:
getMeanTraits
in classODE
- Parameters:
mean
- the array for storing the mean trait values- Returns:
true
if this and previous data point should be connected, i.e. no reset had been requested in the mean time.
-
getMeanTraits
public boolean getMeanTraits(int id, double[] mean) Description copied from class:Model
Return mean trait values for species with IDid
.- Overrides:
getMeanTraits
in classODE
- Parameters:
id
- the species identifiermean
- the array for storing the mean trait values- Returns:
true
if this and the previous data point should be connected, i.e. no reset had been requested in the mean time.
-
getMeanTraitAt
public double[] getMeanTraitAt(int id, int idx) Description copied from class:Model
Return mean trait values at locationidx
for species with IDid
.Note: optional implementation; currently makes sense only for local dynamics in PDE models.
IMPORTANT: the returned array is live and should not be altered.
- Overrides:
getMeanTraitAt
in classModel
- Parameters:
id
- the species identifieridx
- the index of the location- Returns:
- array of mean trait values
-
getTraitNameAt
Description copied from class:Model
Gets the formatted trait names at locationidx
for species with IDid
. The formatting may include HTML tags. Used by GUI for example to show trait names in tooltips.Note: optional implementation. Currently makes sense only for IBS models and local dynamics in PDE models.
- Overrides:
getTraitNameAt
in classModel
- Parameters:
id
- the species identifieridx
- the index of the location- Returns:
- description of traits at
idx
-
getTraitData
Description copied from class:ODE
Unused interface method.- Overrides:
getTraitData
in classODE
- Type Parameters:
T
- color data type.Color
forPopGraph2D
andPopGraph2D
as well asMeshLambertMaterial
forPopGraph3D
- Parameters:
ID
- the species identifiercolors
- the array for storing the colors for individualscolorMap
- the map for translating individual traits into colors
-
getMeanFitness
public boolean getMeanFitness(int id, double[] mean) Description copied from class:Model
Gets the mean fitness values for species with IDid
. The result is stored and returned inmean
. Used by GUI to visualize local dynamics atidx
.- Overrides:
getMeanFitness
in classODE
- Parameters:
id
- the species identifiermean
- the array for storing the mean fitness values- Returns:
true
if this and the previous data point should be connected, i.e. no reset had been requested in the mean time.
-
getMeanFitnessAt
public double[] getMeanFitnessAt(int id, int idx) Description copied from class:Model
Gets the mean fitness(es) of this model at locationidx
. Used by GUI to visualize local dynamics atidx
.Note: optional implementation. Currently makes sense only for local dynamics in PDE models.
IMPORTANT: the returned array is live and should not be altered.
- Overrides:
getMeanFitnessAt
in classModel
- Parameters:
id
- the species identifieridx
- the location of the fitness values- Returns:
- the array of mean fitness values
-
getFitnessNameAt
Description copied from class:Model
Gets the fitness at locationidx
for species with IDid
as a formatted string. The formatting may include HTML tags. Used by GUI for example to show fitness in tooltips.Note: optional implementation. Currently makes sense only for IBS and PDE models.
- Overrides:
getFitnessNameAt
in classModel
- Parameters:
id
- the species identifieridx
- the index of the location- Returns:
- the fitness as a formatted string
-
getFitnessData
Description copied from class:Model
Translates fitness data into colors using ColorMapcolorMap
. Used by GUI to visualize current state of model.- Overrides:
getFitnessData
in classODE
- Type Parameters:
T
- color data type.Color
forPopGraph2D
andPopGraph2D
as well asMeshLambertMaterial
forPopGraph3D
- Parameters:
id
- the species identifiercolors
- the array for storing color valuescolorMap
- the map to use for translating traits to colors
-
getFitnessHistogramData
public void getFitnessHistogramData(int id, double[][] bins) Description copied from class:Model
Generates a histogram of fitness data and returns the result in the provided arraybins
. For Discrete modules a fitness histogram is returned for each trait separately. For Continuous modules there is, in general, only a single fitness dimension.- Overrides:
getFitnessHistogramData
in classODE
- Parameters:
id
- the species identifierbins
- the array for storing histogram. For Discrete modules this is always one dimensional
-
getStatus
Description copied from class:Model
Returns status message from model. Typically this is a string summarizing the current state of the simulation. For example, models with discrete strategy sets (such as 2x2 games, seeTBT
) return the average frequencies of each strategy type in the population(s), seeIBSDPopulation
. Similarly, models with continuous strategies (such as continuous snowdrift games, seeCSD
) return the mean, minimum and maximum trait value(s) in the population(s), seeIBSMCPopulation
. The status message is displayed along the bottom of the GUI.Note: if the model runs into difficulties, problems should be reported through the logging mechanism. Messages with severity
Level.WARNING
or higher are displayed in the status of the GUI and override status messages returned here. -
isMonomorphic
public boolean isMonomorphic()Description copied from class:ODE
Check if population is monomorphic. Note, in multi-species modules all species need to be monomorphic.- Overrides:
isMonomorphic
in classODE
- Returns:
true
if criteria for monomorphic state passed
-
setDiscretization
public void setDiscretization(int d) Sets the number of units used to discretize the spatial dimensions for numerical integration of the PDE.- Parameters:
d
- the number of units- See Also:
-
getDiscretization
public int getDiscretization()Gets the number of units used to discretize the spatial dimensions for numerical integration of the PDE.- Returns:
- the number of units to discretize spatial
-
setLinearExtension
public void setLinearExtension(double l) Sets the linear extension of the lattice.Note: For geometries other than 1D, 2D or 3D lattices the meaning of this parameter is unclear/undefined.
- Parameters:
l
- the linear extension of the lattice- See Also:
-
getLinearExtension
public double getLinearExtension()Gets the linear extension of the lattice.Note: For geometries other than 1D, 2D or 3D lattices the meaning of this parameter is unclear/undefined.
- Returns:
- the linear extension
-
setDiffusion
public void setDiffusion(double[] dc) Sets the diffusion coefficients for each trait.- Parameters:
dc
- the array of diffusion coefficients- See Also:
-
getDiffusion
public double[] getDiffusion()Gets the diffusion coefficients for all traits as an array.- Returns:
- the array of diffusion coefficients
-
setSymmetric
public void setSymmetric(boolean symmetric) Sets whether symmetries should be preserved. Not all models may be able to honour the request. For examplePDE
is only able to preserve symmetries in the diffusion step if theGeometry.isLattice()
returnstrue
.- Parameters:
symmetric
- the request to preserve symmetry
-
getSymmetric
public boolean getSymmetric()Gets whether preservation of symmetry was requested. Not all models may be able to honour the request.- Returns:
true
if symmetry preservation was requested- See Also:
-
isSymmetric
public boolean isSymmetric()Gets whether the model preserves symmetry. Requires that symmetry preservation is requested and the model is able to honour the request.- Returns:
true
if symmetry is preserved
-
incrementTime
public boolean incrementTime(double incr) Increments time byincr
. This is used by thePDESupervisor
to report back on the progress.- Parameters:
incr
- the time that has elapsed- Returns:
true
to continue andfalse
to request a stop
-
setConverged
public void setConverged()Indicates that the numerical integration has converged to a homogeneous state. This is used by thePDESupervisor
to report back on the progress. -
permitsTimeReversal
public boolean permitsTimeReversal()Checks if time reversal is permitted. By default returnsfalse
. Only few models are capable of time reversal.ODE and SDE models return
true
by default.Due to diffusion PDE models do not permit time reversal.
- Overrides:
permitsTimeReversal
in classODE
- Returns:
true
if time reversal permissible.- See Also:
-
init
public void init()Description copied from class:Model
Milestone: Initialize this model -
scaleDensity
private void scaleDensity(double[] d, double scale) Helper method to scale the density vectord
by the scalar factorscale
. The scalar must lie in \((0, 1)\) such that the initial densities/frequencies represent the maximum.- Parameters:
d
- the density vector to scalescale
- the scaling factor
-
parse
Parse initializer stringarg
. Determine type of initialization and process its arguments as appropriate.Note: Not possible to perform parsing in
CLODelegate
ofODE.cloInit
because PDE model provide their ownPDE.InitType
s. -
initDiffusion
public void initDiffusion(double deltat) Helper method to initialize the effective rate of diffusion for the time incrementdt
.Note: This method needs to be public to permit access by
PDESupervisorGWT
andPDESupervisorJRE
- Parameters:
deltat
- the time increment for diffusion
-
checkDt
void checkDt()Helper method to check whether the time increment,ODE.dt
, is acceptable. If it is too large the diffusion step runs into numerical issues. Ifdt
needs to be decreased a warning is emitted. -
calcInvDeltaX
double calcInvDeltaX()Helper method to calculate1 / dx
for different lattice geometries.- Returns:
- the
1 / dx
for the current geometry.
-
minmaxmean
static void minmaxmean(double[] data, double[] min, double[] max, double[] mean) Utility method to update the trait minimum, maximum and mean based on the provided data array.- Parameters:
data
- the data to processmin
- the array with the minima of each traitmax
- the array with the maxima of each traitmean
- the array with the trait means
-
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:
-
encodeState
Description copied from class:Model
Encode the state of the model in aplist
inspiredXML
string. This allows to save the state and restore later with the exact same results as when continuing to run the model. This even allows to switch from JRE to GWT or back and obtain identical results!- Overrides:
encodeState
in classODE
- Parameters:
plist
- theStringBuilder
to write the encoded state to- See Also:
-
restoreState
Description copied from class:Model
Restore the state encoded in theplist
inspiredmap
ofkey, value
-pairs.- Overrides:
restoreState
in classODE
- Parameters:
plist
- the map ofkey, value
-pairs- Returns:
true
if successful- See Also:
-
encodeGeometry
Encodes the geometry of the spatial structure for this PDE in the form of aplist
string.- Parameters:
plist
- the string builder for the encoded state
-
restoreGeometry
Restores the geometry of the spatial structure encoded inplist
.- Parameters:
plist
- the encoded state- Returns:
true
if successful
-
encodeStrategies
Description copied from class:ODE
Encodes state of the model in the form of aplist
string.- Overrides:
encodeStrategies
in classODE
- Parameters:
plist
- the string builder for the encoded state
-
restoreStrategies
Description copied from class:ODE
Restores the state encoded inplist
.- Overrides:
restoreStrategies
in classODE
- Parameters:
plist
- the encoded state- Returns:
true
if successful
-
encodeFitness
Description copied from class:ODE
Encodes the fitness of the model in the form of aplist
string.- Overrides:
encodeFitness
in classODE
- Parameters:
plist
- the string builder for the encoded state
-
restoreFitness
Description copied from class:ODE
Restores the fitness encoded inplist
.- Overrides:
restoreFitness
in classODE
- Parameters:
plist
- the encoded state- Returns:
true
if successful
-