Class LV
- All Implemented Interfaces:
Runnable,IBS.HasIBS,MilestoneListener,Model.HasDE,Model.HasDE.DualDynamics,Model.HasDE.ODE,Model.HasDE.SDE,Features,HasMean,HasMean.Traits,HasPhase2D,HasPop2D,HasPop2D.Traits,HasPop3D,HasPop3D.Traits,CLOProvider
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassODE model for the Lotka-Volterra module.classSDE model for the LV module.Nested classes/interfaces inherited from interface Features
Features.Groups, Features.Multispecies, Features.Pairs, Features.Payoffs, Features.StaticNested classes/interfaces inherited from interface HasMean
HasMean.Fitness, HasMean.TraitsNested classes/interfaces inherited from interface HasPhase2D
HasPhase2D.Data2PhaseNested classes/interfaces inherited from interface HasPop2D
HasPop2D.Fitness, HasPop2D.TraitsNested classes/interfaces inherited from interface HasPop3D
HasPop3D.Fitness, HasPop3D.TraitsNested classes/interfaces inherited from interface IBS.HasIBS
IBS.HasIBS.CGroups, IBS.HasIBS.CPairs, IBS.HasIBS.DGroups, IBS.HasIBS.DPairs, IBS.HasIBS.MCGroups, IBS.HasIBS.MCPairsNested classes/interfaces inherited from interface Model.HasDE
Model.HasDE.DGroups, Model.HasDE.DPairs, Model.HasDE.DualDynamics, Model.HasDE.EM, Model.HasDE.PDE, Model.HasDE.PDEADV, Model.HasDE.PDERD, Model.HasDE.RK5 -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CLOptionCommand line option to set the prey parameters.(package private) PredatorThe reference to the predator species.(package private) static final intThe index of the prey.(package private) double[]The reaction rates for prey reproduction, predation, and competition.(package private) doublePrey net per capita growth rate,a0 - dx, wheredxdenotes the death rate.(package private) doublePredator net per capita growth rate,b0 - dy, wheredydenotes the death rate.Fields inherited from class Discrete
cloMonoStop, monoStop, mutation, speciesFields inherited from class Module
active, cloDeathRate, cloGeometry, cloNGroup, cloNPopulation, cloPhase2DAxes, cloTraitColors, cloTraitDisable, cloTraitNames, competition, deathRate, defaultColor, engine, ibs, ID, interaction, logger, map2fitness, markers, model, nActive, name, nGroup, nPopulation, nTraits, opponent, playerUpdate, structure, traitColor, traitName, trajectoryColor, VACANT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheck()Check all parameters.voidcollectCLO(CLOParser parser) All providers of command line options must implement this method to collect their options.Opportunity to supply custom individual based simulations.createModel(Type type) Creates a model of typetypeformodule.intFor replicator dynamics the frequencies of all traits must sum up to one.(package private) voidgetDerivatives(double t, double[] state, double[] unused, double[] change, boolean isDensity) The Lotka-Volterra model is defined by the following equations: \[ \begin{align*} \frac{dx}{dt} =& x (a_0 - d_x - a_2 x + a_1 y)\\ \frac{dy}{dt} =& y (b_0 - d_y - b_2 y + b_1 x) \end{align*} \] where \(x\), and \(y\) are the densities of prey and predators, respectively.getTitle()Returns title of active module, e.g.voidload()Load new module and perform basic initializations.voidSet the map that transforms the data of the module to a 2D phase plane (projection) tomap.voidunload()Unload module and free all resources.Methods inherited from class Discrete
add, getMaxMonoPayoff, getMinMonoPayoff, getMonoPayoff, getMonoStop, getMutation, setMonoStopMethods inherited from class Module
createGeometry, getActiveTraits, getAuthors, getCompetitionGeometry, getDeathRate, getGeometry, getIBSPopulation, getID, getInteractionGeometry, getKey, getMap2Fitness, getMarkers, getMeanColors, getModelTypes, getNActive, getName, getNGroup, getNPopulation, getNRoles, getNSpecies, getNTraits, getOpponent, getPlayerUpdate, getSpecies, getSpecies, getTraitColor, getTraitColors, getTraitName, getTraitNames, getTrajectoryColor, getVacant, init, processColorMap, reset, run, setActiveTraits, setDeathRate, setGeometries, setIBSPopulation, setModel, setName, setNGroup, setNPopulation, setNTraits, setOpponent, setTraitColors, setTraitNames, setTrajectoryColorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CLOProvider
adjustCLOMethods inherited from interface Features
isMultispecies, isPairwise, isStaticMethods inherited from interface HasPhase2D
getPhase2DMapMethods inherited from interface IBS.HasIBS
createIBSMethods inherited from interface MilestoneListener
modelDidInit, modelDidReset, modelLoaded, modelRelaxed, modelRunning, modelSettings, modelStopped, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloaded
-
Field Details
-
predator
Predator predatorThe reference to the predator species. -
PREY
static final int PREYThe index of the prey.- See Also:
-
rates
double[] ratesThe reaction rates for prey reproduction, predation, and competition. -
rx
double rxPrey net per capita growth rate,a0 - dx, wheredxdenotes the death rate. Convenience variable for derivative calculations in differential equations models. -
ry
double ryPredator net per capita growth rate,b0 - dy, wheredydenotes the death rate. Convenience variable for derivative calculations in differential equations models. -
cloPrey
Command line option to set the prey parameters.
-
-
Constructor Details
-
LV
Create a new instance of the Lotka-Volterra module.- Parameters:
engine- the pacemaker for running the module
-
-
Method Details
-
getTitle
Description copied from interface:FeaturesReturns title of active module, e.g. 2x2 games inTBTreturns "2x2 Games". -
load
public void load()Description copied from class:ModuleLoad new module and perform basic initializations. -
unload
public void unload()Description copied from class:ModuleUnload module and free all resources. -
check
public boolean check()Description copied from class:ModuleCheck all parameters. After this call all parameters must be consistent. If parameter adjustments require a reset then this method must returntrue.Note: All parameter changes that don't require a reset can be made on the fly, in particular also while a model is running.
-
getDependent
public int getDependent()Description copied from interface:Model.HasDEFor replicator dynamics the frequencies of all traits must sum up to one. Hence, fornTraitstraits there are onlynTraits-1degrees of freedom. The index returned bygetDependent()marks the one rate of change that is derived from all the others.Notes:
- Dependent traits are used by models where the frequencies of all types must sum up to one.
- Density modules do not have dependent traits and
getDependent()should return-1. - Currently differential equations implementations are only provided for Discrete modules.
- Specified by:
getDependentin interfaceModel.HasDE- Returns:
- the index of the dependent trait (or
-1if there is none)
-
setPhase2DMap
Description copied from interface:HasPhase2DSet the map that transforms the data of the module to a 2D phase plane (projection) tomap. This provides an opportunity for implementing classes to change settings of the map.- Specified by:
setPhase2DMapin interfaceHasPhase2D- Parameters:
map- the map
-
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 classDiscrete- Parameters:
parser- the reference to parser that manages command line options- See Also:
-
getDerivatives
void getDerivatives(double t, double[] state, double[] unused, double[] change, boolean isDensity) The Lotka-Volterra model is defined by the following equations: \[ \begin{align*} \frac{dx}{dt} =& x (a_0 - d_x - a_2 x + a_1 y)\\ \frac{dy}{dt} =& y (b_0 - d_y - b_2 y + b_1 x) \end{align*} \] where \(x\), and \(y\) are the densities of prey and predators, respectively. \(a_0\geq 0\) indicates the per capita birth rate of prey, \(d_x\) the corresponding death rate, \(a_1\) the rate at which prey get dimished by predation, and \(a_2\geq 0\) the competition rate among prey. Similarly, \(\b_0\geq 0\) denotes the per capita birth rate of predators, \(d_y\) the corresponding death rate, \(b_1\) the rate at which predators grow due to predation, and \(b_2\geq 0\) the competition rate among predators. In the predator-prey scenario \(a_1\leq 0\) and \(b_1>0\) must hold, i.e. predators benefit from the presence of prey but not vice versa.In finite populations, the Lotka-Volterra model can be defined in terms of frequencies, where \(x\), and \(y\) denote the frequencies of prey and predators, respectively, and \(1-x\), \(1-y\) the remaining available space. This yields slightly modified dynamical equations: \[ \begin{align*} \frac{dx}{dt} =& x (a_0 (1 - x) - d_x - a_2 x + a_1 y)\\ \frac{dy}{dt} =& y (b_0 (1 - y) - d_y - b_2 y + b_1 x (1 - y)) \end{align*} \] Note: strictly speaking the second set of dynamical equations for frequencies violates the classical Lotka-Volterra model because they include a cubic term for increased reproduction mitigated by the other species but reduced by competition for space, i.e. \(x y (1-y) p_y\). This results in a qualitatively different dynamics.
- Parameters:
t- the current timestate- the current state of the systemunused- an unused array (for compatibility with theFeatures.Payoffsinterface)change- the array to store the changesisDensity- the flag indicating if the state is in terms of densities for frequencies- See Also:
-
createModel
Description copied from class:ModuleCreates a model of typetypeformodule.Note: Override to provide custom model implementations.
Important: any custom model implementations that involve random numbers, must use the shared random number generator for reproducibility
- Overrides:
createModelin classModule- Parameters:
type- the type ofModelto create- Returns:
- the model for
moduleornullif the module does not support the requested model type - See Also:
-
createIBSPop
Description copied from class:ModuleOpportunity to supply custom individual based simulations.- Overrides:
createIBSPopin classModule- Returns:
- the custom IBSPopulation or
nullto use default.
-