Upload
others
View
28
Download
0
Embed Size (px)
Citation preview
© The AnyLogic Company | www.anylogic.com
Agent based modelingDr. Andrei BorshchevCEO, The AnyLogic [email protected]
Sydney, February 2013
© The AnyLogic Company | www.anylogic.com 2
?
Modeling
The solutionThe problem
The model The solution at the model level
The real world
The world of models
RISK-FREE SPACE
© The AnyLogic Company | www.anylogic.com 3
Types of models
Boxes connected with lines
Formulas of a sheet of paperSimulation models
Excel spreadsheets
Mental models Physical models
© The AnyLogic Company | www.anylogic.com 4
A simulation model
• This is an “executable” model A set of rules that allow us to obtain the next state of the system in
time from the current state
• The model produces the trajectory of the system in time Outputs are “observed” as we move
Inputs
X1
X2
X3
X4
Y1
Y2
Y3
Y4
SimulationModel
© The AnyLogic Company | www.anylogic.com 5
The three methods in simulation modeling
• The three modeling methods are the three different viewpoints …the modeler can take when mapping the real world system to its
image in the world of models
Low abstraction level[maximum details
Micro levelOperational level]
High abstraction level[minimum details
macro levelstrategic level]
Aggregates, global feedback loops, influences, trends…
Medium abstraction level
[medium detailsmeso level
tactical level]
Individual objects, exact sizes, velocities, distances, timing…
Discrete Event(process based)
Modeling
SystemDynamics
Agent BasedModeling
© The AnyLogic Company | www.anylogic.com 6
System Dynamics (J. Forrester, 1950s)
• Bass diffusion model Diffusion of a new product, innovation, or idea
Potentialclients Clients
Sales
Sales fromAdvertizing
+
Salesfrom Word of
Mouth
+
Advertizingeffectiveness
+
+
B
AdoptionFraction
ContactRate
+
+ ++
B
R
© The AnyLogic Company | www.anylogic.com 7
Discrete event modeling (G. Gordon 1960s)
• Entities and resources. Flowchart diagram Queues and delays
Bank
[resources]
[queue+service]
[entities]
[source] [decision]
yes
no
[sink]
[decision]
yes
no
[queue] [delay]
© The AnyLogic Company | www.anylogic.com 8
Agent based modeling (no “father”, 2000s)
• We focus on individual objects and describe their local behavior, local rules Sometimes – also the dynamics of the environment
EnvironmentAgent’s behavior
Child
Junior
Adult
Senior
© The AnyLogic Company | www.anylogic.com 10
DON'T be misguided by "academic" literature:
• Agents are NOT the same thing as cellular automata that live in discrete space There can be no space at all. When space is needed, in most cases it is continuous, sometimes a
geographical map or a facility floor plan
• Agent based modeling does NOT assume clock "ticks" or "steps" Most well-built and efficient agent based models are asynchronous. Continuous time dynamics may
also be a part of agent or environment behavior
• Agents are NOT necessarily people Anything can be an agent: a vehicle, a piece of equipment, a project, an idea, an organization, an
investment
• Agents DON"T have to be intellectual, adaptive, learning, or exhibit goal-seeking behavior Agents can be very primitive, dumb, seeking nothing, and not able to learn
• Agents DON'T have to be active. A passive object can be an agent Consider a pipe segment of a water supply network with ist maintenance and replacement schedules,
cost, breakdown events, etc
• There can be many and there can be very few agents in an agent based model Compare a model of a consumer market and a model of a steel plant
• There are agent based models where agents do not interact at all Consider agents – patients with chronic non-contagious diseases
• There are agent based models with and without environment
© The AnyLogic Company | www.anylogic.com 11
Agents can be:
Non-material things:projects, products, innovations, ideas, investments …
Vehicles, equipment:trucks, cars, cranes, aircrafts, rail cars, machines, …
Organizations:companies, political parties, countries, …
People:consumers, habitants, employees,
patients, doctors, clients, soldiers, …
© The AnyLogic Company | www.anylogic.com 13
What is agent in my model?
• Sometimes this is obvious, sometimes not Example: agent based model of America's automotive market
Person
Car
Person
Car
Person
?
?
?
? Household
• How do I choose? In this particular case: think, e.g. where the decisions are made In general: try, see which architecture results in more elegant model
© The AnyLogic Company | www.anylogic.com 14
Special/standard language for AB modeling…
• …does not exist AB models are very diverse
• However, there are “design patterns” common to many AB models Object-”based” architecture Time model: asynchronous or synchronous (steps) Space: no space, continuous (2D or 3D), GIS, discrete Mobility
Networks and links Communication Between agents Between agents and environment
Agent state information and behavior Statecharts “Rules” SD inside agents DE (processes) inside agents
Statistics collection on populations of agents
© The AnyLogic Company | www.anylogic.com 16
AB modeling has a lot in common with OO design
• Agent = object• The model is designed as a set of agent/object classes• Agents of the same class have common structure, but differ in
parameters/states Memory/state information is individual to every agent
• "Border" of agent/object, separation of interface and implementation
• Agent/object communication: message passing, function calls Message sequence diagrams are useful in AB model design
• Agents/objects can be created and deleted dynamically• [Inheritance and polymorhysm may be useful, but are not that
important in AB modeling]
© The AnyLogic Company | www.anylogic.com 17
Networks
• If agents have more or less stable connections, it may make sense to create a network [If there is no network, it does not mean agents do not communicate.
They can communicate randomly, or establish short-term links]
• There are standard network types supported by AnyLogic Random Ring lattice Small world Scale free Distance-based
• Standard networks have bi-directional "unnamed" links• You can create custom networks of any configuration
For example, hierarchical, with unidirectional or “named” links, etc.
• Networks can be dynamically reconfigured
© The AnyLogic Company | www.anylogic.com 18
Network examplesRandom network
3 links per agent 50 agents on a ring layout
Ring lattice4 links per agent
10 agents on a ring layout
Scale free networkm = 4
50 agents on a ring layout
Small world network 3 links per agent, 75% of neighborhood links
50 agents on a ring layout
Distance-based networkRange = 50
100 agents on a random layout
Custom network 50 initial agents small world
200 more agents linked to them
© The AnyLogic Company | www.anylogic.com 20
Multi-method modeling. AnyLogic
• Support all three modeling methods on a single modern object-oriented platform
• The modeler can choose from a wide range of abstraction levels/methods and can efficiently vary them while working on the model
• The modeler can combine different methods in one model
System dynamics
Discrete event(process based)
modeling
Agent based modeling
Dynamicsystems
© The AnyLogic Company | www.anylogic.com 21
Model architectures
and so on in any combination…
Agents SD DE (Process model)
SD inside agent(e.g. consumer’s individual
decision making)
Process model inside agent(e.g. business process in a company
in a bigger supply chain model)
Agents + SD environment(e.g., population +city infrastructure)
Agents + process model(e.g., clients + service)
SD + process model(e.g., demand + production)
Agents become entities(e.g., patients with chronic diseases
return to hospital)
© The AnyLogic Company | www.anylogic.com 23
“Academic” agent based modeling
• Discrete time
Agent 2
Agent 1
Agent 0
Time0 1 2 3
• Discrete space
rows
columns
{N,S,E,W] {N,NE,E,SE,S,SW,W,NW]
© The AnyLogic Company | www.anylogic.com 26
Do I need to have programming skills?
SD
Almost none
DE
Some: expressions,function calls
AB
More: expressions,function calls,
statements
Softwaredevelopment
Classes, interfaces,
inheritance,polymorphism,
…
© The AnyLogic Company | www.anylogic.com 27
– Same agents,– Environment
scaled down
How many agents to simulate?
• If I need to model the US population do I need to simulate 300,000,000 agents? Fortunately not!
• Two main “model scaling” techniques are used:
– Same environment– Agents represent
groups
© The AnyLogic Company | www.anylogic.com 28
Thank you!
• Questions?
• Links: AnyLogic website: www.anylogic.com AnyLogic models online: www.runthemodel.com
© The AnyLogic Company | www.anylogic.com 30
Bass Diffusion – Agent Based version
PotentialAdopters Adopters
AdoptionRate
Adoptionfrom
Advertising
AdvertisingEffectiveness
+
+
+
B
B
Adoptionfrom Wordof Mouth
TotalPopulation
AdoptionFraction
ContactRate
+
++
+
-
+R
ABSD
100 agents
PotentialAdopters
Adopters
10,000 agents
PotentialAdopters
Adopters
PotentialAdopter
Adopter
Rate:AdEffectiveness
“Buy!”Guard: randomTrue(AdoptionFraction)
Rate: ContactRate
<random agent>.”Buy!”
© The AnyLogic Company | www.anylogic.com 31
Capturing more with AB Model
• Can you build an SD model that captures such dynamics?
• Let the word-of-mouth influence of an adopter depend on how recently he has purchased
PotentialAdopters
Adopters
0 1 2 3
0.01
0.02
0.03
Adoption Fraction vsTime since purchase
“Buy it!”Guard: randomTrue(AdoptionFraction (
Now – Time Purchased ) ))
Rate: Contact Rate<random agent>.”Buy it!”
Rate: AdEffectiveness
PotentialAdopter
Adopter Time Purchased = Now
Time Purchased = Now
Time Purchased
© The AnyLogic Company | www.anylogic.com 32
Correspondence between DE and AB
Arrival Decision?Y
N
Service
Delay Exit
Resource
Idle
In Use
seizedreleased Dispatcher
Wait Resource
B
In Service
Requestresource
Resourcegranted
Finished
Delayed
Delay Time
Y
N
Requestresource
Releaseresource
Delete this agent
DE AB