Starlogo: Infection Simulation

See here.

Starter films: UK Influenza Simulation, Swine Flu Simulation (US)

Setup

Make sure breed is set to sphere.

  1. Factory: Add a Setup block

  2. From Setup & Run: Clear Everyone.

  3. From MyBlocks/Turtle: Create Turtles (500).

  4. From Factory: Set Color (green).

  5. From MyBlocks/Turtle: Scatter Everyone

My Blocks: Setup & Run: Choose a Run Once block. Rename it 'infect'.

Add an if/then block from Logic.

Set the test under if (from Math) to Random (100) <= 10.

Set the result (Then part of If block) to Set Color red (from Traits).

Runtime Area

From Set up & Run: New Forever block. Change name to 'Run'.

Add forward, left and right from Movement. Set forward to 1 step. Set the turns to random 10.

Collisions Area

MyBlocks/Turtles: drag out collision block for Turtles/Turtles (we only have one breed on the board).

Add an if/then block to the first part of the collision block. Set the 'if' part to color of collidee = red. This will need anequals block from Maths and a Color of block from Other Agents. Set the 'then' part to set color red.

Repeat this for the second part of the Turtles collision block.

Recovery (Everyone area)

Add a slider from Setup and Run.

Add a shared number (variable) from the Variables area. Call it 'recovery'. Drag it into the slider. In Spaceland click on the number in the bottom right corner of the slider and set it to 100 so it can be a percentage value.

Recover Procedure

In the Turtles section of the canvas add a procedure block from Procedures. Call it recover.

Add an if/then block to the procedure. Set the test to random 100 <= recovery (the variable created above).

For the 'then' part add set color green from Traits.

MyBlocks/Turtles: add a copy of the recover procedure block to the Run block (under the left block).

Immunity

Drag an Agent Boolean variable from Variables onto the Turtles area of the canvas. Call it 'immune'.

MyBlocks/Turtles: new blocks available.

Move to Setup area. Under Create Turtles add an if/else block (under set color green). Set the test to random 100 <= 10.

Set the 'then' part to Set immune true (from MyBlocks/Turtles and Logic).

Set the 'else' part to Set immune false (from MyBlocks/Turtles and Logic).

Check For Immunity

In the Turtles area add a new procedure block and call it 'check for immunity'.

Add an if/then block. Set the test to turtles immune (from MyBlocks/Turtles) = false (from Logic).

Set the Then part to set color red.

In the Collisions area change the set color red blocks to check for immunity (procedure calls).

Monitoring

Setup area: drag a Monitor block from Setup & Run. Rename it infections.

From MyBlocks/Turtles drag out a Count Turtles With block and slot it into the Monitor.

Add condition color = red to the Count Turtle With block.

Graphs

From Setup & Run drag out a line graph.

Add 'count turtles with color = red' and 'count turtles with color = green'.

Now a line graph will show changes in the populations of healthy and infected turtles.

Change the Variables in the Model

How realistic is the model? What happens in real infections? How do infection rates vary between, say, influenza, measles and Ebola?

Exercises

Videos:

Epidemic UK Influenza Simulation  How Flu Spreads  Swine Flu Simulation (US)
Epidemic Plague & Fire in London  Influenza  Measles
Epidemic Influenza 1918  Influenza Pandemic   Measles  History Channel: The Plague  Ebola
Epidemic MMR  Ben Goldacre on MMR  MMR Debate on News  More Ben Goldacre
Epidemic Japan  China  Humane Society  Bird Flu  Cholera Zimbabwe  Cholera Haiti

Complete the exercises in this document (Word 2007) or this (Word 2003).

Films:

Plague & Fire in London Influenza Measles
Ebola    
Science of Simulating Disease  Modelling Influenza Pandemic Epidemiological Modelling