Agent-Based Modeling
and Simulation
(ABMS)
Bertan Badur
badur@boun.edu.tr
Department of
Management Information Systems
Boğaziçi University
The Business Investor Model
• Chapter 10, 11, 12 of Agent-Based and IndividualBased Modeling: A Practical Introduction, by S.
F. Railsback and V. Grimm
• NetLogo User Menual
Outline
•
10.4 Putting Sensing to Work: The Business
Investor Model
The Business Investor Model
• What information agents have and how they get it
• Model:
– How people decide what business to invest in.
• Businesses differ
– annual profit
– risk of failure – the investor loses its all wealth
• Pathces – business alternatives
• Turtles – investors
– sence neigbor businesses
The ODD Description
• No cost of entering or switching
Entities, State Variables, and States
• Entities:
– investor agents (tutrtles)
– businesses (patches) with profits and risk
• State variables:
– inverstors – location, wealth (money units)
– businesses –
• annual profit (P) (money per year)
• probability of failure (F) per year – loses all wealth
• Lanscape - 19x19 no wrapping
• Time scale – ticks every year, 25 years
•
Process Wverwiew and Scheduling
• in each time step actions executed in the orders:
• Investor repositioning:
–
–
–
–
–
look at their neighbnoring businesses
if they have better profit risk trade off
move to that business
only one agent at a patch
in random order
• Accounting:
– update wealth: previous + current profit
–
if business fails wealth becomes zero
• Output:
– The world display plots and an output file is updated
ODD – Design Concepts
•
•
•
•
•
Basic principles
emergence
adaptive behavior
objetive
U = (W + Th*P)(1 - F)Th
–
–
–
–
•
•
•
•
•
W current welth
Th time horizon
P profit of patch
F faling rate of patch
prediction
sensing
interraaction
stochasticity
observation
globals [n-inv th mean-w std-w one-up-std onedown-std count-f]
turtles-own [w]
patches-own [p f]
to setup
ca
set n-inv 150
set th 5
crt n-inv
[
move-to one-of patches with [not any? turtleshere]
]
ask patches
[
set p (random-float 9000) + 1000
set f (random-float 0.09) + 0.01
]
reset-ticks
end
to go
tick
set count-f 0
ask turtles [
inv-repos
acc-w
]
set mean-w mean [w] of turtles
set std-w standard-deviation [w] of turtles
set one-up-std mean-w + std-w
set one-down-std mean-w - std-w
; plot mean-w
; plot one-down-std
; plot one-up-std
output-print (word ticks" " mean-w " "count-f)
if ticks = 25 [stop]
end
to go
tick
ask turtles [
inv-repos
acc-w
]
if ticks = 25 [stop]
end
inv-repos and utility-for
to inv-repos
let po-patchs (patch-set patch-here neighbors with [not any? turtleshere])
if any? po-patches [
let best-patch max-one-of po-patchs [utility-for myself]
move-to best-patch
]
end
to-report utility-for [t]
let cw [w] of t
let u (cw + th * p ) * (1 - f) ^ th
report u
end
acc-w
to acc-w
ifelse random-float 1.0 < f
[ set w 0
set count-f count-f + 1
]
[set w w + p]
end
observationoutput
• add to the go procedure
• add globlas and initilize in setup
set mean-w mean [w] of turtles
set std-w standard-deviation [w] of turtles
set one-up-std mean-w + std-w
set one-down-std mean-w - std-w
;in the intrface
; plot mean-w
; plot one-down-std
; plot one-up-std
output-print (word ticks" " mean-w " "count-f)
sensing radius
• add a variable sensing radius
– s-r with a slider
to inv-repos
let po-patchs (patch-set patch-here patches inradius s-r with [not any? turtles-here])
let best-patch max-one-of po-patchs [utility-for
myself]
move-to best-patch
end
Networks
set n-of-links 5
crt n-inv
[
move-to one-of patches with [not any? turtleshere]
create-links-to n-of n-of-links other turtles
]
modify positioning
to inv-repos
let po-patchs (patch-set patch-here neighbors with [not any?
turtles-here])
set po-patchs (patch-set (po-patchs) ( [neighbors with [not
any? turtles-here]]
of out-link-neighbors))
let best-patch max-one-of po-patchs [utility-for myself]
move-to best-patch
end
Chpater 11: Adaptive Bevavior and
Objectives
1. Introduction and Objectives
• Most important reason - ABM:
• How system behavior is effected from adaptive
bahvior of its individual agents
– how agents make decisions
– change their states effected from environments and themselfs
• Adaptation
– decision to changes in environment
• Objectives
• agent behavior – something an agent does
• systems behavior – dynamics of the system of
agents
• traits – rules given to agents about how to behave
• adaptive behavior – decision made to improve
their states with respect to an objective
– implicit or explicit
• adaptive trait - rules for adaptive behaior
• theory – adaptive traits to be tested
Objectives
• The objective adaptive behavior
– fitness – ecology – organizms -increase probablity of
offsprings
– utility – economics
• objective function
– explicit measure of agents fitness or utility
• Set of alternatives – evaluted by objective function
• trade-offs
– one objective increasing the other decreasing
• more profit – more risk
• increase proift avoid risk
• more food – more chance of eaten by others
Learning Objectives
• Subseting agentsets in NetLogo
• design and analysis of experiments for adaptive
trifts
• modeling trade-off decision.
– maximizing an objective function and satisficing
Identifying and Optimizing Alternatives in
NetLogo
• adaptive traits.
–
–
–
–
identifying alternatives
eliminating infeasible alternatives
evaluating feasible alternatives – objective function
selecting best alternative – maximizing objective
• In NetLogo – alternatives as agents
– patches – turtles to move to
– turtles for interacting
– links to follow
Identifying Decision Alternatives by
Subseting NotLogo Agentsegts
•
•
•
•
•
Start with agentsets
turtles decision move to a patch
the agentset – patches – set of all alternatives
neighbors – moving to neighboring pathces
other alternatives:
– turtles, links – all turtles or links
– turtles-here, turtles-at, turtles-on – turtles on specific pathces
– link-neighbors, in-link-neighbors- out-link-neighbors – tutles
at other end of the calling turtle’s links
•
• other
– all but the agent executing the statement
• in-radius, in-cone
– agents with in a specified distance or distance and angle
• let destination-pathces patches in-radius 3
• Creating a new agentset –
– not new agents but
– references to existing agents
• with-max, max-n-of, with-min:
– evaluate a reporter chose the agnets maximizing the value of
teh reporters
• let furtune-50 max-n-of 50 turtles [net-worth]
with
let potential-mates other turtles with [age > 20]
set potential-mates potential-mates with [sex !=
[sex] of mayself ]
set potential-mates potential-mates with [ not
maried? ]
• or
let potential-mates other turtles with [age > 20 and
sex != [sex] of mayself and
not maried? ]
Optimize and Objective Function
• max-one-of, min-one-of
– reprots an agent
– in case of a tie select one randomlay
• with-max, with-min
– all agents as an agentset
• Do the NetLogo Brainteasers
Adaptive Behavior in the Business Inverstor
Model
• Experiments in BehaviorSpace
• new variables
– profit-multiplier - from 0.5 to 1.0
– risk-multiplier – from 1.0 to 2.0
• 10 replications
• Plots
– mean final invertor weath v.s. profit mutiples of baseline
– mean anual profit v.s. profit mulitples of baseline
• see figure 11.1
– mean final invertor weath v.s. risk mutiples of baseline
– mean anual profit v.s. risk mulitples of baseline
• see figure 11.2
Non Optimizing Adaptive Traits: A
Satisficing Example
•
•
•
•
In practice – not optimization
satisficing – finding alternatives good enough
Not observe profits or risks of
Decision
– change more frequently – objective not met well
– change less frequently –
• compare objective fuction with atreshold value
• investors can only observe current projects profit
and risk values
• compare expected anula change in expected welth
with a treshold value
– riskles rate of investments - 5&
• w-i-tr in globlas set its vaue in setup
• or add a slider
reposition turtles
to inv-repos
if w-i-r < w-i-tr
[
let po-patchs neighbors with [not
any? turtles-here]
if any? po-patchs
[
move-to one-of po-patchs ]
]
end
reoprt rate of change of welth
to-report w-i-r ; reports rate of change of expected
welth
if w = 0 [ set w 1 ]
let u (w + th * p ) * (1 - f) ^ th
let wir (u - w) / (w * th)
report wir
end
The Objective Function
• In the Business Invertor model
• some projects have negative profit
– profit drawn from a uniform dist -5000 to10000
• If investor’s weath fall below 0
– set it to zero
• if expected value at the end of time horizon is
negative
– set it to zero
• count failing projects due to
– negative profit
– random failure
Other Objective Functions
• First
– in the baseline model
• Second
– ignore risk – based on only profit
• Third
– ignore profit
– only risk of failure or negagtive profits
Chapter 12: Prediction
1. Introduction and Objectives
• Fondomental to many decisions
– anticipate consequences of alternatives
• prediction – by itself a model
• modeling how the agent models
• Holland (1995) – tacit prediction
– hidden assupmptions
• explicit prediction
– Business Invertor model – calculates expected value of projects
•
•
•
•
What predictions are esential?
How to model them
Modelingpredictions
How different predictions affect outcomes of AMBs
Learning Objectivesw
•
•
•
•
effect of diferent predictions on outcomes
submodel analysis
counter plots
Bayesian updating
2 Effect of Prediction: BusinessInvesgtor
Model Time Horizon
• What is the effect of time horizon on invertors
welth;?
• BehaviorSpace
– mean anual profit v.s. time horizon
– meqn final wealth v.s. time horizon
3 Implementing and Analysing Submodels
•
•
•
•
•
submodels – processes
designing, testing nad analizing seperately
Analyze expected utility
utility function of profit and failure rate
coutour plots of expected welth v.s. profit and risk
4. Analizing the Investor Untilityh Function
•
•
•
•
profit and risk changes
how expected welth varies
parameters time horizon and current welth
Take total derivatie of utility with respect to profit
and risk
• equate to zero
5. Modeling Prediction Explicitly
• Estimating risk of patches from historical data
– from overall failure rates – mean rate of failure
– from historcal data of the patch
•
•
•
•
<Bayesian statistics
priaory of a binomial parameter – beta distribution
Guessing overall failure rate
Start with mean variance of overall failure rate
– mean : 0.5
– varince (0.1-0.01)2/12 0.007