# CS382:Predator-Prey

## Contents

# Predator Prey ( Lynx Hare )

## Overview

The predator prey unit will last for a week and a half. (Or, 3 classes) The purpose of this unit is to teach the students of this class about using system dynamics, using predator-prey interaction as a vehicle to facilitate the student's understanding of how the systems dynamics approach to modeling functions. This unit will consist of a lab where students use a couple of different simulation models to explore the intricacies of how predator and prey interact, both agent-based and system dynamics based.

## Background Reading for Teachers and TAs

- US Department of Energy's very nice (if ugly) intro to System Dynamics
- Great compilation of knowledge on the subject. Is the primary source for the present lecture notes.

- Systems Dynamics Society SD Wiki
- Another compilation of knowledge used extensively in the lecture notes.

## Reading Assignments for Students

- Given the reference materials present so far, it's possible that rather than having a link to online reading assignments, we may have to create paper handouts based on the materials that we have links to.

- A handout created from parts of the US Dept. Of Energy's guide to System Dynamics seems like a very good place to start.

## Reference Material

- Page on Lynx - Hare Populations
- A page detailing the relationship between the populations on Lynx and Hares. It also shows a graph and asks students to do several questions based on that graph.

- Talks about Lynx - Hare as a Pred/Prey model
- Talks about the Lynx / Hare model of predator prey, and the relationship between the two populations.

- Wolf Sheep Agent based netlogo model
- The starting agent-based wolf-sheep predator-prey model.

- Wolf Sheep Systems Dynamics netlogo model
- This is the starting model system dynamics model that we took apart and modified to build the rest of the lab based on.

- US Department of Energy's very nice (if ugly) intro to System Dynamics
- Introduction to systems dynamics. Tells you everything you need to know about System Dynamics to get started. This is where the majority of the reading assignments will be coming from.

- Systems Dynamics Society SD Wiki
- System Dynamics Wiki. Should be given out as a reference at the beginning of the unit for students who need additional understanding on the topic.

## Lecture Notes

Outline of the lectures designed to fit into 2 1:20 slots per week. This unit lasts 1 1/2 weeks, so requires 3 lectures. I dig the detail of these lecture notes. Do more!

**Lecture 1:**

- Intro & Concepts
- What is system dynamics? for instance, answer these
- What is it for?
- What does it let you do?
- Systems dynamics lets you sketch out the relationships between all the components of a dynamic system, and given those relationships, will allow you to predict how the system behaves over a period of time. Will it result in a fluctuating growth? Exponential growth? Perfect equilibrium? All of these questions should be answerable using this type of model.

- Why use System Dynamics? When should you use it?
- The answer to this question is essentially the same as why you should use any other model. It's oftentimes quicker, cheaper and safer to alter a model and run tests on that than to alter a real system and run tests on that. Additionally, a failure in a model will allow you to predict a failure in a real system.
- Failure in a real system often has catastrophic consequences, such as the loss of lives. The failure of a model is often much less devastating, resulting in perhaps a "Darn. Well, back to the drawing board." instead of "My son/daughter was in that building!"

- Strengths / Weaknesses and list some of these

- Basic Terminology (Building Blocks)
- Time Paths
- A time path is how something changes over time (either the whole system or an aspect of the system).

- Link
- Feedback Loop

- Stock
- A stock is a quantity of objects that's variable in nature. Examples of this are the number of sheep in a pasture, the number of fish in a pond, the amount of oil left in the world, the number of tanks in the US military, etc.

- Flow
- This represents the flow of resources either into or out of a stock. For instance, drilling would represent a flow out of the stock of oil in Alaska, and into the stock of oil in the US Oil Reserve.

- Time Paths

