modeling and simulation module 1: lesson 1 introduction to complex adaptive systems and computer...

85
Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Upload: gervais-peters

Post on 25-Dec-2015

240 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Modeling and SimulationModule 1: Lesson 1

Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Page 2: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Turn & Walk Activity

Simple Rules• You are an agent• Form a circle (or not)• Turn to face the person on your left • Close your eyes and take three steps in that

heading

Page 3: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Turn & Walk Computer Model

Web-based StarLogo Nova Platformhttp://www.slnova.org/GUTS/projects/4591/• What is the relationship between the

computer model and the real world?• What was included and what was missing

from the computer model of Turn & Walk?• What are computer models good for?

Page 4: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Setup and Forever blocks

Page 5: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Complex Adaptive Systems (CAS)

video “Introduction to Complex Systems”

https://www.youtube.com/watch?v=CPHjsWSzOY0

Page 6: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Complex Adaptive Systems (CAS)

Page 7: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Terms to Remember

• Agent• Simple rules• Heading• Iteration• Prediction• Emergent patterns

• Scatter• Initial conditions• Outcome• Phenomenon• Adaptive

Page 8: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Introduction to StarLogo Nova and Building Painting Turtles

Modeling and SimulationModule 1: Lesson 2

Page 9: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

StarLogo NovaA web-based software program

Computer Science Concepts• Instructions• Computer Program• Looping• Iterations• Public and Private

Galleries• Remixing

Page 10: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Guided Tour of StarLogo Nova

Follow Guided Introduction to StarLogo Nova to see the different parts of site.

www.slnova.org•User Interface•Terrain & Spaceland area•Blocks & Drawers (workspace to create your code)•Account & log in•My Profile, public & private galleries, creating new project•Sharing your project•Remixing your project

Page 11: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Flower Turtles Project

• Start a new blank project.• Name it ‘Flower Turtles’ with your name(s) in

the title.• Your challenge: Have turtles create a flower

o create 5 turtles that separate when ‘Setup’button is pushed.

o have the turtles move and leave trails with their pens down

• Save your project with both partners names

Page 12: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Flower Turtles ProjectIn the World Page- create 5 turtles that separate when the setup button is pushed.

In the Turtle Page- have the turtles move & turn to create a flower pattern.

Page 13: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Extensions: Painting Turtles Challenge

• REMIX your Flower Turtle project and call it “Painting Turtles”

• Your challenge: Paint a masterpieceo create many turtleso have the turtles move around the space leaving

trailso have a slight wiggle to their walko Change the colors of the turtles.

• Save your project with both partners names

Page 14: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Terms to Remember• Agent• Location• Heading• Steps

• Iteration• Setup• Runtime• Random

Page 15: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Conditional BranchingTrailblazer and Bumper Turtles

Modeling and SimulationModule 1: Lesson 3

Page 16: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 2

• What commands enabled turtles to change their environment?

• What could an agent leaving trails represent in a real world scenario?

Page 17: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

How turtles can react to their environmentTrailblazer

Instructions• Starting and ending in the same place.• Using a pencil, draw the path in the CENTER of squares. • Pick up ALL the gold while avoiding the hazards.• Color the squares as necessary according to the following rules:

– Take a step forward.– If you are standing on a RED square, then turn right by 90 degrees– Else If you are standing on a BLUE square, then turn left by 90

degrees– Else If you are standing on a BLACK square, then turn right by 180

degrees• Trade your map with your partner.

Page 18: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Discussion and New Concepts

• Comparing solutions• Computer Science concept: conditionals• New commands: If/Then and If/Then/Else• Boolean statements-– Evaluate to either True or False (Yes or No)

• Examples of conditionals in real life?

Page 19: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Setup and Forever blocks

Page 20: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

New SLNova Blocks

Page 21: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Bumper Turtles Challenge

• Start with the program called “Bumper Turtles starter” program

http://www.slnova.org/GUTS/projects/4593/• Click on the “Paint Landmarks” push button and see the

program execute the code provided. Do not change the code in Paint Landmarks!

• Remix the project, add your name(s) to the title• Your challenge is to make the turtles react to the

landmarks created by the “Paint Landmarks”– Use logic blocks that evaluate the color of the terrain and tells

the turtle how to turn.

Page 22: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Partial Solution

Page 23: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Discussion• What is the difference between if/then

statements in a row vs. nested if/then/else statements

• Does execution order matter?• What could these trails and bumpers

represent in Bumper Turtles model?• Terms to remember: conditional, Boolean,

evaluation

Page 24: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Probability with Dice and Data,Wiggle Walk, and Colliding Turtles

Modeling and SimulationModule 1: Lesson 1

