Preharvest Produce Microbial Contamination Simulator

Preharvest Produce Microbial Contamination Simulator preview image

1 collaborator

Default-person Sanghyun Han (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.3.1 • Viewed 109 times • Downloaded 3 times • Run 0 times
Download the 'Preharvest Produce Microbial Contamination Simulator' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model explores the stability of predator-prey ecosystems. Such a system is called unstable if it tends to result in extinction for one or more species involved. In contrast, a system is stable if it tends to maintain itself over time, despite fluctuations in population sizes.

HOW IT WORKS

There are two main variations to this model.

In the first variation, wolves and sheep wander randomly around the landscape, while the wolves look for sheep to prey on. Each step costs the wolves energy, and they must eat sheep in order to replenish their energy - when they run out of energy they die. To allow the population to continue, each wolf or sheep has a fixed probability of reproducing at each time step. This variation produces interesting population dynamics, but is ultimately unstable.

The second variation includes grass (green) in addition to wolves and sheep. The behavior of the wolves is identical to the first variation, however this time the sheep must eat grass in order to maintain their energy - when they run out of energy they die. Once grass is eaten it will only regrow after a fixed amount of time. This variation is more complex than the first, but it is generally stable.

The construction of this model is described in two papers by Wilensky & Reisman referenced below.

HOW TO USE IT

  1. Set the GRASS? switch to TRUE to include grass in the model, or to FALSE to only include wolves (red) and sheep (white).
  2. Adjust the slider parameters (see below), or use the default settings.
  3. Press the SETUP button.
  4. Press the GO button to begin the simulation.
  5. Look at the monitors to see the current population sizes
  6. Look at the POPULATIONS plot to watch the populations fluctuate over time

Parameters: INITIAL-NUMBER-SHEEP: The initial size of sheep population INITIAL-NUMBER-WOLVES: The initial size of wolf population SHEEP-GAIN-FROM-FOOD: The amount of energy sheep get for every grass patch eaten WOLF-GAIN-FROM-FOOD: The amount of energy wolves get for every sheep eaten SHEEP-REPRODUCE: The probability of a sheep reproducing at each time step WOLF-REPRODUCE: The probability of a wolf reproducing at each time step GRASS?: Whether or not to include grass in the model GRASS-REGROWTH-TIME: How long it takes for grass to regrow once it is eaten SHOW-ENERGY?: Whether or not to show the energy of each animal as a number

Notes:

  • one unit of energy is deducted for every step a wolf takes
  • when grass is included, one unit of energy is deducted for every step a sheep takes

THINGS TO NOTICE

When grass is not included, watch as the sheep and wolf populations fluctuate. Notice that increases and decreases in the sizes of each population are related. In what way are they related? What eventually happens?

Once grass is added, notice the green line added to the population plot representing fluctuations in the amount of grass. How do the sizes of the three populations appear to relate now? What is the explanation for this?

Why do you suppose that some variations of the model might be stable while others are not?

THINGS TO TRY

Try adjusting the parameters under various settings. How sensitive is the stability of the model to the particular parameters?

Can you find any parameters that generate a stable ecosystem that includes only wolves and sheep?

Try setting GRASS? to TRUE, but setting INITIAL-NUMBER-WOLVES to 0. This gives a stable ecosystem with only sheep and grass. Why might this be stable while the variation with only sheep and wolves is not?

Notice that under stable settings, the populations tend to fluctuate at a predictable pace. Can you find any parameters that will speed this up or slow it down?

Try changing the reproduction rules -- for example, what would happen if reproduction depended on energy rather than being determined by a fixed probability?

EXTENDING THE MODEL

There are a number ways to alter the model so that it will be stable with only wolves and sheep (no grass). Some will require new elements to be coded in or existing behaviors to be changed. Can you develop such a version?

Can you modify the model so the sheep will flock?

Can you modify the model so that wolf actively chase sheep?

NETLOGO FEATURES

Note the use of breeds to model two different kinds of "turtles": wolves and sheep. Note the use of patches to model grass.

Note use of the ONE-OF agentset reporter to select a random sheep to be eaten by a wolf.

RELATED MODELS

Look at Rabbits Grass Weeds for another model of interacting populations with different rules.

CREDITS AND REFERENCES

Wilensky, U. & Reisman, K. (1999). Connected Science: Learning Biology through Constructing and Testing Computational Theories -- an Embodied Modeling Approach. International Journal of Complex Systems, M. 234, pp. 1 - 12. (This model is a slightly extended version of the model described in the paper.)

Wilensky, U. & Reisman, K. (2006). Thinking like a Wolf, a Sheep or a Firefly: Learning Biology through Constructing and Testing Computational Theories -- an Embodied Modeling Approach. Cognition & Instruction, 24(2), pp. 171-209. http://ccl.northwestern.edu/papers/wolfsheep.pdf

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

COPYRIGHT AND LICENSE

Copyright 1997 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2000.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [num-sick run-number delay con-soil]

breed [sheep a-sheep]
breed [flies fly]
breed [plants plant]
turtles-own [energy infected? recover-count]
patches-own [countdown]
sheep-own [excreta-color]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-clear
  clear-all
  set run-number 1
  setup-world
  setup-patches
  reset-ticks
end 

to setup-keep
  clear-turtles
  clear-patches
  set run-number (run-number + 1)
  setup-world
  setup-patches
  reset-ticks
end 

to setup-world
  set-default-shape sheep "sheep 2"
  create-sheep initial-number-sheep
  [
    set color white
    set excreta-color red
    set size 7
    setxy random-xcor random-ycor
    set infected? false
    set recover-count random 144 + 24
  ]

  set-default-shape flies "bug"
  create-flies initial-number-flies
  [
    set color black
    set size 0.5
    setxy random-xcor random-ycor
    set energy flies-initial-energy
    set infected? false
  ]

  set-default-shape plants "plant"
  create-plants Nx * Ny
  [
    set color green
    set size 3
    let i who - initial-number-sheep - initial-number-flies
    let x (i mod Nx)
    let y ((i - x) / Nx)
    setxy ((max-pxcor + 1) / (Nx)) * (x + 0.5)  ((max-pycor + 1) / (Ny)) * (y + 0.5)
    set energy plants-initial-energy
    set infected? false
    set recover-count random 24 + 168
  ]

  infect
  set con-soil count patches with [pcolor = (black + 1)]
  set num-sick 0
  set delay 0
  do-plots
end 

;;;;;;;;;;;;;;;;;;;;;setup-functions;;;;;;;;;;;;;;;;;;;;;;;

to infect
  ask one-of plants [
    ifelse ( Not any? plants with [ infected? = false ] )[
      print "All plants are infected!!"
      stop
    ][
      ifelse(infected? = false)[
        set infected? true
        plants-get-sick
      ][ infect ]
    ]
  ]
end 

to setup-patches
  ask patches[set pcolor brown]
end 

;;;;;;;;;;;;;;;;;;;;; go ;;;;;;;;;;;;;;;;;;;;;;; <-- Main

to go
  if ticks >= 1440 [stop]
  if (num-sick = count turtles) [ set delay (delay + 1) ]
  if (delay > 60) [ stop ]

  ask plants [
    ifelse(energy > 0)[
      ifelse(energy < plants-initial-energy)[
        set energy (energy * (1 + plants-reproduce / 100))
      ][ set energy plants-initial-energy ]
    ]
    [
      ifelse(recover-count <= 0)[
        set energy plants-initial-energy / 5
        set recover-count random 24 + 168
      ][ set recover-count (recover-count - 1) ]
    ]
  ]

  ask sheep [
    move-sheep
    eat-plants
    if(random 100 <= sheep-excretion-chance) [ set pcolor excreta-color ]
    if(infected? = true)[set recover-count (recover-count - 1)]
  ]

  ask flies [
    move-flies
    set energy (energy - 0.25)
    eat-excrement
    reproduce-flies
  ]
  ask patches [ recovery-soil ]

  plants-infection-check
  sheep-infection-check
  flies-infection-check

  flies-death
  set num-sick count turtles with [ infected? = true ]
  do-plots
  tick
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;; Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;

to move-sheep
  rt random 80
  lt random 80
  fd 30
end 

to move-flies
  rt random 50
  lt random 50
  fd 5
end 

to eat-plants
  let prey one-of plants in-radius 2 with [energy > 0]
  if (prey != nobody) and (random 100 <= eat-chance) [
    ask prey [
      set energy -10
      if(energy < 0) [ set shape "plant small" ]
      if(infected? = true) and (random 100 <= infection-chance-from-plants)[
        ask sheep in-radius 2[ set infected? true ]
      ]
    ]
  ]
end 

to reproduce-flies
  if (random 100 <= flies-reproduce) and (energy > flies-initial-energy * 1.5) [
    set energy (energy / 2)
    hatch-flies 2 [
      rt random 360 fd 0.5
      set energy flies-initial-energy
    ]
  ]
end 

to eat-excrement
  if (any? patches in-radius 2)[
    ifelse (pcolor = red) [
      set pcolor orange
      set energy (energy + energy-from-red)
    ][
      ifelse (pcolor = orange) [
        set pcolor yellow
        set energy (energy + energy-from-orange)
      ][
        ifelse(pcolor = yellow) [
          set pcolor grey
          set energy (energy + energy-from-yellow)
        ][
          if(pcolor = violet) [
            set pcolor orange
            set energy (energy + energy-from-violet)

          ]
        ]
      ]
    ]
    if (any? patches in-radius 2 with [pcolor = violet or pcolor = (black + 1)]) and (random 1000 <= infection-chance-from-excreta) and (infected? = false)
    [set infected? true]
  ]
end 

to flies-death
  ask flies[ if(energy < 0) [ die ] ]
end 

to recovery-soil
  ifelse (pcolor = red) [
    set countdown excrement-recovery-red
    ifelse (countdown <= 0) [ set pcolor orange ][ set countdown (countdown - 1) ]
  ][
    ifelse (pcolor = orange) [
      set countdown excrement-recovery-orange
      ifelse (countdown <= 0) [ set pcolor yellow][ set countdown (countdown - 3) ]
    ][
       ifelse (pcolor = yellow) [
         set countdown excrement-recovery-orange
         ifelse (countdown <= 0) [set pcolor grey ][ set countdown (countdown - 5) ]
       ][
          ifelse (pcolor = grey) [
            ifelse (countdown <= 0) [ set pcolor brown ][ set countdown (countdown - 10) ]
          ][
             ifelse (pcolor = (black + 1)) [
               set countdown excrement-recovery-black
               ifelse (countdown <= 0) [ set pcolor sky ][ set countdown (countdown - 10) ]
            ][
               ifelse (pcolor = sky) [
                 set countdown excrement-recovery-sky
                 ifelse (countdown <= 0) [ set pcolor brown ][ set countdown (countdown - 10) ]
               ][
                 if (pcolor = violet) [
                   set countdown excrement-recovery-violet
                   ifelse (countdown <= 0) [ set pcolor orange ][ set countdown (countdown - 10) ]
                 ]
               ]
            ]
          ]
       ]
    ]
  ]
end 

to plants-get-sick
  set pcolor (black + 1)
  set color 57
  ifelse(energy > 0)[ set shape "plant sick" ][set shape "plant small"]
end 

to sheep-get-sick
  set shape "sheep 2 sick"
  set excreta-color violet
end 

to flies-get-sick
  set shape "bug sick"
end 

to plants-infection-check
  ask plants [
    if (any? flies in-radius 2 with [infected? = true]) and (random 1000 <= infection-chance-from-flies)[ set infected? true ]
    ifelse (infected? = true) [ plants-get-sick ]
    [
      set color green
      ifelse(energy > 0)[ set shape "plant"][ set shape "plant small" ]
    ]
  ]
end 

to sheep-infection-check
  ask sheep [
    ifelse (infected? = true) [
       sheep-get-sick
       if(recover-count <= 0)[
         set infected? false
         set excreta-color red
         set shape "sheep 2"
         set recover-count random 144 + 24
       ]
    ]
    [
      set excreta-color red
      set shape "sheep 2"
    ]
  ]
end 

to flies-infection-check
  ask flies
  [
    ifelse (infected? = true) [
      flies-get-sick
      if(random 100 <= fly-excretion-chance) [ set pcolor sky ]
    ]
    [set shape "bug"]
  ]
end 

to do-plots
  set-current-plot "soil contaminations"
  set-current-plot-pen "red"
  plot count patches with [pcolor = red]
  set-current-plot-pen "orange"
  plot count patches with [pcolor = orange]
  set-current-plot-pen "yellow"
  plot count patches with [pcolor = yellow]
  set-current-plot-pen "grey"
  plot count patches with [pcolor = grey]
  set-current-plot-pen "black"
  plot count patches with [pcolor = (black + 1)]
  set-current-plot-pen "sky"
  plot count patches with [pcolor = sky]
  set-current-plot-pen "violet"
  plot count patches with [pcolor = violet]
end 

There is only one version of this model, created about 1 year ago by Sanghyun Han.

Attached files

File Type Description Last updated
Preharvest Produce Microbial Contamination Simulator.png preview Preview for 'Preharvest Produce Microbial Contamination Simulator' about 1 year ago, by Sanghyun Han Download

This model does not have any ancestors.

This model does not have any descendants.