- Causal Loop Diagram
- Pictures used to convey understanding of interactions or influences within the structure. It's used specifically to show the influential interactions between two elements of a structure.
- The main conventions that are used to display a loop are the "+", "-", "S" and "O"
- That is to say, that if a arrow is shown from A to B with a + on it, it means that A adds to B. As A increases, it adds more and more to B, and as it decreases, it adds less and less, but still adds to B
- With a - shown with the arrow, A subtracts from B. As A grows, it subtracts more and more from B. As A diminishes, it subtracts less and less from B (But still subtracts)
- With a S shown with the arrow, A and B grow in the same direction. This means that as A increases, B increases, and vice versa.
- A O indicates that A and B grow in opposite directions, I.E. as A shrinks B grows and vice versa.
- With no label, it indicates that A is considered a constant.
- The Causal loop diagram gives no indication as to the strength of the influence of the two elements, it just shows the nature of the influence.
- There are, generally speaking, two types of Causal loops. A Reinforcing loop and a Balancing loop.
- In a reinforcing loop, each action adds to the other. An action that produces a result that produces more of the same action is a reinforcing loop.
- In a balancing loop, any action attempts to bring two things to agreement. A situation where one tries to solve a problem or achieve a goal is representative of a balancing loop.

**Lecture 2:**

- More Terminology
- System Dynamics is interested in the behavior of systems over a period of time. Time paths are critical to expressing this.
- Types of Time Paths
- Linear Family
- Growth / Decline
- The notion that most systems grow / decline under a linear curve is in fact incorrect. A linear growth or decline indicates a system which is devoid of feedback.
- Feedback is a crucial part for the growth or decay of any system.

- Equilibrium
- The expression of a system under which there is no pressure for change, or a system in which all variables reach their desired state at the same point in time
- Note that this is an extremely artificial scenario, most systems do NOT reach or maintain equilibrium.

- Growth / Decline
- Exponential Family
- Paths showing exponential growth and exponential decay. Real systems tend to grow along exponential paths rather than linear paths.

- Goal-Seeking Family
- Displayed in most living, and some nonliving systems

- Oscillation Family
- Sustained
- Characterized by a predictable periodicity.
- Predator-Prey relations are often characterized by this, as while the individual oscillations may vary, they often follow a predictable oscillating pattern in that the rise of the prey population indicates the rise of the predator population, and the decline of a prey population causes the decline of a predator population.

- Dampened
- Displayed by systems that display dissipation or relaxation processes, such as friction or information smoothing.

- Exploding
- Starts of smoothly, but grow until either the system settles down or is torn apart.
- This pattern occurs infrequently in real-world situations, and doesn't last long when it does.

- Chaos
- A unique type of oscillation, as it basically represents a random pattern generated by a system that is devoid of randomness

- Sustained
- S-Shaped Family
- This is extremely visible in the Wolf Sheep Agent based netlogo model when the grass is taken out of the equation. The sheep population goes too high, which in turn causes the wolf population to increase too much, which leads to an irrecoverable decline in the sheep population. (Extinction)
- This is referred to as an "Overshoot and crash" system.

- Linear Family

- Review of the "Building Blocks" of a System Dynamics model

**Lecture 3:**

- Review of Class 1 and 2.
- Still working on material for this. Fair enough

## Lab

#### Process

- Open up the Netlogo Lynx-Hare model showing both an agent based model and an empty system dynamics model.
- Start Netlogo.
- Click File->Open and select pred.nlogo
- Two windows should pop up, focus on the one that has buttons and input boxes on it.

- Play around with the agent based model and observe the behavior of the model:
- Press the Setup button on the left side of the model.
- Enter the values you want in the various input boxes
- Press the Go button.

- Observing the agent based model, identify parts of the system dynamics model:
- Determine the stocks in this model.
- Determine the flows.
- Determine what effects the sheep birth / death rate.
- Determine what effects the wolf birth / death rate.

- Figure out the variables then look at how you can tweak the simulation.

- Draw a causal loop diagram using the above information.
- Implement the System Dynamics Netlogo model using the causal loop diagram: (TODO: How to name the parts of the model)
- Focus on the other window that came up when you opened the model.
- For each stock in your causal loop diagram, click the Stock button at the top and then click somewhere in the blank area.
- For each of the placed stocks place two flows, one on the left and one on the right of each stock. Connect the flows to the stock by clicking and dragging the close end of the flow to the stock.
- In each of the stocks input the appropriate equations.
- Click the Check button and return to the other window.

