135
MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Embed Size (px)

Citation preview

Page 1: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

MIS 585

Special Topics in IMS

Agent-Based ModelingChapter 3:

Exploring and Extedning

Agent-Based Models

Page 2: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Outline

IntorductionThe Fire ModelThe Diffusion-Limited Aggregation

(DLA) ModelThe Segregation ModelThe El Farol ModelConclusion

Page 3: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Introduction

• This chapter is based on• IABM-WR: Chapter 3

Page 4: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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-oranize” without any leader organizer

• 4 – Different models emphasize different aspects of the world

Page 5: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 o fire form tree to tree• interesting things to say about how

likely a fire is sepead all over the forest

Page 6: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 7: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Rule 3

• flock of bird - no leader bird or organizer abut how to fly

• self-organize without a leader

Page 8: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 9: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Outline

IntorductionThe Fire ModelThe Diffusion-Limited Aggregation

(DLA) ModelThe Segregation ModelThe El Farol ModelConclusion

Page 10: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 11: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 p

Page 12: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Tipping Point

• know where tipping point is and where you are

Page 13: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Description of the Fire Model

• percolation:• in 1987, Denish physisists and

complex systems theoritst, Per Bak• self-oganizing criticallity

Page 14: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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– greeen: unburn tree– red: burning tree– brown: burned tree– block: empty space

Page 15: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

A Simple Fire Model (cont.)

• when setup– Left edeg 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 pacth is

a tree

Page 16: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 17: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

setupglobals [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-ticksend

Page 18: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Exercises

• Different initializations of trees• Inililize always fixed number of

trees• Find other ways of initialization of

threes and burning trees

Page 19: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

iterations

• ask the burning trees to set fire to any neighboring (four neithbors) non-burning trees

Page 20: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

go

to go

ask patches with [pcolor = red] [

ask neighbors4 with [pcolor = green] [

set pcolor red

]

]

tick

end

Page 21: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Stoping Condition

• iterations stop when all trees are burned

if all? patches [pcolor != red]

[stop]• i

Page 22: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

final go procedureto 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 ] tickend

Page 23: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Reporter

• write a reporter to return trees fireing

• and use the reporter propersly

Page 24: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Reporter

to report fire-trees

return patches with [pcolor = red]

end• change go fromask patches with [pcolor = red]• toask fire-trees

Page 25: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Monitoring percentage of burend trees

• Add a moitor to the interface to see the percentages of trees bured

• Add a moitor • to the reporter:(count patches with [shade-of? pcolor red]) / initial-trees * 100

Page 26: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 silite change in input parameter

has a large effect on output

Page 27: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

First Extension: Probablistic Transitions

• Many simplifying assumptions:• fire does not spread

deterministically• but many factors:

– wind, wood type, how close the branches are

• not certaion - with a proabability• Change the go procedure so that a

burning tree ignates fire to its neighbor with a probability

Page 28: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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] ]...

Page 29: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 30: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Second Extension: Adding Wind

• wind: – increases the chance of fire spread in

the directio 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)

Page 31: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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,

Page 32: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

The pseudocodefor all red pathces ask their unborn neighbor threes - create and set probability to

probability-of-spread - determine the direction - adjust the probability according to the

diection - determine whether the neighbor will

burn or not if so -- set its color to red

Page 33: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 you to execute commands)

let direction towards myself

Page 34: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 if direction = 0 [

set probability probability - south-wind-speed ]

you green tree

burning tree myself

Page 35: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 spreadif direction = 90 [

set probability probability - west-wind-speed ]

burning tree myself

you: green tree

Page 36: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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 ]

burning tree myself

you: green tree

Page 37: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

adjust the probability

• if the 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 ]

you

burning tree

Page 38: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

catch on fire

• after determining the probability• set color of the tree just burningif random 100 < probability

[ set pcolor red ]

Page 39: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 40: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

New Predicates

• towards• ask

Page 41: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 42: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 43: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

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

Page 44: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• 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

Page 45: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Extensions

• probablistic sparks or locations

Page 46: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Summary of the Fire Model• three change to the basic model • affecting tipping point in different

