PredatorPreyPlant — Predator-Prey Dynamics including Vegetation

This is an expansion of the Predator-Prey model in which plants (the resource the prey feeds on) are modelled explicitly. The main additions/changes are the following:

  • The movement mechanism is different, and the movement rule now involves a movement radius so that each entity can move further than one cell per turn.

  • The presence of plants which can grow, based on different growth models

Implementation Details

Movement

In contrast to the PredatorPrey model, the movement rule is no longer called once per cell each turn. Instead, it is called for num_moves random cells each turn. This makes it possible for one cell to be selected multiple times to carry out the movement rule and other cells might not be selected at all within that time step.

The internal num_moves parameter can be set in the configuration via the num_moves_fraction key, which allows specifying it in units of the total number of grid cells.

Three possible actions take place on a selected cell:

  • In case both a predator and a prey are on a cell, the prey will flee in the same fashion as in the standard Predator-Prey model.

  • If there is a predator but no prey on the cell, the predator will move until it finds a prey or until it reaches the move_limit.

  • If there is only a prey but no resource, the prey will move to find resources until it reaches it or arrives at the move_limit. In this phase the prey will move to a cell even if there is a predator on it.

Vegetation Growth Model

There are three options for the growth models of the vegatation:

  • none: deactivates explicit modelling of vegetation. Grass regrows every turn, thus prey can also eat every turn.

  • deterministic: vegetation will regrow after a specific number of time-steps.

  • stochastic: vegetation will regrow with a certain probability, evaluated each time step.

Default configuration parameters

Below are the default configuration parameters for the PredatorPreyPlant model:

# --- Space -------------------------------------------------------------------
space:
  periodic: true


# --- CellManager -------------------------------------------------------------
cell_manager:
  grid:
    structure: square
    resolution: 64

  neighborhood:
    mode: Moore

  cell_params:
    # Initial prey and predator resources are drawn from a uniform integer (!)
    # distribution with the limits specified below.
    predator:
      min_init_resources: !is-unsigned 2
      max_init_resources: !is-unsigned 8
    prey:
      min_init_resources: !is-unsigned 2
      max_init_resources: !is-unsigned 8
 
    # The probabilities to have a predator, plant, and/or prey on a cell.
    # These probabilities are evaluated independently and for each cell.
    p_predator: !is-probability 0.05
    p_prey: !is-probability 0.3
    p_plant: !is-probability 1.

# Load species positions from datasets of a HDF5 file.
# If enabled, the presence of an entity is set using data from the respective
# dataset, i.e. `predator`, `prey`, and `plant`.
# Values can only be 0 or 1, specifying whether the respective entity is
# present on the corresponding cell.
cell_states_from_file:
  hdf5_file: !is-string /abs/path/to/data.hdf5
  load_predator: !is-bool false
  load_prey: !is-bool false
  load_plant: !is-bool false


# --- Model dynamics ----------------------------------------------------------
# How many cells to randomly select each time step and apply the movement rule
# to. This is specified in units of the number of available cells.
num_moves_fraction: !is-positive 1.


# Species-specific parameters; the model dynamics arise from these
predator:
  # Resource intake from eating and maximum resource value
  resource_intake: !param
    default: 3.
    dtype: float
    limits: [0.,~]
    
  resource_max: !param
    default: 20.
    dtype: float
    limits: [0.,~]
    

  # Cost of living (per time step)
  cost_of_living: !param
    default: 1.
    dtype: float
    limits: [0.,~]
    

  # Movement limit; how many single steps a predator can make when moving.
  move_limit: !param
    default: 1
    dtype: int
    limits: [1, ~]
    
  # Reproduction parameters: minimum resources required, probability for
  # the reproduction taking place, and cost of reproduction.
  repro_resource_requ: !param
    default: 4.
    dtype: float
    limits: [0.,~]
    
  repro_prob: !is-probability 0.5
  repro_cost: !param
    default: 2.
    dtype: float
    limits: [0.,~]
    


prey:
  resource_intake: !param
    default: 3.
    dtype: float
    limits: [0.,~]
    
  resource_max: !param
    default: 8.
    dtype: float
    limits: [0.,~]
    

  cost_of_living: !param
    default: 1.
    dtype: float
    limits: [0.,~]
    

  move_limit: !param
    default: 1
    dtype: int
    limits: [1, ~]

  # Fleeing probability when on the same cell together with a predator
  p_flee: !is-probability 0.5

  repro_resource_requ: !param
    default: 4.
    dtype: float
    limits: [0., ~]
    
  repro_prob: !is-probability 0.2
  repro_cost: !param
    default: 2.
    dtype: float
    limits: [0., ~]
    


