Class PDE
- All Implemented Interfaces:
Discrete,CLOProvider
Important: Currently multi-species modules are not supported by PDE models.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class Model
Model.HasDE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double[]Helper variable to store the effective diffusion terms.final CLOptionCommand line option to set the diffusion coefficients.final CLOptionCommand line option to set the linear extension.final CLOptionCommand line option to set the discretization as the total number of spatial units to use for the numerical integration of the PDE.final CLOptionCommand line option to request preservation of symmetry.protected double[][]Density distribution of traits as a 2D array.protected intThe index of the dependent trait.protected double[]The array of diffusion coefficients for each (independent) trait.protected intDiscretization of space as the total number of spatial units.protected double[][]Fitness distribution of traits as a 2D array.(package private) doubleThe generation when the model execution is halted next.protected PDE.InitTypeType of initial configuration for each species.(package private) booleanThe flag indicating whether the dynamics is symmetric.protected doubleThe 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 ModuleConvenience 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) booleanThe 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 GeometryGeometry representing the spatial dimensions of this PDE.protected PDESupervisorThe 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, 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 TypeMethodDescription(package private) doubleHelper method to calculate1 / dxfor different lattice geometries.booleancheck()Check consistency of parameters and adjust if necessary (and possible).(package private) voidcheckDt()Helper method to check whether the time increment,ODE.dt, is acceptable.voidcollectCLO(CLOParser parser) All providers of command line options must implement this method to collect their options.voiddiffuse(int start, int end) Diffusion step.voidencodeFitness(StringBuilder plist) Encodes the fitness of the model in the form of apliststring.(package private) voidencodeGeometry(StringBuilder plist) Encodes the geometry of the spatial structure for this PDE in the form of apliststring.voidencodeState(StringBuilder plist) Encode the state of the model in aplistinspiredXMLstring.(package private) voidencodeTraits(StringBuilder plist) Encodes state of the model in the form of apliststring.double[]Gets the diffusion coefficients for all traits as an array.intGets the number of units used to discretize the spatial dimensions for numerical integration of the PDE.<T> voidgetFitnessData(int id, T[] colors, ColorMap.Gradient1D<T> colorMap) Translates fitness data into colors using ColorMapcolorMap.voidgetFitnessHistogramData(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 locationidxfor species with IDidas a formatted string.Gets the geometry representing the spatial structure of this PDE.doubleGets the linear extension of the lattice.booleangetMeanFitness(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 locationidxfor species with IDid.booleangetMeanTraits(double[] mean) Collect and return mean trait values for all species.booleangetMeanTraits(int id, double[] mean) Return mean trait values for species with IDid.Returns status message from model.booleanGets whether preservation of symmetry was requested.<T> voidgetTraitData(int id, T[] colors, ColorMap<T> colorMap) Unused interface method.getTraitNameAt(int id, int idx) Gets the formatted trait names at locationidxfor species with IDid.booleanincrementTime(double incr) Increments time byincr.voidinit()Milestone: Initialize this modelvoidinitDiffusion(double deltat) Helper method to initialize the effective rate of diffusion for the time incrementdt.booleanCheck if population is monomorphic.booleanGets whether the model preserves symmetry.voidload()Milestone: Load this model and allocate resources (if applicable).(package private) static voidminmaxmean(double[] data, double[] min, double[] max, double[] mean) Utility method to update the trait minimum, maximum and mean based on the provided data array.booleannext()Advance model by one step.voidNormalizes the mean density after the diffusion step is complete.voidNormalizes the mean fitnesses after the reaction step is complete.booleanParse initializer stringarg.booleanChecks if time reversal is permitted.doublereact(int start, int end) Reaction step.voidreset()Milestone: Reset this modelvoidResets minimum, maximum and mean density prior to diffusion step.voidResets minimum, maximum and mean fitnesses prior to reaction step.booleanrestoreFitness(Plist plist) Restores the fitness encoded inplist.(package private) booleanrestoreGeometry(Plist plist) Restores the geometry of the spatial structure encoded inplist.booleanrestoreState(Plist plist) Restore the state encoded in theplistinspiredmapofkey, value-pairs.booleanrestoreTraits(Plist plist) Restores the state encoded inplist.private voidscaleDensity(double[] d, double scale) Helper method to scale the density vectordby the scalar factorscale.voidIndicates that the numerical integration has converged to a homogeneous state.voidInitializes minimum, maximum and mean density based on current state.voidsetDiscretization(int d) Sets the number of units used to discretize the spatial dimensions for numerical integration of the PDE.voidsetLinearExtension(double l) Sets the linear extension of the lattice.voidsetSymmetric(boolean symmetric) Sets whether symmetries should be preserved.voidunload()Milestone: Unload this model and free resources (if applicable).voidupdate()Update this model.voidupdateDensity(double[] min, double[] max, double[] mean) Update minimum, maximum and mean density during to reaction step.voidupdateFitness(double[] min, double[] max, double[] mean) Update minimum, maximum and mean fitnesses during to reaction step.booleanGWT 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, getStatus, isDensity, isTimeReversed, normalizeState, setAccuracy, setAdjustedDynamics, setDt, setInitialTraits, setInitialTraits, setTimeReversed, updateBest, updateBestResponse, updateEcology, updateImitate, updateImitateBetter, updateProportional, updateThermalMethods 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, isRelaxing, permitsDebugStep, permitsMode, permitsSampleStatistics, permitsUpdateStatistics, readStatisticsSample, relax, requestMode, resetStatisticsSample, setMode, setNSamples, setTimeRelax, setTimeStep, setTimeStopMethods 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 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.spacedefines the geometric arrangement of the nodes.Note: this variable is
protectedto allow direct access fromPDESupervisorfor 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.spacedefines the geometric arrangement of the nodes.Note: this variable is
protectedto allow direct access fromPDESupervisorfor 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.spacedefines the geometric arrangement of the nodes.Note: this variable is
protectedto allow direct access fromPDESupervisorfor efficiency reasons. -
initType
Type of initial configuration for each species.Note: this variable is deliberately hiding a field from
ODEbecause PDE models have their own initialization types. Make sureinitTypeis not accessed through calls tosuper. Since PDE's currently support only single species modelsinitTypeis 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 (independent) 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==trueand 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 coefficientsdiffcoeffbut also on the time incrementdtand 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. -
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 theModulemoduleusing theEvoLudopacemakerengineto 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: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 -
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:ModelGWT 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:
useSchedulingin classModel- Returns:
trueif model calculations are asynchronous
-
next
public boolean next()Advance 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
For PDEs simply delegate to supervisor for dealing with multiple threads (JRE) or scheduling (GWT).
- 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:
-
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
densityis unchanged, the new density distribution is innextand the fitness matchingdensityis 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 totalmeanfitness (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
nextis unchanged, the new density distribution is indensityand 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 totalmeandensity (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:ModelCollect 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:
getMeanTraitsin classODE- Parameters:
mean- the array for storing the mean trait values- Returns:
trueif 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:ModelReturn mean trait values for species with IDid.- Overrides:
getMeanTraitsin classODE- Parameters:
id- the species identifiermean- the array for storing the mean trait values- Returns:
trueif 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:ModelReturn mean trait values at locationidxfor 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:
getMeanTraitAtin classModel- Parameters:
id- the species identifieridx- the index of the location- Returns:
- array of mean trait values
-
getTraitNameAt
Description copied from class:ModelGets the formatted trait names at locationidxfor 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:
getTraitNameAtin classModel- Parameters:
id- the species identifieridx- the index of the location- Returns:
- description of traits at
idx
-
getTraitData
Description copied from class:ODEUnused interface method.- Overrides:
getTraitDatain classODE- Type Parameters:
T- color data type.ColorforPopGraph2DandPopGraph2Das well asMeshLambertMaterialforPopGraph3D- 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:ModelGets the mean fitness values for species with IDid. The result is stored and returned inmean. Used by GUI to visualize local dynamics atidx.- Overrides:
getMeanFitnessin classODE- Parameters:
id- the species identifiermean- the array for storing the mean fitness values- Returns:
trueif 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:ModelGets 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:
getMeanFitnessAtin classModel- Parameters:
id- the species identifieridx- the location of the fitness values- Returns:
- the array of mean fitness values
-
getFitnessNameAt
Description copied from class:ModelGets the fitness at locationidxfor species with IDidas 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:
getFitnessNameAtin classModel- Parameters:
id- the species identifieridx- the index of the location- Returns:
- the fitness as a formatted string
-
getFitnessData
Description copied from class:ModelTranslates fitness data into colors using ColorMapcolorMap. Used by GUI to visualize current state of model.- Overrides:
getFitnessDatain classODE- Type Parameters:
T- color data type.ColorforPopGraph2DandPopGraph2Das well asMeshLambertMaterialforPopGraph3D- 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:ModelGenerates 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:
getFitnessHistogramDatain classODE- Parameters:
id- the species identifierbins- the array for storing histogram. For Discrete modules this is always one dimensional
-
getStatus
Description copied from class:ModelReturns status message from model. Typically this is a string summarizing the current state of the simulation. For example, models with discrete traits (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.WARNINGor higher are displayed in the status of the GUI and override status messages returned here. -
isMonomorphic
public boolean isMonomorphic()Description copied from class:ODECheck if population is monomorphic. Note, in multi-species modules all species need to be monomorphic.- Overrides:
isMonomorphicin classODE- Returns:
trueif 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
-
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 examplePDEis 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:
trueif 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:
trueif symmetry is preserved
-
incrementTime
public boolean incrementTime(double incr) Increments time byincr. This is used by thePDESupervisorto report back on the progress.- Parameters:
incr- the time that has elapsed- Returns:
trueto continue andfalseto request a stop
-
setConverged
public void setConverged()Indicates that the numerical integration has converged to a homogeneous state. This is used by thePDESupervisorto 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
trueby default.Due to diffusion PDE models do not permit time reversal.
- Overrides:
permitsTimeReversalin classODE- Returns:
trueif time reversal permissible.- See Also:
-
init
public void init()Description copied from class:ModelMilestone: Initialize this model -
scaleDensity
private void scaleDensity(double[] d, double scale) Helper method to scale the density vectordby 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
CLODelegateofODE.cloInitbecause PDE model provide their ownPDE.InitTypes. -
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
PDESupervisorGWTandPDESupervisorJRE- 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. Ifdtneeds to be decreased a warning is emitted. -
calcInvDeltaX
double calcInvDeltaX()Helper method to calculate1 / dxfor different lattice geometries.- Returns:
- the
1 / dxfor 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: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:
-
encodeState
Description copied from class:ModelEncode the state of the model in aplistinspiredXMLstring. 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:
encodeStatein classODE- Parameters:
plist- theStringBuilderto write the encoded state to- See Also:
-
restoreState
Description copied from class:ModelRestore the state encoded in theplistinspiredmapofkey, value-pairs.- Overrides:
restoreStatein classODE- Parameters:
plist- the map ofkey, value-pairs- Returns:
trueif successful- See Also:
-
encodeGeometry
Encodes the geometry of the spatial structure for this PDE in the form of apliststring.- 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:
trueif successful
-
encodeTraits
Description copied from class:ODEEncodes state of the model in the form of apliststring.- Overrides:
encodeTraitsin classODE- Parameters:
plist- the string builder for the encoded state
-
restoreTraits
Description copied from class:ODERestores the state encoded inplist.- Overrides:
restoreTraitsin classODE- Parameters:
plist- the encoded state- Returns:
trueif successful
-
encodeFitness
Description copied from class:ODEEncodes the fitness of the model in the form of apliststring.- Overrides:
encodeFitnessin classODE- Parameters:
plist- the string builder for the encoded state
-
restoreFitness
Description copied from class:ODERestores the fitness encoded inplist.- Overrides:
restoreFitnessin classODE- Parameters:
plist- the encoded state- Returns:
trueif successful
-