ways• as model assumptions or mechnizms

change new measurse msy be needed

• in Extension 3 – whether the file will move to right edge

mey not be a good measure• Tipping points:

– characteristics of inputs and outputs– not the models’

Page 47: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Advanced Modeling Applications

• generalized into model of a percolation:

• Given a structure with probablistic transitions between locations

• how likely that an new entity diffuses form one side to another

• E.g.: – innovation diffusion– spread of diseases – epidemiology

Page 48: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Outline

IntorductionThe Fire ModelThe Diffusion-Limited

Aggregation (DLA) ModelThe Segregation ModelThe El Farol ModelConclusion

Page 49: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

The Diffusion-Limit Aggregation (DLA) Model

• Description of the Diffusion-Limit Aggregation (DAL) Model

• First Extension: Probablistic Sticking• Second Extension: Neighbor

Influence• Third Extension: Different

Aggregates• Summary of the DAL Model• Advenced Modeling Applications

Page 50: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Intorduction• in ABMs no direct relation between

– complexity of resulting pattern and– complexity of the uderlying rules

• simple rules may create complex pattrns

• focus not on complex rules but on interractions

• ABMs are interesting:– not because what each agent does– what tghe agents do together

Page 51: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

A very simple model

• what agents does – move randomly around the world

• and stop moving when a basic condition is met

• simple rules complex patterns may emerge

Page 52: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Discription of the DAL Model

• In many physical processes– creation of clouds to snowflakes, dust and

smoke

• particles aggregate interesting ways• DAL: an idealization of this process• Witten & Sander 1981, 1983• generate patterns found in nature

– cristals, foral, fungi, growth of human lungs

• social patterns– growth of cities

Page 53: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

DLA NetLogo Model

• Starts with – many red particles– a green patch at the center

• iterations - GO forever– all particles more randomly “wigging” left

and right by a small random turns – and forward one unit– if any of its neighbors green– turn the patch its is on green and dies

• fractile like patterns formed by patches

Page 54: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Initialization• Setting the world:

– origine: center– max-pcor 100, max 100.– wrapping on– patch size 1

• number of particles– slider variable: num-particles– size 1.5, color: red– uniformly distributed around the world

• one patch at center with color green

Page 55: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

setupto setup clear-all ask patch 0 0 [ set pcolor green ] create-turtles num-particles [ set color red set size 1.5 setxy random-xcor random-ycor

] reset-ticksend

Page 56: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

iterations

• wiggle-angle– slider – varibale: 0 – 100 – default 60

• ask each particle;; • turn a random amount right and

left• move one unit forward• if you are touching a green patch,

turn your own patch green and then die

Page 57: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

goto go ask turtles [ right random wiggle-angle left random wiggle-angle forward 1 if any? neighbors with [pcolor = green]

[ set pcolor green die ] ;; end if ] ;;end ask tickend

Page 58: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

New Predicatcates

• any?• Exercise how would you do the

same thing without using any?

Page 59: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

First Extension: Probablistic Sticking

• if a particle comes to contact with a stationary object with certainity it becomes stationary

• control the probablity of a particle becoming stationary

Page 60: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

proablistic stoping

• since stopping is probablistic• a particle may be on top of another

green patch – we do not want to stop

• stop with a probability only when• on a black patch and one of the

neighbors are green• in simple version because

movemnt is forward by 1 unit it is not needed

Page 61: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

part of go

if ( pcolor = black )

and ( any? neighbors with [pcolor = green] )

and ( random-float 1.0 < probability-of-sticking )

[ set pcolor green

die

] ;; end if

Page 62: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Slider

• Slider• variable: probablity-of-sticking– max value: 1.0– min value: 0.0– increment: 0.01– default: 0.5

Page 63: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Experimentation

• Experiment with different probabilities

• as probability of sticking goes to 1• simple model

– thiner branches as prob 1.0

• as prob 0.0 thicker strucutral branches

Page 64: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Second Extension: Neighbor Influence

• how probability of sticking is related to number of neighbors that are already stationary