- Experiment with different values for the two models.
- Make notes of what you notice.

- In <Some piece of software Charlie is getting us>, collect data points from a run of the agent based model. Fit a curve to this data. Using the curve equations, configure the system dynamics model to produce a result similar to the one gleaned from the agent-based simulation. (TODO: this needs to be fleshed out more)
- We will be providing a set of values for the agent-based model. Do you have these?
- We need to determine exactly how to do this in Excel.

- Evaluation for correctness / completeness.
- Evaluate the correctness of the system dynamics model. How? Be more specific, please. For the poor confused freshmen.
- Evaluate how well the results of the system dynamics model meshed with the results generated by the agent-based model.

#### Write-up

- Required Elements:
- Provide all the stuff we told them to to in the procedure.
- What are the stocks?
- What are the flows?
- How can the simulation be tweaked?
- A causal loop diagram.
- Netlogo implementation of the system dynamics model.
- Excel file with the fit curve.
- An explanation of how they came up with the values for the system dynamics model based on the fitted curve.

- Provide all the stuff we told them to to in the procedure.
- Visualization opportunities:
- Placeholder.

- Optional elements:
- Placeholder.

- Provide a template for the first couple of labs ala CS128?
- Placeholder.

#### Software

- Custom Lynx-Hare model based on Wolf Sheep Systems Dynamics netlogo model

#### Bill of Materials

- I don't think it will be practical to try and conduct a lab for this unit with anything but software.
- So far all the software that we've found is open-source and free.

## Evaluation

#### CRS Questions

- Look at the graph on Lynx - Hare as a Pred/Prey model. What type of oscillation does it show?
- A. Chaos
- B. Explosive
- C. Dampening
- D.
**Sustained**

- What is a good example of a reinforcing loop?
- A. Uncontrolled fishing in a lake
- B. Spilling wine on a carpet
- C.
**A Stock Market crash** - D. Parents buying a child toys

#### Quiz Questions

- Look at the graph on Lynx - Hare as a Pred/Prey model. What is the average periodicity of the oscillation?
- Give an example of a system with a explosive type of oscillating time path.
- Pick a system from the following list, and draw a model of it.
- System A
- System B
- Etc.

- What is an example of a stock?
- Fish in a lake
- The net worth of the stock market
- Wine in a glass
**All of the above**

- Draw an example of a system following the explosive oscillation pattern.
- What growth model is displayed by most systems?
**Exponential increase**- Dampening oscillation
- Linear increase
- Equilibrium

# Predator Prey Metadata

This section contains information about the goals of the unit and the approaches taken to meet them. et them.

## Scheduling

- Given that this unit employs agent-based modeling as a introductory element in order to make the switch to system dynamics, it would be best if this unit came after a unit on agent-based modeling, or at least a unit in which students were introduced to agent-based modeling.

## Concepts, Techniques and Tools

This is a placeholder for a list of items from the context page.

## General Education Alignment

### Analytical Reasoning Requirement

#### Abstract Reasoning

From the [Catalog Description] *Courses qualifying for credit in Abstract Reasoning typically share these characteristics:*

*They focus substantially on properties of classes of abstract models and operations that apply to them.*- Complete. The entire unit is about students learning exactly what you can do with a system dynamics model. It would be impossible to teach that without discussing the properties of the model and what operations you could perform on it.

*They provide experience in generalizing from specific instances to appropriate classes of abstract models.*- Partial. The way the unit works is by teaching students about the class of model, and has them build a specific one as part of a lab activity.

*They provide experience in solving concrete problems by a process of abstraction and manipulation at the abstract level. Typically this experience is provided by word problems which require students to formalize real-world problems in abstract terms, to solve them with techniques that apply at that abstract level, and to convert the solutions back into concrete results.*- Partial. The lab activity involves constructing a model, manipulating the data that goes in, and then collecting results, but not in order to satisfy a concrete problem.

#### Quantitative Reasoning