plant:
  # Plants' growth model
  growth_model: !is-string stochastic
  # Available models:
  #  - none:           As in the standard Predator-Prey model, the presence of
  #                    plants is ignored. Thus, available resources for prey
  #                    are unlimited.
  #
  #  - deterministic   The system will regrow plants deterministically after a
  #                    constant regeneration time given by ``regen_time``.
  # 
  #  - stochastic      The system will regrow plants with a probability
  #                    given by parameter ``regen_prob``, evaluated each time
  #                    step for each cell without a plant on it.

  # The deterministic regeneration time
  regen_time: !is-unsigned 20

  # The regeneration probability (for stochastic regrowth)
  regen_prob: !is-probability 0.05

Available plots

The following plot configurations are available for the PredatorPreyPlant model:

Default Plot Configuration

phase_space/predator_prey:
  based_on: phase_space

  x: predator
  y: prey

  helpers:
    set_labels:
      x: Predator Density $[1/A]$
      y: Prey Density $[1/A]$

phase_space/prey_plant:
  based_on: phase_space
  
  x: prey
  y: plant

  helpers:
    set_labels:
      x: Prey Density $[1/A]$
      y: Plant Density $[1/A]$


# --- Time series of mean values ----------------------------------------------
species_densities:
  based_on: species_densities

mean_resources:
  based_on: mean_resources

# --- Animation of the spatial resource development of prey and predators -----
resources:
  based_on: .ca.state.anim_ffmpeg  # update to *_frames to save frames
  enabled: true

  model_name: PredatorPreyPlant

  # Select the properties to plot
  to_plot:
    resource_predator:
      title: Predator
      limits: [0, 8]   # Adapt to resource_max species parameter
      cmap: viridis

    resource_prey:
      title: Prey
      limits: [0, 8]   # Adapt to resource_max species parameter
      cmap: viridis

  helpers:
    set_suptitle:
      title: Resources
      fontsize: xx-large


# --- Animation of the spatial development of prey and predator populations ---
population:
  based_on: combined_grid_animation_ffmpeg  # update to *_frames to save frames
  enabled: true

  to_plot:
    # Combined in model_plots.PredatorPreyPlant.ca.combine_pred_and_prey
    combined: &population_combined
      title: Predator and Prey
      limits: [0, 3]
      cmap: 
        empty: white
        prey: orange
        predator: blue
        both: red


# --- More detailed animation: prey only, combined, predator only -------------
population_detailed:
  based_on: combined_grid_animation_ffmpeg  # update to *_frames to save frames
  enabled: true

  to_plot:
    predator:
      title: Predator
      limits: [0, 1]
      cmap: 
        empty: white
        predator: blue
        
    combined:
      <<: *population_combined

    prey:
      title: Prey
      limits: [0, 1]
      cmap: 
        empty: white
        prey: orange

    plant:
      title: Plant
      limits: [0, 1]
      cmap: 
        empty: white
        plant: green

Base Plot Configuration

# -- Phase space plots --------------------------------------------------------
phase_space:
  based_on: .time_series.phase_space

  model_name: PredatorPreyPlant

  # How to color-code the time axis
  cmap: viridis_r

  # All below: passed on to plt.scatter
  s: 3.5


# -- Time series --------------------------------------------------------------
species_densities:
  based_on: .time_series.densities

  helpers:
    set_limits:
      x: [0, max]
    set_labels:
      y: Density $[1/A]$
    set_title:
      title: Densities

  model_name: PredatorPreyPlant

  # Which data to calculate the densities from
  to_plot:
    predator:
      mean_of: [x, y]
      preprocess:
        - create_mask: [==, 1]
      label: Predator

    prey:
      mean_of: [x, y]
      preprocess:
        - create_mask: [==, 1]
      label: Prey

    plant:
      mean_of: [x, y]
      preprocess:
        - create_mask: [==, 1]
      label: Plant

# -- Time series of the predator and prey resources ---------------------------
mean_resources:
  based_on: .basic_uni.lineplots

  helpers:
    set_limits:
      x: [0, max]
      y: [0, ~]
    set_labels:
      y: Resource Density $[1/A]$
    set_title:
      title: Mean Total Resources

  model_name: PredatorPreyPlant

  # Take average only of cells with resources >= 1
  to_plot:
    resource_predator:
      path_to_data: resource_predator
      transform_data:
        - where: [ge, 1]
        - mean: [x, y]
      label: Predator

    resource_prey:
      path_to_data: resource_prey
      transform_data:
        - where: [ge, 1]
        - mean: [x, y]
      label: Prey


# -- A grid animation that shows combined predator and prey positions ---------
combined_grid_animation_frames: &combined_grid_anim
  based_on: .ca.state.anim_frames

  model_name: PredatorPreyPlant

  # Use the custom plotting function
  module: model_plots.PredatorPreyPlant
  plot_func: combine_pred_and_prey

combined_grid_animation_ffmpeg:
  <<: *combined_grid_anim
  based_on: .ca.state.anim_ffmpeg

For the utopya base plots, see Multiverse Base Configuration.

References

Kurt Roth: Chaotic, Complex, and Evolving Environmental Systems, unpublished lecture notes, University of Heidelberg, 2019.