• if a particle is moving • it is more likely to stick if

– two or three neighbors are stationary

– then only one

Page 65: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

The problem• add a switch to the interface

– variable: neighbor-influence?– boolean variable. true or false– convension end with ? to inform

programmers

• Modify probablity of sticking– define local-prob

• if neighbor-influence? is off– the same: no neighbor effect

• if on: mulitply by fraction of green neighbors

Page 66: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

pseudeocode

• declare and initiize local-prob• if neighbor-influence is TRUE then

make the probability proportionate to the number of green neighbors, otherwise use the original value

in other word; increase the probability of sticking the more green neighbors there are

• modify the stopping condition

Page 67: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

part of the go... forward 1 let local-prob probability-of-sticking if neighbor-influence? [ set local-prob probability-of-sticking * (count neighbors with [ pcolor = green ] / 8) ] ;; end if neighbor-influeince if (pcolor = black) and ( any? neighbors with [pcolor = green] ) and ( random-float 1.0 < local-prob ) [ set pcolor green die ] ;; end if] ;; end ask...

Page 68: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Experimentation

• 1 - it takes much longer to form structures as there is a lower problity of a moving particle stopping

• 2 – the structure is very tick and almost bloblike

• 3 – many one patch-wide branches

Page 69: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Third Extension: Different Aggregates

• Start with a fixed user determined number of seeds

• set a set of randomly selected patches to green

• not neccesarily at the center

Page 70: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Initialization

• Start with a user determined number of seed

• Give number of seeds from a silder• Insert a silder to the interface

– variable: num-seeds– nin value: 1– max value: 10– increment: 1– default: 10

Page 71: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

part of the setup

ask n-of num-seeds patches [ set pcolor green ]

Page 72: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Observations

• selects exactly num-seeds initail patches as seeds

Page 73: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Summary of the DLA Model

• Three versions of the DLA model• simple rules complex patterns• first two extensions:

– particles decide when to stop– patterns – thicker and more

substantial

• third extension:– starting from multiple seeds

Page 74: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Advanced Modeling Applications

• AB Modeling straddles between mathematics of fractiles

• See mathematics section • fractiles subsection

Page 75: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Outline

IntorductionThe Fire ModelThe Diffusion-Limited Aggregation

(DLA) ModelThe Segregation ModelThe El Farol ModelConclusion

Page 76: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

The Segregation Model

• Description of the Segregation Model

• First Extension: Adding Multiple Ethnicities

• Second Extension: • Third Extension:• Summary of the Model• Advenced Modeling Applications

Page 77: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Introduction• two approaches to ABM• 1 – common in science start with a

known phenomenon• phenomenon-based modeling• aggregate pattern – reference

pattern• generate with agent rules• 2 – start with simple rules• to see what patterns develop• explaratory modeling• combination of them

Page 78: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• for high levels of the treshold:– the model predicts the conferamtion– checkerboard is seregated into areas of all

pennies and all dimes• surprise • for low levels of the treshold:

– pennies and dimes are clustered– global segregation occured dispied the

relative toleranc of individuals• There was no single individual in the

model who wanted segregated neighborhood

• but the group as a whole moved segregation

• macrobehavior from micromotives

Page 79: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Controversial• 1 – belived that housing segreagation is

due to individuals being prejudicate– prejiduce itself is not the cause of segregation, – emergent effect of aggregation of weak

predijuse

• to reduce housing segregation – not reduce predicuse

• 2 – people behavior with simple rules– critics: hummans have complex cognition and

social arrangements

• Oversimplifed model of people’s housing choice but it revels an unknown dynamics

Page 80: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Description of the Segregation Model

• NetLogo version:– Model Library > Simple Models >

IABM Textook > Chapter Three > Segregation Extensions > Segregation Simple.nlogo

• Initialization• Iterations

Page 81: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Initialization

• apporximately equal number of red and green turtles are distributed evenly around the world

• each turtle defermines wheter it is happy or not, depending on its neighbors of the same color with itself exceeds the %-similar-wanted treshold or not

Page 82: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

iterations

• check whether there are unhappy turtles

