WolfSheepPredation

Overview

This module is a reimplementation in R using the SpaDES and NetLogoR packages of the "Wolf sheep predation" NetLogo model by Wilensky (1997, NetLogo Wolf Sheep Predation model). Please refer to the NetLogo documentation for information on the model.

Usage

library(SpaDES.core)
library(SpaDES.tools)
library(NetLogoR)

# Define the parameters
wolfSheepParams <- list(.plotInitialTime = NA, .plotInterval = NA,
                        .saveInitialTime = 0, .saveInterval = 1,
                        grassOn = TRUE, grassTGrowth = 30,
                        nSheep = 100, gainFoodSheep = 4, reproSheep = 4,
                        nWolf = 50, gainFoodWolf = 20, reproWolf = 5)

# Model init
wolfSheepSim <- simInit(
  times = list(start = 0, end = 500),
  params = list(WolfSheepPredation = wolfSheepParams),
  modules = list("WolfSheepPredation"),
  paths = list(modulePath = "./examples/Wolf-Sheep-Predation")
)

# Run the model
wolfSheepRun <- spades(wolfSheepSim)

Events

The module events recreate the model procedures from the NetLogo model which are:

Plotting

The sheep (red) and the wolves (black) positions are plotted on the world. The world is homogeneous if grassOn = FALSE, or it is heterogeneous if grassOn = TRUE with green (1) and white (0) patches.

Saving

The size of the wolf and sheep populations are recorded in the saving event, as well as the number of green patches in the world if grassOn = TRUE.

Data dependencies

Input data

Model parameters must be defined beforehand. Otherwise, no other input data are necessary for this module.

Output data

The size of the sheep and wolf populations saved during the simulation, as well as the number of green patches if grassOn = TRUE, are available at the end of the simulation. You can access to it with wolfSheepRun$numSheep, wolfSheepRun$numWolves and wolfSheepRun$numGreen.

Links to other modules

No anticipated linkages to other modules.



Try the NetLogoR package in your browser

Any scripts or data that you put into this service are public.

NetLogoR documentation built on March 2, 2020, 5:08 p.m.