Chapter 1 – Introduction to Computers, the Internet, and the Web

advertisement
MIS 585
Special Topics in IMS
Agent-Based Modeling
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-oranize”
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
o 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 p
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
– greeen: unburn tree
– red: burning tree
– brown: burned tree
– block: empty space
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
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
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) nonburning 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 propersly
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 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
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
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
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]
]
...
Experimentation
• Experiment with both probability-ofspread 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
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)
Initialization
• both form -25 to +25
• they affect probability-of-spread
parameter
• Implementation:
• create a local variable probability
initially set to probability-ofspread parameter
• creation by let, setting by set,
The pseudocode
for all red pathces
ask their unborn neighbor threes
- create and set probability to probability-ofspread
- 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
Implementation
• create and set probability to probability-ofspread:
let probability probability-ofspread
• 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
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 ]
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
if direction = 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
• 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 ]
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
• ask
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
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’
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
Outline
Intorduction
The Fire Model
The Diffusion-Limited Aggregation
(DLA) Model
The Segregation Model
The El Farol Model
Conclusion
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
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
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
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
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
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
setup
to 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-ticks
end
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
go
to 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
tick
end
New Predicatcates
• any?
• Exercise how would you do the same
thing without using any?
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
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
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
Slider
• Slider
• variable: probablity-of-sticking
– max value: 1.0
– min value: 0.0
– increment: 0.01
– default: 0.5
•
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
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
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
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
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
...
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
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
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
part of the setup
ask n-of num-seeds patches
[ set pcolor green ]
Observations
• selects exactly num-seeds initail
patches as seeds
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
Advanced Modeling
Applications
• AB Modeling straddles between
mathematics of fractiles
• See mathematics section
• fractiles subsection
Outline
Intorduction
The Fire Model
The Diffusion-Limited Aggregation (DLA)
Model
The Segregation Model
The El Farol Model
Conclusion
The Segregation Model
• Description of the Segregation Model
• First Extension: Adding Multiple
Ethnicities
• Second Extension:
• Third Extension:
• Summary of the Model
• Advenced Modeling Applications
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
• 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
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
Description of the Segregation
Model
• NetLogo version:
– Model Library > Simple Models > IABM
Textook > Chapter Three > Segregation
Extensions > Segregation Simple.nlogo
• Initialization
• Iterations
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
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
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
setup
to setup
clear-all
ask n-of number patches
[ sprout 1 ]
ask turtles [
set color one-of [red green]
]
update-variables
reset-ticks
end
update-variables
to update-variables
update-turtles
update-globals
end
Interface
• view:
– origin: center
– max-pxcor,max-pycor:25, wrapped
• Slider:
– variable: number
– nax: 2500
– min: 500
– default: 2000
updatre turtles
for 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? ...
update-turtles
to 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
updating globals
• calculate the following to be monitored
• calculate percentatage of similar neighbors
percent-similar:
• on the average, what percent of a turtle's
neighbors are the same color as that turtle?
• calculate percentage of unhappy turtles
percent-unhappy
• what percent of the turtles are unhappy?
update-globals
to update-globals
let similar-neighbors sum [similarnearby] 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
Variables
• globals:
percent-similar
percent-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
Variables
globals [
percent-similar
percent-unhappy
]
turtles-own [
happy?
similar-nearby
total-nearby
]
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
go
to go
if all? turtles [happy?] [
stop ]
move-unhappy-turtles
update-variables
tick
end
moving turtles
to 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
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
• other colors then red and green;
• blue, yellow and orange
• modify setup
set colors [red green yellow blue
orange]
• add globals
globals [
...
colors
]
• initilizes the global variable colors to be a
list of the fife colors
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
setup
• assign a color to each turtle from the
list of our colors
ask turtles [
set color (item (random
number-of-ethnicities)
colors)
]
• each turtle picks its color randomly form
the list, but up to the number-ofethnicities
New Predicate: item
item 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
=> 6
show item 3 "my-shoe"
=> "s"
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?
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:
turtles-own
turtles-own [
...
;; the threshold for this
particular turtle
my-%-similar-wanted
]
modifications
• Modify initialization:
• after assigning a color to each turtle
from the list of our colors
• assign an individual level of %-similarwanted
• Modify update turtles
• change the update-turtles code as
well
setup
ask turtles [
set color (item (random
number-of-ethnicities)
colors)
set my-%-similar-wanted
random %-similar-wanted
]
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
• percent similar monitor ends up with
lower values at the end of the runs
• logical,
• Some individuals are more tolorant to
other ethnicities
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
•
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 %differentwanted treshold.
Experimentation
• percent similar result decreases as all
agnets seeking diversity
• set of parameters the system never
settles down
– both %similar-wanted and %differentwanted over 50
• In general, longer time to reach
equilibrium.
Further Extensions
• 1 – make %different-wanted global
variable agent specific %my-differentwanted
• 2 – some agents sought only diversity
some others only similarity
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
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
Outline
Intorduction
The Fire Model
The Diffusion-Limited Aggregation (DLA)
Model
The Segregation Model
The El Farol Model
Conclusion
The El Farol Model
•
•
•
•
•
•
Description of the Model
First Extension:
Second Extension:
Third Extension:
Summary of the Model
Advenced Modeling Applications
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
Description of the El Farol
Model
• B. Artur
• El Farol bounded rationality and
inductive reasoning
• neoclasical economics – perfect
rationality
• 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
• no mater what strategy agents apply
• average bar population is 60
• Even not have perfect information find
the optimal solution
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
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-own
turtles-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
]
• Initilize revord to 0
• modify setup
create-turtles 100 [
set color white
move-to-empty-one-of home-patches
set strategies n-values numberstrategies [random-strategy]
set best-strategy first strategies
set reward 0
update-strategies
]
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
]
]
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 beststrategy sublist history 0 memory-size
set attend? (prediction <= overcrowdingthreshold) ;; 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
]
•
•
•
•
•
•
•
•
•
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
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
Explorations
• as time progress, both average and
max rewords increases but max
increases more so some agents are
doing better then others
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 commands
set-plot-y-renge 0 1
set-plot-x-range 0 (max [reward]
or turtles + 1)
Explorations
•
•
•
•
run the model severa times
first normal distribution
then some agents with high rewards
so on they are performing better than
the average.
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
Further Extensions
• Why some agnets are doing well?
• Investigate strategies
• Do they change strategies more often
then the average performing agen?
Advanced Modeling
Applications
• El Farol – ABM and machine learning
• agent chang strategies over time
• Minority game
– financial markets
– Santa Fe Stcok Market model
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
Outline
Intorduction
The Fire Model
The Diffusion-Limited Aggregation (DLA)
Model
The Segregation Model
The El Farol Model
Conclusion
Conclusion
• How to extend models in different ways
• How to explore how the models are
related to key concepts of ABM
Download