• any unhappy turtle moves to a new location– turning a rondom amaout– moving forward by a random

amaount from 0 to 10– if not occupied, settels their– if this location is occupied oves again

Page 83: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

setup: algorithm

• create a turtle on NUMBER randomly selected patches.

• note that slider's maximum value is 2500 which is a little less than the total number of patches

• make approximately half the turtles red and the other half green

Page 84: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

setupto setup clear-all ask n-of number patches [ sprout 1 ] ask turtles [ set color one-of [red green] ]

update-variables reset-ticksend

Page 85: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

update-variables

to update-variables

update-turtles

update-globals

end

Page 86: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Interface

• view:– origin: center– max-pxcor,max-pycor:25, wrapped

• Slider: – variable: number– nax: 2500– min: 500– default: 2000

Page 87: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

updatre turtlesfor each turtle use More neighborhood: count the number of my neighbors that

are the same color as me set similar-nearby... count the total number of neighbors set total-nearby ... I’m happy if there are at least the

minimal number of same-colored neighbors

set happy? ...

Page 88: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

update-turtlesto update-turtles ask turtles [ set similar-nearby count (turtles-on neighbors)

with [color = [color] of myself] set total-nearby count (turtles-on neighbors)

set happy? similar-nearby >= ( %-similar-wanted * total-nearby / 100 )

]end

Page 89: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

updating globals• calculate the following to be monitored• calculate percentatage of similar

neighborspercent-similar: • on the average, what percent of a

turtle's neighbors are the same color as that turtle?

• calculate percentage of unhappy turtlespercent-unhappy• what percent of the turtles are

unhappy?

Page 90: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

update-globalsto update-globals

let similar-neighbors sum [similar-nearby] of turtles

let total-neighbors sum [total-nearby] of turtles

set percent-similar (similar-neighbors / total-neighbors) * 100

set percent-unhappy (count turtles with [not happy?]) / (count turtles) * 100

end

Page 91: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Variables• globals:percent-similarpercent-unhappy

• turtles:happy?:• for each turtle, indicates whether at least %-similar-

wanted percent of that turtles' neighbors are the same color as the turtle

similar-nearby: • how many neighboring patches have a turtle with my

color?total-nearby: • sum of previous two variables

Page 92: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Variables

globals [

percent-similar

percent-unhappy

]

turtles-own [

happy?

similar-nearby

total-nearby

]

Page 93: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Interface tab • plot:

– name: percent similar– x-label: time, y-label: %– pen update: plot percent-similar

• plot:– name: percent unhappy– x-label: time, y-label: %– pen update: plot percent-unhappy

• monitors for percent-similar and percent-unhappy variables

Page 94: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

go

to go

if all? turtles [happy?] [ stop ]

move-unhappy-turtles

update-variables

tick

end

Page 95: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

moving turtlesto move-unhappy-turtles ask turtles with [ not happy? ] [ find-new-spot ]end

to find-new-spot rt random-float 360 fd random-float 10 if any? other turtles-here [ find-new-spot ] ;; keep going until we find an unoccupied patch

setxy pxcor pycor ;; move to center of patch

end

Page 96: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

First Extension: Adding Multiple Ethnicities

• add a third, forth or even the fifth ethnicity

• modify the setup• originally

– makes all turtles red– ask half ot them to be green

• l

Page 97: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• other colors then red and green;• blue, yellow and orange• modify setup set colors [red green yellow blue orange]

• add globalsglobals [ ... colors]• initilizes the global variable colors to

be a list of the fife colors

Page 98: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Interface Tab

• allow the user to control number of ethnicities in the model

• add a slider– variable: number-of-ethnicities

• set bound from 2 to 5

Page 99: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

setup• assign a color to each turtle from

the list of our colorsask turtles [ set color (item (random number-of-ethnicities) colors)

] • each turtle picks its color randomly

form the list, but up to the number-of-ethnicities

Page 100: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

New Predicate: itemitem index list item index string• On lists, reports the value of the item in the

given list with the given index.• On strings, reports the character in the given