Page 25: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 3

• What commands enabled agents to react to their environments?

Page 26: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 3

• What commands enabled agents to react to their environments?

• IF/THEN• IF/THEN/ELSE

Page 27: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 3

• An example of reacting to the environment: IF/THEN with a Boolean expression

Page 28: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

New in Lesson 4

• Today we are going to learn about probability (or the likelihood of something happening).

• Then we are going to use probability to make turtles do a “wiggle” walk.

Page 29: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Chances Are

• Today we are going to learn about probability• Form small groups and each group gets a cup

and a die. • Roll the die in the cup and record the result on

your activity sheet.• Repeat until you have 50 trials.

Page 30: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Chances Are

• What were your results?• If you used a bar graph to visualize your

results, what would it look like?• Pool each groups data and see the results for

the class.• What are the chances of rolling each number

between 1 and 6?

Page 31: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Chances Are

• We can mimic a roll of a die in StarLogo Nova using the random command.

• Random 6 will return a number between 0 and 5.

Page 32: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Chances Are• Random can be used within other commands.

For example, used within a left turn command, what do you think this command now does?

• If we used this command in an agent’s walk, what would it’s trail look like?

Page 33: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle walk

• Next imagine that you were going to roll two dice instead of one die. Do you think we will still get a flat distribution?

• In other words, is rolling a pair of ones as common as rolling a sum of 8?

Page 34: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle walk

• Fill in all the possible combinations of rolling two dice. Student 1

Stud

ent 2

-

Page 35: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle Walk

• What is the most common result of rolling two dice?

• What is the next most common result?• If we were to graph out the number of

occurrences of each result, what would it look like?

Page 36: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle Walk

• We use this “triangle” distribution when we want to to make agents walk with some randomness in their motion but mostly follow a straight line. We call this a wiggle walk.

Page 37: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle Walk

• We use this distribution when we want to to make agents walk with some randomness in their motion but mostly follow a straight line. We call this a wiggle walk.

Page 38: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle Walk

Page 39: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle Walk

• Try it yourself! • Open your Bumper Turtle program and make

your agents wiggle when they walk.• Next you can get rid of the red, black and blue

blocks

Page 40: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Wiggle Walk

• What’s the difference between a walk that uses one command

• And two commands?

Page 41: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Colliding Turtles

New Command: Collision

• Collisions occur when two agents bump into one another. (They do not need to be centered on the same patch.)

Page 42: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Colliding Turtles

New Command: Collision

Page 43: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Colliding Turtles

New Command: Collision with a condition

Page 44: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

New StarLogo Nova Blocks

Page 45: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Colliding Turtles(coding agent to agent interaction)

• Start from a new blank project• Create 50 blue turtles and 5 red turtles (use 2 ‘create do’

blocks)• Have the turtles move forward with a little wiggle in their

walk. (forever block on the turtle page)• Upon colliding with a red turtle, have turtles react to that

agent (the collidee) by changing their color to red.• Save your project, make sure your name(s) are in the title.• Extension: add a ‘chance’ or probability of a turtle turning

red when it collides with a red turtle.

Page 46: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 4

• What could collisions represent in the real world?

• Why do we use probability in models?

Page 47: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

End of Lesson 4

Page 48: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Epidemiology Modeling the Spread of Disease

Designing and Running Experiments

Modeling and SimulationModule 1: Lesson 5

Page 49: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 4

• What could collisions represent in the real world?

• Why do we use probability in models?

Page 50: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Lesson 5

• Introduction to Epidemiology.• Modeling the spread of a disease.• Creating a slider for transmission rate.• Using the slider value to determine whether

or not to pass a disease from agent to agent.• Creating a slider for recovery rate.• Using it to determine if a sick agent recovers.

Page 51: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Introduction to Epidemiology

• Epidemics are the spread of disease• Epidemiologists study the spread of disease• One way epidemiologists try to study the

spread of disease is through running simulations of how a disease spreads. Then they can test different measures to stop and epidemic.

Page 52: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

What is MRSA?• MRSA is a bacteria called Methicillin resistant

Staphylococcus Aureus. • Staphylococcus means grape-cluster in Greek.• Viewed at 10,000 x magnification.

Page 53: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

MRSA • 30% of a population has some form of

staphylococcus or staph on their skin or nose, which is known as colonization.

• About 880,000 people are infected with MRSA each year, out of those, 3% die.

Page 54: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

How Does it Spread?• Direct physical contact

Page 55: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

How to treat an infection• The infection is usually drained, cleaned, and

covered.• Treated with an appropriate antibiotic.• Keep it covered and don’t share personal items.

