Class EvoLudo
- All Implemented Interfaces:
MersenneTwister.Chronometer
,CLOProvider
- Direct Known Subclasses:
EvoLudoGWT
EvoLudoJRE
and GWT specific code to
EvoLudoGWT
. Two distinct
implementations are required e.g. because of significant differences in
input/output routines.- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Coloring methods for multiple continuous traits.static interface
The interface to execute commands in a manner that is agnostic to the implementation details regarding GWT or JRE environments. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Model
The active modelprotected Module
The active module.static final CLOption.Category
The category for global options.static final CLOption.Category
The category for user interface specific options.static final CLOption.Category
The category for model specific options.static final CLOption.Category
The category for module specific options.static final CLOption.Category
The category for simulation specific options.protected List
<ChangeListener> List of change listeners that get notified when the model changes.protected String
The command line options (raw string provided in URL, HTML tag, TextArea or command line)final CLOption
Command line option to set the delay between subsequent updates.final CLOption
Command line option to print help message for available command line options.final CLOption
Command line option to set the type of model (seeType
).final CLOption
Command line option to set module.final CLOption
Command line option to perform test of random number generator on launch.final CLOption
Command line option to request that the EvoLudo model immediately starts running after loading.final CLOption
Command line option to set seed of random number generator.final CLOption
Command line option to set color scheme for coloring continuous traits.final CLOption
Command line option to set the color for trajectories.final CLOption
Command line option to set verbosity level of logging.protected EvoLudo.ColorModelType
The coloring method type.static final String
The copyright string.(package private) double
Starting time of CPU sampling (negative if not sampling).(package private) double
Mean time of CPU sampling.(package private) int
Number of CPU time samples(package private) double
Variance of time of CPU sampling.protected int
Delay between subsequent updates in milliseconds when model is running.private static final double
Delay decrement for speed sliderSlider
static final double
Initial delay between subsequent updates for speed sliderSlider
static final double
Maximum delay between subsequent updates for speed sliderSlider
static final double
Minimum delay between subsequent updates for speed sliderSlider
private boolean
Flag to indicate if a backstep is in progress.boolean
The flag to indicate whether the current device/program supports touch eventsfinal int
UniqueID
of EvoLudo instance.private static int
The loggers of each EvoLudo lab instance need to have unique names to keep the logs separate.static boolean
The flag to indicate whether EvoLudo is running in a web browser (or ePub) using javascript generated by GWT or in the java JRE.protected boolean
The flag to indicate whether the active model is running.protected boolean
The flag to indicate whether running of the model is suspended.protected Logger
The logger for keeping track of and reporting events and issues.protected List
<MilestoneListener> List of engine listeners that get notified when the state of the population changed, for example after population reset or completed an update step.The lookup table for all available modules.protected CLOParser
The parser for command line options.protected ChangeListener.PendingAction
The action that is pending (if any).private boolean
The flag to indicate whether the module reqiuires a full reparsing of the command line options.private boolean
The flag to indicate whether a reset of the active model has been requested.protected RNGDistribution
The shared random number generator to ensure reproducibility of results.protected int
timeout for layout process of snapshots in msec. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(ChangeListener newListener) Add a change listener to the list of listeners that get notified when the model changes.void
addCLOProvider
(CLOProvider provider) Registerclo
as a provider of command line options.void
addMilestoneListener
(MilestoneListener newListener) Add a milestone listener to the list of listeners that get notified when the model reaches milestones.void
Addmodule
to lookup table of modules using the module's key.void
collectCLO
(CLOParser prsr) All providers of command line options must implement this method to collect their options.Creates individual based simulation model formodule
.abstract Network2D
createNetwork2D
(Geometry geometry) Generate 2D network.abstract Network3D
createNetwork3D
(Geometry geometry) Generate 3D network.Creates ordinary differential equation model formodule
.Creates partial differential equation model formodule
.Creates stochastic differential equation model formodule
.void
debug()
Advances the EvoLudo model by a single debugging step.void
Decrease delay between subsequent updates by fixed factor.void
dumpEnd()
Concluding words for report (currently JRE only).void
Report all parameter settings tooutput
(currently JRE only).abstract int
Calculate elapsed time since instantiation in milliseconds.Encode current state of EvoLudo model as XML string (plist format).protected void
Finish sampling CPU time.abstract void
execute
(EvoLudo.Directive directive) Executedirective
in JRE or GWT environments.abstract void
Export the current state of the engine using the appropriate means available in the current environment (GWT/JRE).void
Report error and stop model execution, if running.void
Called whenever the state of the model has changed.void
Called after the model has been re-initialized.void
Called whenever a new model has finished loading.void
Called after the model completed its relaxation.void
Called after the model has been reset.void
Called whenever the model starts its calculations.void
Called after the population has reached an absorbing state (or has converged to an equilibrium state).void
Called whenever a new model has finished loading.void
Called whenever a new module has finished loading.void
Called after the state of the model has been restored either through drag'n'drop with the GWT GUI or through the--restore
command line argument.void
Called whenever the current module has finished unloading.void
Called whenever the settings of the model have changed.getCLO()
Get the raw command line options, as provided in URL, HTML tag, settings TextArea or command line.Format, encode and output help on command line options.Get the type of color model for translating continuous traits into colors.int
getDelay()
Get delay between subsequent updates.abstract String
getGit()
Gets current git version of code base.abstract String
Gets the compilation date of the current git version.Get version of JRE (if not running in browser).Note: Instead of sharing logging system, EvoLudo could implement helper routines for logging notifications.getModel()
Get the active model.Gets the activeModule
.getRNG()
Get the shared random number generator to ensure the reproducibility of results.int
Gets the timeout for the layout process of snapshots in msec.String[]
Get the command line options split into an array with option names followed by their arguments (if applicable).Return version string of current model.abstract PDESupervisor
hirePDESupervisor
(PDE charge) Hire supervisor for managing PDE calculations.void
Increase delay between subsequent updates by fixed factor.boolean
Check if the active model is running.boolean
Check whether the current model is suspended.void
Notification from GUI that layout process has finished.boolean
Set model type and loads the corresponding frameworks for individual based simulations or numerical integration of ODE/SDE/PDE models.loadModule
(String newModuleKey) Load new module with keynewModuleKey
.void
Convenience method to log errors of simulations.void
logMessage
(String msg) Convenience method to log messages of simulations.abstract void
logProgress
(String msg) Utility method to log progress of simulations.void
logWarning
(String msg) Convenience method to log warnings of simulations.final boolean
Check consistency of parameters in all populations.final void
Initialize all populations and notify all listeners.final void
modelInit
(boolean quiet) Initialize all populations and notify all listeners if requested.final boolean
Advance model by one step (reportFreq
updates) and notify all listeners.final boolean
modelNextDone
(boolean cont) Called after the calculations of the next state of the model have finished.final boolean
Relax model bytimeRelax
steps and notify all listeners when done.final boolean
modelRelax
(boolean quiet) Relax model bytimeRelax
steps and notify all listeners if requested.final void
Reset all populations and notify all listeners.final void
modelReset
(boolean quiet) Reset all populations and notify all listeners if requested.abstract void
next()
Advances the EvoLudo model by a single step.boolean
Called after parameters have changed.boolean
parseCLO()
Parse command line options.protected boolean
Pre-process and parse array of command line arguments.protected String[]
preprocessCLO
(String[] cloarray) Pre-process array of command line arguments.void
prev()
Attempts to backtrack a single step of the EvoLudo model.(package private) void
Helper method for handling model changed events and processes pending actions.void
removeChangeListener
(ChangeListener obsoleteListener) Remove the change listener from the list of listeners that get notified when the model changes.void
removeCLOProvider
(CLOProvider provider) Unregisterclo
as a provider of command line options.void
removeMilestoneListener
(MilestoneListener obsoleteListener) Remove the milestone listener from the list of listeners that get notified when the model reaches milestones.void
Requests aChangeListener.PendingAction
to be processed on the next opportunity.void
requestAction
(ChangeListener.PendingAction action, boolean now) Requests aChangeListener.PendingAction
to be processed on the next opportunity.void
Request full reparsing of the command line options.void
requiresReset
(boolean reset) Request reset the active model, e.g.protected void
Resets sampling of CPU time.abstract boolean
Restore state of EvoLudo model from saved plist, which encodes engine state.boolean
restoreState
(Plist plist) Restore state of EvoLudo model from pre-processed plist, which encodes engine state (seeencodeState()
).abstract void
run()
Start the EvoLudo model and calculate the dynamics one step at a time.void
Set the raw command line options, as shown e.g.void
setColorModelType
(EvoLudo.ColorModelType colorModelType) Set the type of the color model for translating continuous traits into colors.void
setDelay
(int delay) Set delay between subsequent updates.void
setSuspended
(boolean suspend) Set the flag indicating whether the model is suspended.abstract void
showHelp()
Show help on command line options.void
Run simulation.protected void
Starts sampling CPU time.void
Start or stop EvoLudo model.void
stop()
Requests halting of a runningModel
on the next opportunity.void
Unload model framework.void
unloadModel
(boolean quiet) Unload model framework and, if requested, notifies all registeredMilestoneListener
's.void
Unload current module to free up resources.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface CLOProvider
adjustCLO
-
Field Details
-
isGWT
public static boolean isGWTThe flag to indicate whether EvoLudo is running in a web browser (or ePub) using javascript generated by GWT or in the java JRE. Special characters in strings can result in headaches when running in an ePub (or, worse still, in XHTML pages).true
when running as GWT application;false
for JRE applications. -
hasTouch
public boolean hasTouchThe flag to indicate whether the current device/program supports touch eventsNote: cannot be
static
orfinal
to allow disabling touch events for debugging (seeEvoLudoGWT.cloGUIFeatures
). -
IDcounter
private static int IDcounterThe loggers of each EvoLudo lab instance need to have unique names to keep the logs separate. UseIDcounter
to generate uniqueID
's. -
ID
public final int IDUniqueID
of EvoLudo instance.- See Also:
-
logger
The logger for keeping track of and reporting events and issues. -
rng
The shared random number generator to ensure reproducibility of results.- See Also:
-
modules
The lookup table for all available modules. -
activeModel
The active model -
resetRequested
private boolean resetRequestedThe flag to indicate whether a reset of the active model has been requested. This is necessary after certain parameter changes. For example, changing the population size (seeIBSPopulation.nPopulation
) requires a reset to (re)generate population geometries and initialize types/strategies. -
reparseCLO
private boolean reparseCLOThe flag to indicate whether the module reqiuires a full reparsing of the command line options. -
milestoneListeners
List of engine listeners that get notified when the state of the population changed, for example after population reset or completed an update step. -
changeListeners
List of change listeners that get notified when the model changes. -
cpu
double cpuStarting time of CPU sampling (negative if not sampling). -
cpuMean
double cpuMeanMean time of CPU sampling. -
cpuVar
double cpuVarVariance of time of CPU sampling. -
cpuSamples
int cpuSamplesNumber of CPU time samples -
clo
The command line options (raw string provided in URL, HTML tag, TextArea or command line) -
isSuspended
protected boolean isSuspendedThe flag to indicate whether running of the model is suspended. For example while parameters are being applied. If the changes do not require a reset of the model the calculations are resumed after new parameters are applied. Also used when command line options are set to immediately start running after loading (seecloRun
). -
DELAY_MIN
public static final double DELAY_MINMinimum delay between subsequent updates for speed sliderSlider
- See Also:
-
DELAY_MAX
public static final double DELAY_MAXMaximum delay between subsequent updates for speed sliderSlider
- See Also:
-
DELAY_INIT
public static final double DELAY_INITInitial delay between subsequent updates for speed sliderSlider
- See Also:
-
DELAY_INCR
private static final double DELAY_INCRDelay decrement for speed sliderSlider
- See Also:
-
delay
protected int delayDelay between subsequent updates in milliseconds when model is running. -
activeModule
The active module. -
isRunning
protected boolean isRunningThe flag to indicate whether the active model is running. -
doPrev
private boolean doPrevFlag to indicate if a backstep is in progress. -
pendingAction
The action that is pending (if any). -
COPYRIGHT
The copyright string.- See Also:
-
snapLayoutTimeout
protected int snapLayoutTimeouttimeout for layout process of snapshots in msec. -
parser
The parser for command line options. -
catGlobal
The category for global options. -
catModule
The category for module specific options. -
catModel
The category for model specific options. -
catSimulation
The category for simulation specific options. -
catGUI
The category for user interface specific options. -
cloModule
Command line option to set module. -
cloModel
Command line option to set the type of model (seeType
). -
cloSeed
Command line option to set seed of random number generator. -
cloRun
Command line option to request that the EvoLudo model immediately starts running after loading. -
cloDelay
Command line option to set the delay between subsequent updates. -
cloTrajectoryColor
-
cloTraitColorScheme
Command line option to set color scheme for coloring continuous traits.- See Also:
-
cloRNG
Command line option to perform test of random number generator on launch. This takes approximately 10-20 seconds. The test reports (1) whether the generated sequence of random numbers is consistent with the reference implementation ofMersenneTwister
and (2) the performance of MersenneTwister compared toRandom
. -
cloVerbose
Command line option to set verbosity level of logging. -
cloHelp
Command line option to print help message for available command line options. -
colorModelType
The coloring method type.
-
-
Constructor Details
-
EvoLudo
public EvoLudo()Create an instance of the EvoLudo controller. EvoLudo manages different module/model implementations and the connection between simulations/numerical calculations and the GUI interface as well as the execution environment. This includes logging (verbosity and output channels), restoring previously saved engine states as well saving the current state of the engine, export its data or graphical snapshots. -
EvoLudo
protected EvoLudo(boolean loadModules) Constructor to instantiate a new EvoLudo controller. IfloadModules == true
, load all available modules. Otherwise a specific module needs to be loaded by the caller.- Parameters:
loadModules
- the flag to indicate whether to load modules
-
-
Method Details
-
logProgress
Utility method to log progress of simulations. For implementation details seeEvoLudoJRE
andEvoLudoGWT
- Parameters:
msg
- progress message
-
logMessage
Convenience method to log messages of simulations.- Parameters:
msg
- information message
-
logWarning
Convenience method to log warnings of simulations.- Parameters:
msg
- warning message
-
logError
Convenience method to log errors of simulations.- Parameters:
msg
- error message
-
getRNG
Get the shared random number generator to ensure the reproducibility of results. This is the only RNG that MUST be used for all calculation, i.e. must be shared with all models including distributions (e.g. for mutations, migration...)Important:
- Must be used for any random numbers related to the modelling.
- Must not be used for anything else, e.g. shared with layout procedures for networks (although it may be desirable to set a seed for the layout routines in a consistent manner if one was set for the simulations, to also ensure visual reproducibility).
- If the number of random numbers drawn changes, any corresponding test fails almost certainly. Tests pass only if the results are identical.
- Returns:
- the one and only random number generator for modelling
- See Also:
-
createODE
Creates ordinary differential equation model formodule
.Note: by default returns
RungeKutta
model. Override to provide custom implementation of ODE model.- Parameters:
module
- the interactionModule
- Returns:
- the ODE model for
module
-
createSDE
Creates stochastic differential equation model formodule
.Note: by default returns
SDE
model. Override to provide custom implementation of SDE model.- Parameters:
module
- the interactionModule
- Returns:
- the SDE model for
module
-
createPDE
Creates partial differential equation model formodule
.Note: by default returns
PDE
model. Override to provide custom implementation of PDE model.- Parameters:
module
- the interactionModule
- Returns:
- the PDE model for
module
-
createIBS
Creates individual based simulation model formodule
.Note: by default returns
IBSD
forDiscrete
models andIBSC
forContinuous
models. Override to provide custom implementation of IBS model.- Parameters:
module
- the interactionModule
- Returns:
- the IBS model for
module
-
createNetwork2D
Generate 2D network. This is the factory method to provide different implementations for GWT and JRE. More specifically, the layouting process in GWT uses scheduling (asynchronous execution) to prevent the GUI from stalling, while JRE implementations take advantage of multiple threads for significantly faster execution due to parallelization.- Parameters:
geometry
- the geometry backing the 2D network- Returns:
- new instance of a 2D network
-
createNetwork3D
Generate 3D network. This is the factory method to provide different implementations for GWT and JRE. More specifically, the layouting process in GWT uses scheduling (asynchronous execution) to prevent the GUI from stalling, while JRE implementations take advantage of multiple threads for significantly faster execution due to parallelization.Note: The
java3d
package is obsolete. At present no 3D implementation for java exists.- Parameters:
geometry
- the geometry backing the 3D network- Returns:
- new instance of a 3D network
-
loadModel
Set model type and loads the corresponding frameworks for individual based simulations or numerical integration of ODE/SDE/PDE models. Notifies all registeredMilestoneListener
's of any changes.- Parameters:
type
- the type ofModel
to load- Returns:
true
if model type changed
-
getModel
Get the active model.- Returns:
- the active model
-
requiresReset
public void requiresReset(boolean reset) Request reset the active model, e.g. after change of parameters.- Parameters:
reset
-true
if reset is requested
-
requestParseCLO
public void requestParseCLO()Request full reparsing of the command line options. This is necessary if the command line options have changed in a fundamental way, for example if the number of traits in a module has changed. -
addMilestoneListener
Add a milestone listener to the list of listeners that get notified when the model reaches milestones.- Parameters:
newListener
- the new milestone listener
-
removeMilestoneListener
Remove the milestone listener from the list of listeners that get notified when the model reaches milestones.- Parameters:
obsoleteListener
- the listener to remove from list of milestone listeners
-
addChangeListener
Add a change listener to the list of listeners that get notified when the model changes.- Parameters:
newListener
- the new change listener
-
removeChangeListener
Remove the change listener from the list of listeners that get notified when the model changes.- Parameters:
obsoleteListener
- the listener to remove from the list of change listeners
-
unloadModel
public void unloadModel()Unload model framework. Notifies all registeredMilestoneListener
's. -
unloadModel
public void unloadModel(boolean quiet) Unload model framework and, if requested, notifies all registeredMilestoneListener
's.- Parameters:
quiet
- set totrue
to skip notifying listeners
-
modelCheck
public final boolean modelCheck()Check consistency of parameters in all populations.Note: in multi-species interactions optimizations seem sensible only if all populations involved approve of them.
- Returns:
true
if reset is required
-
modelReset
public final void modelReset()Reset all populations and notify all listeners. -
modelReset
public final void modelReset(boolean quiet) Reset all populations and notify all listeners if requested.Note: if
quiet == true
statistics are preserved.- Parameters:
quiet
- set totrue
to skip notifying listeners
-
modelInit
public final void modelInit()Initialize all populations and notify all listeners. -
modelInit
public final void modelInit(boolean quiet) Initialize all populations and notify all listeners if requested. In contrast tomodelReset(boolean)
this method does not re-generate the population structures.- Parameters:
quiet
- set totrue
to skip notifying listeners
-
resetCPUSample
protected void resetCPUSample()Resets sampling of CPU time. -
startCPUSample
protected void startCPUSample()Starts sampling CPU time. -
endCPUSample
protected void endCPUSample()Finish sampling CPU time. -
modelRelax
public final boolean modelRelax()Relax model bytimeRelax
steps and notify all listeners when done. If model converged during relaxation notify listeners that model has stopped.- Returns:
true
if converged- See Also:
-
modelRelax
public final boolean modelRelax(boolean quiet) Relax model bytimeRelax
steps and notify all listeners if requested.- Parameters:
quiet
- set totrue
to skip notifying listeners- Returns:
true
if converged- See Also:
-
modelNext
public final boolean modelNext()Advance model by one step (reportFreq
updates) and notify all listeners.- Returns:
true
if not converged, i.e. ifmodelNext()
can be called again.
-
modelNextDone
public final boolean modelNextDone(boolean cont) Called after the calculations of the next state of the model have finished. For GWT this method serves as a callback for the asynchronous model computations. For JRE this runs in a separate thread from the GUI andmodelNext()
directly calls this.- Parameters:
cont
-false
if converged or halting time reached- Returns:
true
if not converged, i.e. ifmodelNext()
can be called again.
-
paramsDidChange
public boolean paramsDidChange()Called after parameters have changed. Checks new settings and resets population(s) (and/or GUI) if necessary.- Returns:
true
if reset was necessary
-
getCLO
Get the raw command line options, as provided in URL, HTML tag, settings TextArea or command line.- Returns:
- command line options
-
getSplitCLO
Get the command line options split into an array with option names followed by their arguments (if applicable).- Returns:
- array command line options and arguments
-
setCLO
Set the raw command line options, as shown e.g. in the settings TextArea.- Parameters:
clo
- the new command line option string
-
isSuspended
public boolean isSuspended()Check whether the current model is suspended.- Returns:
true
if model is suspended
-
setSuspended
public void setSuspended(boolean suspend) Set the flag indicating whether the model is suspended. A suspended model resumes execution as soon as possible. For example after a new set parameters has been checked.- Parameters:
suspend
-true
to indicate that model is suspended.
-
setDelay
public void setDelay(int delay) Set delay between subsequent updates.- Parameters:
delay
- in milliseconds
-
getDelay
public int getDelay()Get delay between subsequent updates.- Returns:
- the delay in milliseconds
-
increaseDelay
public void increaseDelay()Increase delay between subsequent updates by fixed factor. -
decreaseDelay
public void decreaseDelay()Decrease delay between subsequent updates by fixed factor. -
loadModule
Load new module with keynewModuleKey
. If necessary first unload current module.- Parameters:
newModuleKey
- the key of the module to load- Returns:
true
if new module was loaded
-
unloadModule
public void unloadModule()Unload current module to free up resources.Implementation note:
Called fromloadModule(java.lang.String)
to first unload the active module or triggered by GWT'sEvoLudoWeb.onUnload()
, i.e. when unloading the GWT application. -
getModule
Gets the activeModule
.- Returns:
- the active module
-
addModule
Addmodule
to lookup table of modules using the module's key. If a GUI is present, add GUI as a listener ofmodule
to get notified about state changes.- Parameters:
module
- the module to add to lookup table
-
execute
Executedirective
in JRE or GWT environments.- Parameters:
directive
- the directive to execute in appropriate GWT or JRE manners
-
isRunning
public boolean isRunning()Check if the active model is running.- Returns:
true
if model is running
-
layoutComplete
public void layoutComplete()Notification from GUI that layout process has finished. Opportunity for taking snapshots. -
stop
public void stop()Requests halting of a runningModel
on the next opportunity. -
run
public abstract void run()Start the EvoLudo model and calculate the dynamics one step at a time. -
next
public abstract void next()Advances the EvoLudo model by a single step. Called when pressing the 'Step' button, the 'n' or 'right-arrow' key. -
startStop
public void startStop()Start or stop EvoLudo model. If model is running wait until next update is completed to prevent unexpected side effects. -
prev
public void prev()Attempts to backtrack a single step of the EvoLudo model. Called when pressing the 'Prev' button, the 'p' or 'left-arrow' key. -
debug
public void debug()Advances the EvoLudo model by a single debugging step. Called when pressing the 'Debug' button or 'D' key. -
simulation
public void simulation()Run simulation. Currently only implemented by EvoLudoJRE. Returns control to caller only if the arguments inclo
do not match requirements for running a simulation.- See Also:
-
requestAction
Requests aChangeListener.PendingAction
to be processed on the next opportunity. If model is not running the action is processed immediately.- Parameters:
action
- the action requested
-
requestAction
Requests aChangeListener.PendingAction
to be processed on the next opportunity. If model is not running ornow
is set totrue
the action is processed immediately.- Parameters:
action
- the action requestednow
-true
to processes action immediately
-
fireModuleLoaded
public void fireModuleLoaded()Called whenever a new module has finished loading. Notifies all registeredMilestoneListener
s. -
fireModuleUnloaded
public void fireModuleUnloaded()Called whenever the current module has finished unloading. Notifies all registeredMilestoneListener
s. -
fireModuleRestored
public void fireModuleRestored()Called after the state of the model has been restored either through drag'n'drop with the GWT GUI or through the--restore
command line argument. Notifies all registeredMilestoneListener
s.- See Also:
-
fireModelLoaded
public void fireModelLoaded()Called whenever a new model has finished loading. Notifies all registeredMilestoneListener
s. -
fireModelUnloaded
public void fireModelUnloaded()Called whenever a new model has finished loading. Notifies all registeredMilestoneListener
s. -
fireModelRunning
public void fireModelRunning()Called whenever the model starts its calculations. Fires only when starting to run. Notifies all registeredMilestoneListener
s. -
fireModelChanged
public void fireModelChanged()Called whenever the state of the model has changed. For example, to trigger the update of the state displayed in the GUI. Processes pending actions and notifies all registeredModel.MilestoneListener
s.- See Also:
-
fireSettingsChanged
public void fireSettingsChanged()Called whenever the settings of the model have changed. For example, to trigger the range of values or markers in the GUI. Notifies all registeredMilestoneListener
s.- See Also:
-
processPendingAction
void processPendingAction()Helper method for handling model changed events and processes pending actions.- See Also:
-
fireModelInit
public void fireModelInit()Called after the model has been re-initialized. Notifies all registeredMilestoneListener
s. -
fireModelReset
public void fireModelReset()Called after the model has been reset. Notifies all registeredMilestoneListener
s. -
fireModelRelaxed
public void fireModelRelaxed()Called after the model completed its relaxation. Notifies all registeredMilestoneListener
s. -
fireModelStopped
public void fireModelStopped()Called after the population has reached an absorbing state (or has converged to an equilibrium state). Notifies all registeredMilestoneListener
s. -
getLogger
Note: Instead of sharing logging system, EvoLudo could implement helper routines for logging notifications. However, when logging notifications with a severity ofLevel.WARNING
or higher the default logging message includes the name of the calling routine and hence would always refer to the (unhelpful) helper routines.- Returns:
- logger of this EvoLudo controller
-
hirePDESupervisor
Hire supervisor for managing PDE calculations. This is the factory method provide different implementations For GWT and JRE. More specifically, GWT uses asynchronous execution to prevent the GUI from stalling, while JRE implementations take advantage of multiple threads for significantly faster execution due to parallelization.- Parameters:
charge
- the PDE model to supervise- Returns:
- supervisor for coordinating PDE calculations
- See Also:
-
elapsedTimeMsec
public abstract int elapsedTimeMsec()Calculate elapsed time since instantiation in milliseconds.Hide GWT/JRE differences in measuring execution time.
- Specified by:
elapsedTimeMsec
in interfaceMersenneTwister.Chronometer
- Returns:
- time in milliseconds
- See Also:
-
getVersion
Return version string of current model. Version must include reference to git commit to ensure reproducibility of results.- Returns:
- the version string
-
getJavaVersion
Get version of JRE (if not running in browser).- Returns:
- the java version string
-
getGit
Gets current git version of code base.- Returns:
- the git version string
-
getGitDate
Gets the compilation date of the current git version.- Returns:
- the git compilation date as a string
-
getSnapLayoutTimeout
public int getSnapLayoutTimeout()Gets the timeout for the layout process of snapshots in msec.- Returns:
- timeout in msec
-
dumpParameters
public void dumpParameters()Report all parameter settings tooutput
(currently JRE only). -
dumpEnd
public void dumpEnd()Concluding words for report (currently JRE only). -
exportState
public abstract void exportState()Export the current state of the engine using the appropriate means available in the current environment (GWT/JRE).- See Also:
-
encodeState
Encode current state of EvoLudo model as XML string (plist format).- Returns:
- encoded state
-
restoreFromFile
public abstract boolean restoreFromFile()Restore state of EvoLudo model from saved plist, which encodes engine state.- Returns:
true
on successfully restoring state- See Also:
-
restoreState
Restore state of EvoLudo model from pre-processed plist, which encodes engine state (seeencodeState()
).Note: the appropriate model must already have been loaded and the command line arguments specified with the key
CLO
in theplist
must also have been processed already.In JRE the options in
plist
are merged with any other command line arguments (albeit the ones inplist
have priority to minimize the chance of complications). In GWTrestoreState(Plist)
is overridden to first deal with the command line arguments.- Parameters:
plist
- the lookup table with key value pairs- Returns:
true
on successfully restoring state
-
addCLOProvider
Registerclo
as a provider of command line options. Initialize command line parser if necessary.- Parameters:
provider
- the option provider to add
-
removeCLOProvider
Unregisterclo
as a provider of command line options.- Parameters:
provider
- the option provider to remove
-
preprocessCLO
Pre-process array of command line arguments. Some arguments need priority treatment. Examples include the options--module
,--verbose
or--restore
.--module
- load module and remove option
--verbose
- set verbosity level effective immediately. This ensures that issues when parsing the remaining command line options are already properly reported
- Parameters:
cloarray
- array of command line arguments- Returns:
- pre-processed array of command line options
- See Also:
-
parseCLO
public boolean parseCLO()Parse command line options.- Returns:
true
if parsing successful andfalse
if problems occurred- See Also:
-
parseCLO
Pre-process and parse array of command line arguments.- Parameters:
cloarray
- string array of command line arguments- Returns:
true
if parsing successful andfalse
if problems occurred- See Also:
-
getCLOHelp
Format, encode and output help on command line options.- Returns:
- the help string
-
showHelp
public abstract void showHelp()Show help on command line options. -
collectCLO
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.
Note: In contrast to other providers of command line options, the EvoLudo class maintains a reference to the parser (
prsr
andparser
must be identical).- Specified by:
collectCLO
in interfaceCLOProvider
- Parameters:
prsr
- the reference to parser that manages command line options- See Also:
-
getColorModelType
Get the type of color model for translating continuous traits into colors.- Returns:
- the type of color model
- See Also:
-
setColorModelType
Set the type of the color model for translating continuous traits into colors.- Parameters:
colorModelType
- the new type of color model- See Also:
-
fatal
Report error and stop model execution, if running.IMPORTANT: Does not return control to caller.
- Parameters:
msg
- the error message
-