string at the given index• Note that the indices begin from 0, not 1. (The

first item is item 0, the second item is item 1, and so on.)

;; suppose mylist is [2 4 6 8 10]show item 2 mylist=> 6show item 3 "my-shoe"=> "s"

Page 101: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Explorations

• run the model with different number of ethnicities

• much longer to settel• however once setteled • percents similar displaid is

independnet of the number of ethnicities

• Why?

Page 102: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Second Extension: Allowing Diverse Tresholds

• Original model – every agent has the same similarity treshold– same level of tolerence to other

ethnicities in their neighborhood

• it is likely that different individuals has different levels of tolerance

• modify turtles-own:

Page 103: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

turtles-own

turtles-own [

...

;; the threshold for this particular turtle

my-%-similar-wanted

]

Page 104: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

modifications

• Modify initialization:• after assigning a color to each

turtle from the list of our colors• assign an individual level of %-

similar-wanted• Modify update turtles• change the update-turtles code

as well

Page 105: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

setup

ask turtles [

set color (item (random number-of-ethnicities) colors)

set my-%-similar-wanted random %-similar-wanted

]

Page 106: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

update turtles

to update-turtles ... ;; I’m happy if there are at least the minimal number of same-colored neighbors

set happy? similar-nearby >= ( my-%-similar-wanted * total-nearby / 100 )

]end

Page 107: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• percent similar monitor ends up with lower values at the end of the runs

• logical,• Some individuals are more tolorant

to other ethnicities

Page 108: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Third Extension: Adding Diversity-Seeking Individuals

• simplifying assumpltion:– individuals concent about too much

diversity

• individuals seeking some diversity in their neighborhood

• add %wdifferent-wanted propertiy just like %simlar-wanted

Page 109: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Modifications

• Create a %different-wanted slider• modify the update-turtle

procedure:• agents are happy only when the

number of similar agents nearby is greater than the %similar-wanted treshold and number of other agents nearby is greater than the %different-wanted treshold.

Page 110: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Experimentation

• percent similar result decreases as all agnets seeking diversity

• set of parameters the system never settles down– both %similar-wanted and %different-

wanted over 50

• In general, longer time to reach equilibrium.

Page 111: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Further Extensions

• 1 – make %different-wanted global variable agent specific %my-different-wanted

• 2 – some agents sought only diversity some others only similarity

Page 112: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Summary of the Segregation Model

• Different models emphisize different aspects of the world.

• Schling assumptions about peoples preferences and behavior.

• first extension: multiplicity of ethicities• second extension: from uniform agents

to heterogonous agents with different tresholds– individual differences and diversity

• Third extension: agents also seeking out diversity

Page 113: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Advanced Urban Modeling Applications

• Urban modeling systems– “residential preference” modles

• Integrated model of a city– commercial, industrial and governmental

models of urban policy

• E.g.:– CITIES Project: Center of Connected

Learning and Computer Modeling at Northwestern University

• Another goal of urban modeling:– ecological impact of cities and their

footprint on the environment.. E.g.: SLUCE Project at the University of Michigan

Page 114: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Outline

IntorductionThe Fire ModelThe Diffusion-Limited Aggregation

(DLA) ModelThe Segregation ModelThe El Farol ModelConclusion

Page 115: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

The El Farol Model

• Description of the Model• First Extension:• Second Extension:• Third Extension:• Summary of the Model• Advenced Modeling Applications

Page 116: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Introduction

• Add new reporters and monitors to collect data from an existing model

• You do not need to understand every part of a model to work with it

• El Farol model: list, regression• looking info tab

Page 117: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Description of the El Farol Model

• B. Artur• El Farol bounded rationality and

inductive reasoning• neoclasical economics – perfect

rationality

Page 118: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• El Farol bar• 100 total researchers lke Irish music• if they thougth it is crowded people

do not go– predict more then 60 people there

• assume attendence is publicly available

• but each agent has a limited memory• Each agent has a strategy

Page 119: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• no mater what strategy agents apply

• average bar population is 60• Even not have perfect information

find the optimal solution

Page 120: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Controls