From the [Catalog Description] *General Education courses in Quantitative Reasoning foster students' abilities to generate, interpret and evaluate quantitative information. In particular, Quantitative Reasoning courses help students develop abilities in such areas as:*

*Using and interpreting formulas, graphs and tables.*- Complete. In this unit we have students create and examine formulas for modeling the relationships between the different parts of the systems. We also have them draw diagrams for representing their model and then use graphs and tables to analyze their results.

*Representing mathematical ideas symbolically, graphically, numerically and verbally.*- Complete. Systems dynamics is at it's core representing systems symbolically and mathematically.

*Using mathematical and statistical ideas to solve problems in a variety of contexts.*- Complete. We are using mathematics to solve problems.

*Using simple models such as linear dependence, exponential growth or decay, or normal distribution.*- Complete. In this unit we look at the concepts of linear and exponential growth and decay, among others.

*Understanding basic statistical ideas such as averages, variability and probability.*- Partial. Only so much as these ideas would be helpful in a particular model.

*Making estimates and checking the reasonableness of answers.*- Complete. Experimentation is used when developing models and there is an analysis part of our lab.

*Recognizing the limitations of mathematical and statistical methods.*- Complete. When comparing SD to Agent based we will go into the relative strengths and weaknesses of SD in general and as compared to Agent based modeling.

### Scientific Inquiry Requirement

From the [Catalog Description] *Scientific inquiry:*

*Develops students' understanding of the natural world.*- Complete. They can model natural systems including our example, Predator-Prey models.

*Strengthens students' knowledge of the scientific way of knowing — the use of systematic observation and experimentation to develop theories and test hypotheses.*- Complete. Experimentation is used when developing models.

*Emphasizes and provides first-hand experience with both theoretical analysis and the collection of empirical data.*- Partial. We certainly provide some experience with theoretical analysis but not much empirical data will be collected.

## Scaffolded Learning

- The scaffold approach in this unit is aimed at building a bare-bones understanding of system dynamics, then slowly adding layers of complexity and moving up the complexity ladder until the students have a

## Inquiry Based Learning

Some prose.

Consider open-ended questions for the students to explore in the context of the lab. What happens when you change X? Why?

# Predator Prey Mechanics

## General Feedback

- A list of items maintained by the authors, Charlie, and the Reviewers.

## Lab Feedback

### Run 1

It took about 20 min without doing a full write-up or the last part. The instructions were a little sparse and assumed knowledge of the tools. However the basics of the lab work well and gives students a chance to actually see how a systems dynamics model can be created and run, and explores the difference between it and Agent based modeling. It would have been nice to have the final part ready as I think it is in a lot of ways the kicker of the lab but even if it's not included it's still a fairly strong lab. I think it's an appropriate difficulty in that there it requires students to apply what they've learned and use a new tool but, assuming the instructions were fleshed out, provides enough scaffolding to help them get through it without much despair.

## Archived Feedback

- Put answers to CRS / quiz Qs in bold
- Done.

- Come up with something concrete, then go into detail on it (at least to the level of procedure). That'll make it easier to evaluate where to go with it in the greater scheme of things, and to offer suggestions for what might be most effective. Agreed.
- Done.

- They're going to need to know how to get to that one.
- How should they determine these?
- More information on how put in.

- ??? I have only a vague idea of what this means. I can see that there's an interface in Netlogo to edit the diagram, but what exactly do they need to do?
- Fleshed out the details more.

- Yep. You're supposed to do it as part of the lab writeup for this week for people to be able to do your lab. :P
- d(^_^)b

- Maybe I'm just terrible at using the browser interface, but the diagram window did not pop up for me in either Firefox or Safari. Using the Netlogo on my machine, though, I had both windows for the diagram and testing. If I'm doing something wrong, then it needs instructions; otherwise we might need to make them download it for reals (gasp)
- No longer being done in the browser

- Make a new model with the correct vermin. Could we also just change the name of the unit?
- Done. (or at least it will be.)

# Authorship

Dylan Parkhurst

Matt Edlefsen