1.4k likes | 1.41k Views
Understand and modify agent-based models to explore phenomena like forest fires and urban segregation. Step-by-step guide with practical exercises.
E N D
MIS 643 Agent-Based Modeling and Simulation 2017/2018 Fall Chapter 3: Exploring and Extedning Agent-Based Models
Outline Intorduction The Fire Model The Diffusion-Limited Aggregation (DLA) Model The Segregation Model The El Farol Model Conclusion
Introduction • This chapter is based on • IABM-WR: Chapter 3
Introduction • Learn how to modify and extend an ABM • Four characteristics of AB Modeling • 1 – Simple rules can be used to generate complex phenomena • 2 – Randomness in individual behavior can results in consistant patterns of population behavior • 3 – Complex patterns can be “self-organize” without any leader organizer • 4 – Different models emphasize different aspects of the world
Rule 1 • many models – simple rules • without any complex math • deep understanding of the knowledge domain • E.g.: the fire model • with very simple rules about spreading of fire form tree to tree • interesting things to say about how likely a fire is sepead all over the forest
Rule 2 • seeing an ordered population behavior • individual level need not be ordered • by fixed rules • stochastic rules mey results ordered patterns at the population level
Rule 3 • flock of bird - no leader bird or organizer abut how to fly • self-organize without a leader
Rule 4 • different models different aspects of the world • For each model filter out some aspects and remove others • Segragation model is about • how urban population develop • but nothing to say about • location of retail stores • or parks • or school districts
Outline Intorduction The Fire Model The Diffusion-Limited Aggregation (DLA) Model The Segregation Model The El Farol Model Conclusion
The Fire Model • Description of the Fire Model • First Extension: Probablistic Transitions • Second Extension: Adding Wind • Third Extension: Allow Long Distance Transmission • Summary of the Fire Model • Advenced Modeling Applications
The Fire Model • many complex systems • critical treshold • tipping point • A small change in one parameter results in a large change in outcome • model of a forest fire • spread of a disease • diffusion of innovation • Sensitive to one parameter: percentage of trees • after some percentage
Tipping Point • know where tipping point is and where you are
Description of the Fire Model • percolation: • in 1987, Denish physisists and complex systems theoritst, Per Bak • self-oganizing criticallity
A Simple Fire Model • (Wilenksly 1997a), NetLogo library in Earch Science section • Fire Simple in: Simple Models > IABM > Chapter 3 > Fire Extension > Fire Simple • Only patches – four kind • green: unburn tree • red: burning tree • brown: burned tree • black: empty space
A Simple Fire Model (cont.) • when setup • Left edge of World – all red – on fire • when running • the fire will ignate neighboring trees – neighbor four • continues • untill run out of trees • Control parameter: density • a probability whether or not a patch is a tree
Initialization • set up trees: a randomly seleted patch is a tree with a probablity density. • make a column of burning treese at the left edge • keep track of how many trees there are • Interface – world • origin – center • max-pxcor = 125, max-pycor = 25 • wrap off • patch size: 2
setup globals [initial-trees] patches-own [] to setup ca ask patches [ if random 100 < density [set pcolor green] if pxcor = min-pxcor [set pcolor red] ] set initial-trees count patches with [pcolor = green] reset-ticks end
Exercises • Different initializations of trees • Inililize always fixed number of trees • Find other ways of initialization of threes and burning trees
iterations • ask the burning trees to set fire to any neighboring (four neithbors) non-burning trees
go to go ask patches with [pcolor = red] [ ask neighbors4 with [pcolor = green] [ set pcolor red ] ] tick end
Stoping Condition • iterations stop when all trees are burned if all? patches [pcolor != red] [stop] • i
final go procedure to go if all? patches [pcolor != red] [stop] ask patches with [pcolor = red] [ ask neighbors4 with [pcolor = green] [ set pcolor red ] set pcolor red - 3.5 ] tick end
Reporter • write a reporter to return trees fireing • and use the reporter properly
Reporter to report fire-trees return patches with [pcolor = red] end • change go from ask patches with [pcolor = red] • to ask fire-trees
Monitoring percentage of burend trees • Add a monitor to the interface to see the percentages of trees bured • Add a monitor • to the reporter: (count patches with [shade-of? pcolor red]) / initial-trees * 100
Tipping Point • Experiment with density parameters and see how percent of trees burned changes with the density of trees • At 59% there is a tipping point • a slite change in input parameter has a large effect on output
First Extension: Probablistic Transitions • Many simplifying assumptions: • fire does not spread deterministically • but many factors: • wind, wood type, how close the branches are • not certain - with a proabability • Change the go procedure so that a burning tree ignates fire to its neighbor with a probability
probabilistic spread • old go statement ask patches with [pcolor = red] [ ask neighbors4 with [pcolor = green] [ set pcolor red ] ... • new go statement ask patches with [pcolor = red] [ ask neighbors4 with [pcolor = green] [ if random 100 < probability-of-spread [set pcolor red] ] ...
Silder for probability parameter • add a slider for setting the value of probability-of-spread • from 0 to 100
Experimentation • Experiment with both probability-of-spread and density parameters • setting probability to 100 returns to the original model • for a given density, high values of probability-of-spread is needed to get almost same percentage of spread
Second Extension: Adding Wind • wind: • increases the chance of fire spread in the direction it is blowing • decreases the chnage of fire spread in the direction it is not blowing • no effect on the chance of spread in the perpendicular direction • Implemented by two sliders • speed from the south (negative from north) • speed from the west (negative from east)
Initialization • both form -25 to +25 • they affect probability-of-spread parameter • Implementation: • create a local variable probability initially set to probability-of-spread parameter • creation by let, setting by set,
The pseudocode for all red patches ask their unborn neighbor trees - create and set probability to probability-of-spread - determine the direction - adjust the probability according to the dirction - determine whether the neighbor will burn or not if so -- set its color to red
Implementation • create and set probability to probability-of-spread: let probability probability-of-spread • determine the direction: compute the direction from you (the green tree) to the burning tree (NOTE: “myself” is the burning tree (the red patch) that asked youto execute commands) let direction towards myself
adjust the probability • if the burning tree is north of you • so the south wind impedes the fire spreading to you • so reduce the probability of spread ifdirection = 0 [ set probability probability - south-wind-speed ] burning tree myself you green tree
adjust the probability • if the burning tree is east of you • so the west wind impedes the fire spreading to you • so reduce the probability of spread ifdirection = 90 [ set probability probability - west-wind-speed ] you: green tree burning tree myself
adjust the probability • if the burning tree is south of you • so the south wind aids the fire spreading to you • so increase the probability of spread if (direction = 180 ) [ set probability probability + south-wind-speed ] you: green tree burning tree myself
adjust the probability • ifthe burning tree is west of you • so the west wind aids the fire spreading to you • so increase the probability of spread if direction = 270 [ set probability probability + west-wind-speed ] burning tree you
catch on fire • after determining the probability • set color of the tree just burning if random 100 < probability [ set pcolor red]
Explanation • modify the probability of spread • increase or decrease accordingly • for each neighnbor • first determine • which direction the fire is trying to spead • how wind effect the probability • with the updated probability • the fie will spread to the neighboring tree
New Predicates • towards • self/ / myself
self / myself • context: turtle or patch • "self" and "myself" are very different. "self" is simple; it means "me". "myself" means "the turtle or patch who asked me to do what I'm doing right now." • When an agent has been asked to run some code, using myself in that code reports the agent (turtle or patch) that did the asking. • myself is most often used in conjunction with of to read or set variables in the asking agent. • myself can be used within blocks of code not just in the ask command, but also hatch, sprout, of, with, all?, with-min, with-max, min-one-of, max-one-of, min-n-of, max-n-of.
Example - myself ask turtles [ ask patches in-radius 3 [ set pcolor [color] of myself ] ] ;; each turtle makes a colored "splotch" around itself
towards • towards ageent • context turtle or patch • Reports the heading from this agent to the given agent. • If wrapping is allowed by the topology and the wrapped distance (around the edges of the world) is shorter, towards will use the wrapped path. • Note: asking for the heading from an agent to itself, or an agent on the same location, will cause a runtime error.
Example - towards set heading towards turtle 1 ;; same as "face turtle 1"
Experimentation • set • density at %100 • let the wind blow strong from the south and west • set probability-of-spead fairly low arond %38 • triangular to northeast
Third Extension: Allow Long Distance Transmission • another effet of wind: enables fire to jump over long distances • add a switch to control jumping • in NetLogo – control boolean variables • add – big-jumps: on and off • off: reduced to Fire 2 Model • on: ingnate new fire at some distance in the direction of the wind
the code if random 100 < probability [ set pcolor red ;; if big jumps is on, then sparks can fly farther if big-jumps? [ let target patch-at ( west-wind-speed / 5 ) ( south-wind-speed / 5 ) if target != nobody and [pcolor] of target = green [ ask target [ set pcolor red ];; to ignite the target patch ] ;; end if target ] ;; end big-jump? ] ;; end random 100
if big-jumps? is true • it looks for a target patch some distance away in the direction of the wind • experiment with different parameters • observation: lines in the direction of wind Figure 3.7 • increases the probability of raaching the other end but reusting patterns are different with • chunks of world not burned • as new features are added modify the questions and the measures
Extensions • probablistic sparks or locations