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

Lotka-Volterra module for EvoLudo. This module implements the classic Lotka-Volterra equations for predator-prey dynamics. It supports both deterministic and stochastic simulations, as well as individual-based simulations (IBS).
Author:
Christoph Hauert
  • Field Details

    • predator

      Predator predator
      The reference to the predator species.
    • PREY

      static final int PREY
      The index of the prey.
      See Also:
    • rates

      double[] rates
      The reaction rates for prey reproduction, predation, and competition.
    • rx

      double rx
      Prey net per capita growth rate, a0 - dx, where dx denotes the death rate. Convenience variable for derivative calculations in differential equations models.
    • ry

      double ry
      Predator net per capita growth rate, b0 - dy, where dy denotes the death rate. Convenience variable for derivative calculations in differential equations models.
    • cloPrey

      public final CLOption cloPrey
      Command line option to set the prey parameters.
  • Constructor Details

    • LV

      public LV(EvoLudo engine)
      Create a new instance of the Lotka-Volterra module.
      Parameters:
      engine - the pacemaker for running the module
  • Method Details

    • getTitle

      public String getTitle()
      Description copied from interface: Features
      Returns title of active module, e.g. 2x2 games in TBT returns "2x2 Games".
      Specified by:
      getTitle in interface Features
      Returns:
      the title of active module
    • load

      public void load()
      Description copied from class: Module
      Load new module and perform basic initializations.
      Overrides:
      load in class Discrete
      See Also:
    • unload

      public void unload()
      Description copied from class: Module
      Unload module and free all resources.
      Overrides:
      unload in class Discrete
      See Also:
    • check

      public boolean check()
      Description copied from class: Module
      Check all parameters. After this call all parameters must be consistent. If parameter adjustments require a reset then this method must return true.

      Note: All parameter changes that don't require a reset can be made on the fly, in particular also while a model is running.

      Overrides:
      check in class Module
      Returns:
      true to trigger reset
      See Also:
    • getDependent

      public int getDependent()
      Description copied from interface: Model.HasDE
      For replicator dynamics the frequencies of all traits must sum up to one. Hence, for nTraits traits there are only nTraits-1 degrees of freedom. The index returned by getDependent() 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:
      getDependent in interface Model.HasDE
      Returns:
      the index of the dependent trait (or -1 if there is none)
    • setPhase2DMap

      public void setPhase2DMap(HasPhase2D.Data2Phase map)
      Description copied from interface: HasPhase2D
      Set the map that transforms the data of the module to a 2D phase plane (projection) to map. This provides an opportunity for implementing classes to change settings of the map.
      Specified by:
      setPhase2DMap in interface HasPhase2D
      Parameters:
      map - the map
    • collectCLO

      public void collectCLO(CLOParser parser)
      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, the parser issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and call super.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 interface CLOProvider
      Overrides:
      collectCLO in class Discrete
      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 time
      state - the current state of the system
      unused - an unused array (for compatibility with the Features.Payoffs interface)
      change - the array to store the changes
      isDensity - the flag indicating if the state is in terms of densities for frequencies
      See Also:
    • createModel

      public Model createModel(Type type)
      Description copied from class: Module
      Creates a model of type type for module.

      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:
      createModel in class Module
      Parameters:
      type - the type of Model to create
      Returns:
      the model for module or null if the module does not support the requested model type
      See Also:
    • createIBSPop

      public IBSPop createIBSPop()
      Description copied from class: Module
      Opportunity to supply custom individual based simulations.
      Overrides:
      createIBSPop in class Module
      Returns:
      the custom IBSPopulation or null to use default.