• memory size: how many weeks of atendence they can remember

• number-strategies: number of strategies in his bag

• overcrowding-treshold: number of agent that make the bar crowded

Page 121: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

First Extension: Color Agents That Are More Succeswful Predictors

• Each agent to keep track of• how often they go the the bar when it is

not crowded• Add a propertiy to agents: reword• update turtles-ownturtles-own [ strategies ;; list of strategies best-strategy ;; index of the current best

strategy attend? ;; true if the agent currently plans to

attend the bar prediction ;; current prediction of the bar

attendance reward ;; the amount that each agent

has been rewarded]

Page 122: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• Initilize revord to 0• modify setup create-turtles 100 [

set color white

move-to-empty-one-of home-patches

set strategies n-values number-strategies [random-strategy]

set best-strategy first strategies

set reward 0

update-strategies

]

Page 123: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

modify go• update reward whenever agent goes to the bar

and it is not crowded• go procedure form if attendance > overcrowding-threshold [ ask crowded-patch [ set plabel "CROWDED" ] ]• to ifelse attendance > overcrowding-threshold [ ask crowded-patch [ set plabel "CROWDED" ] ] [ ask turtles with [ attend? ] [ set reward reward + 1 ] ]

Page 124: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

modifications• visualization to display reword

appropriately• give different colors proportional to its

reword• relative to the maximum reword• update each agents color ask turtles [ set prediction predict-attendance best-

strategy sublist history 0 memory-size set attend? (prediction <= overcrowding-

threshold) ;; true or false ;; scale the turtle's color a shade of red

depending on its reward level (white for little reward, black for high reward)

set color scale-color red reward (max [ reward ] of turtles + 1) 0

]

Page 125: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

• scale-color four parameters• 1 – base color• 2 – the variable linked to color – reward• 3 – first range value – a bit higher then

naximum reward• 4 – second range value – 0• if the first range value is less then the second

one then• the larger the linked variable the ligther the

color • if the second range value is less then the first

one then• the larger the linked variable the darker the

color

Page 126: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Second Extension: Average, Min and Max Rewords

• Adding monitors to get statistics of variables

• Monitors for reward• Monitor:

– name: Max Reward– reporter area: max [reward] or turtles

• Monitor:– name: Min Reward– reporter area: min [reward] or turtles

• Monitor:– name: Avg. Reward– reporter area: mean [reward] or turtles

Page 127: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Explorations

• as time progress, both average and max rewords increases but max increases more so some agents are doing better then others

Page 128: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Third Extension: Histogram Rework Values

• Create a new plot– name: Reward Distribution– mode of the pen: “bar”– pen update commands: histogram [reward] or turtles– plot setup commandsset-plot-y-renge 0 1

set-plot-x-range 0 (max [reward] or turtles + 1)

Page 129: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Explorations

• run the model severa times• first normal distribution• then some agents with high

rewards• so on they are performing better

than the average.

Page 130: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Summary of the El Farol Model

• Modify a model so that it provides more information then the original one

• first extension: visualization of success of agents

• second exension: statistics with some monitors; max, min, agerage rewards

• third extension: histogram of the data. Richer understanding

Page 131: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Further Extensions

• Why some agnets are doing well?• Investigate strategies• Do they change strategies more

often then the average performing agen?

Page 132: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Advanced Modeling Applications

• El Farol – ABM and machine learning

• agent chang strategies over time• Minority game

– financial markets– Santa Fe Stcok Market model

Page 133: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Extending models

• deterministic rules to probablistic rules

• new mechnisms that generate probablities– add different metrics

• different straring and stopping conditions

• global parameters to individual agents making agents heterogonous– parameters and new rules

Page 134: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Outline

IntorductionThe Fire ModelThe Diffusion-Limited Aggregation

(DLA) ModelThe Segregation ModelThe El Farol ModelConclusion

Page 135: MIS 585 Special Topics in IMS Agent-Based Modeling Chapter 3: Exploring and Extedning Agent-Based Models

Conclusion

• How to extend models in different ways

• How to explore how the models are related to key concepts of ABM