Page 56: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Picture of MRSA cycle

• MRSA transmission

ColonizedSusceptible (Healthy) Infected

Page 57: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Community-Associated MRSA Modeled as a Complex Adaptive System

This is a screen shot from a simplified version of a Community-associated MRSA model developed by the University of Chicago / Argonne National Laboratory. In this model, students go from home to school and back again. The agents can be in one of three states: healthy, infected, or colonized, and can infect others if they are colonized or infected.

Page 58: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

New in Lesson 5

• CS concepts: Variables and Procedures• We are going to turn our colliding turtles model

to make it into an epidemic model.• Let’s add a new widget called a slider. We will

use this slider to hold a value called the transmission rate.

• This rate is the percentage of time a disease gets passed from one person to another upon collision.

Page 59: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Variables

• Variables are containers for holding values.• Think of a variable as a box with a label.• In StarLogo Nova, Sliders can be used to hold

values and set values as inputs to the model.

Page 60: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Procedures• Procedures are stacks of commands that

perform a particular function and can be given a name.

Page 61: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Create a New StarLogo Nova widget

Page 62: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

New StarLogo Nova widget

• Change the max value to 100 by typing in 100 next to max and hitting the return key.

• Click on “Edit Widgets” again to get out into editing mode and back into play mode.

Page 63: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Use the New Widget

• We now have a way to set the transmission rate through the user interface with a slider.

• We can get the value of transmission rate in code.• How do we “pass the disease to the healthy agent

40% of the time after a collision?” [hint: remember the dice rolls]

Page 64: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Use the Transmission Rate Widget

• We are rolling a 100-sided die. If the result is less than the transmission rate, pass the disease on.

• How often should we roll less than the transmission rate?

• What kind of distribution does the roll of a single die give us?

Page 65: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Save and Test your Model

• Try changing the transmission rate?• What is missing if you wanted to use your model as

an experimental test bed?

Page 66: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Extension: Adding Recovery

• People sometimes recover from a disease• How can we use probability to determine

when a sick person recovers?

Page 67: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Adding Recovery

• Recovery will be a new procedure. • At each step a sick person has a chance of

recovery.

Page 68: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Adding Recovery

• Create a new slider for recovery rate.• Use that slider in the recover procedure to

determine whether the sick agent recovers (becomes healthy again).

Page 69: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Adding Recovery

• Create a new slider for recovery rate.

Page 70: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Adding Recovery

• Use that slider in the recover procedure to determine whether the sick agent recovers (becomes healthy again or blue).

Page 71: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Save and Test your Model

• Try changing the recovery rate?• Did you see any new outcomes or patterns?

Page 72: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 5

• What does this model tell you?• What is the impact of changing the

transmission rate? And recovery rate?• What other things move through a population

like a disease?

Page 73: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

End of Lesson 5

Page 74: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Adding InstrumentationDesigning and Running Experiments

Modeling and SimulationModule 1: Lesson 6

Page 75: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 5

• What are the different ways we have used probability in this model?

• What is the impact of changing the transmission rate?

• What was the impact of changing the recovery rate?

Page 76: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Instrumenting your Model

Definitions:• Qualitative means relating to, measuring, or

measured by the quality of something (its size, appearance, value, etc.) rather than its quantity.

• Quantitative means relating to, measuring, or

measured by the quantity of something rather than its quality.

Page 77: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Instrumenting your Model

• We need some way of tracking the spread of disease.• What data should we collect?

Page 78: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Instrumenting your Model• Let’s create a new “line graph” widget called

“Population Healthy and Sick.”• We’ll use it to track #red (sick) and #blue (healthy)

over time.

Page 79: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Instrumenting your Model

• Drag the line graph off to the side of Spaceland.• Double click on New Series and change its name to

“CountHealthy” then select blue as its line color.• Add another Series and change its name to

“CountSick” then select red as its line color.• Finally, click “Edit Widgets” to leave editing mode

and returning to play mode.

Page 80: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Instrumenting your Model

• We want The World will update the line graph each time through the forever loop.

Page 81: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Test your Model

• Does the line graph work?• What patterns can you see that were difficult to see

without the line graph?

Page 82: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Customization

• Researching diseases and adding in real transmission rate values.

Page 83: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Designing and Running Experiments

• Use the Experimental Design form to describe your experiment.

• Plan and run your experiment.• Describe and share your findings.

Page 84: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

Review from Lesson 6

• Why is it important to instrument models?• How can computer models of epidemics be

used to better understand the spread of disease?

Page 85: Modeling and Simulation Module 1: Lesson 1 Introduction to Complex Adaptive Systems and Computer Modeling and Simulation

End of Lesson 6