CS199 Predator/Prey Models (lab)

Lab "Rules"

People are encouraged to work together during lab, to talk about the things they're seeing and concluding. Two heads are often better than one, and it's just more fun to have some chatter in the room, so please feel free to talk to one another during lab.

Holding Tanks

Download and run the following model:

holding-tanks.mox

First investigate the model. Notice that each gets the same amount of input and simply reports its contents.

Run the model and carefully examine the plotter window, including the data table. There are four holding tanks there, and they act slightly differently (actually, two work the same - which two?).

Q: What characterizes the difference between the first two and the second two tanks?

Q: What characterizes the difference between the second two tanks? How is that controlled?

Why is this important?

Many simulations can act differently depending on the kind of holding tanks you use. As a general rule of thumb, you should use "Integrated (delay)" unless you know of a reason to use something else. Integrated (delay) takes a new input at time N, where N is an integer number of time units, and spreads it over the period from N to N+1, depending on your step size (dt).

Predator-Prey Simulations

We hinted at this the first day, but didn't dig into the model. Today, we will. We won't explore the Cedar Bog model, since that's pretty complicated. Instead, we'll look at a simplification involving hare and lynx.

Prey

Please open Example > Tutorials > Predator Prey > Fig_1.mox

Explore the model. Notice the similarities between this model and the compound interest one.

Run the model. The hare population always grows exponentially, doesn't it, just like compound interest? That makes sense, because the new bunnies make more new bunnies.

Predators

What we need is a predator to keep this population in control! We'll assume:

Please open Example > Tutorials > Predator Prey > Fig_3.mox. Study the model. Notice the use of the text link called "Lynx Pop."

Notice the slider. These are kinda fun, but they're not normal blocks. You can find one in Model > Controls > Slider. Delete the existing slider and put another one in, just to practice.

Run the model and look at the plot. Notice that we now have two lines. Notice also that we have two different Y axes, one for the blue curve and one for the red line. Notice also how one curve is labeled "1" and the other "2."

Q: How are these plotting effects done?

Okay, the lynx aren't making much of a dent in the number of hare. But, of course, that's because the number of lynx doesn't increase.

More Predators!

Please open Example > Tutorials > Predator Prey > Fig_5.mox. Study the model. Notice the use of two holding tanks for two different state variables: the number of hare and the number of lynx. When you feel comfortable with the model, run it.

Q: In English, what happens? Interpret the graph.

Hunting Areas

Please open Example > Tutorials > Predator Prey > Fig_7.mox. Study the model. The model eliminates the slider and makes a very different calculation for the number of hare killed, namely:

((number of hare) / 100) * (number of lynx)

The rationale here is that the 100 represents the size of the modeled ecosystem, so the first term is the number of hare per unit area (acres, hectares, or whatever). The area should be measured in units equal to the territory of the lynx, so the first term can also be thought of as the number of hare in each lynx's normal territory. But of course, as the number of lynx increases, the territory will shrink.

Why do we multiply by the number of lynx? Does this make sense?

We'll use this for now, but keep in mind that it's easy to build simulations that we don't understand and maybe don't make sense.

Run the model and see how it acts.

Starvation!

Clearly, if we have too few prey, the predators should start dying out. Please open Example > Tutorials > Predator Prey > Fig_10.mox. Again, study the model.

Plot this. What do you see? Aha!

Q: Describe this so that it makes sense to you.

Q: Change the two holding tanks to be "Integrate (delay)" and see what happens. (You may need to run the simulation for more years, so that you get more cycles, to see an effect.) What happens?

StarLogo

StarLogo is a parallel simulator based on Logo. You can create essentially any number of turtles but each turtle executes the same code. However, there are ways to "customize" the code, so that you can create kinds of turtles and each kind has a particular behavior. You can then simulate the aggregate behavior.

StarLogo has now been installed on the standard lab image, so it will be on any public computer. It should be in the "all applications" folder on the dock. Launch it and run the built-in rabbits demo

  1. File > Open Project
  2. Choose Applications / StarLogo 2.1 / Sample Projects / Biology / rabbits.slogo

Notice that this software includes animation, which Extend does not.

Read about it at the starlogo site: click on the "Projects" button and then "rabbits" link.

This is another predator-prey simulation, but it is based on the following model rules:

Running the Starlogo Demo

Some questions:

Bias Simulation using StarLogo

Here is another simulation in StarLogo. This demonstrates sampling bias based on "locality." If the thing you're trying to measure tends to group in location (such as Democrats in cities and Republicans in rural areas), then polling by going door-to-door will give you a biased sample. Control-click on the following and download it to your desktop, and then open it with StarLogo.

JumperWalkers.slogo

In this model, we are trying to determine the percentage of green. There are "rabbits" who jump from random patch to random patch, counting. There are "foxes" who start at a random place and then walk from patch to patch. The graph shows their changings estimates of the percentage of green.

Here's how to run the simulation:

Interestingly, if you go door to door long enough, you converge on the unbiased sample. Rarely do we have time for that in real life, though!

Answers

This work is licensed under a Creative Commons License | Creative Commons License | Viewable With Any
Browser | Valid HTML 4.01! | Valid CSS!