Introduction to
Agent Based Modeling
Using NetLogo
Prem Sankar C
Research Scholar, Dept of Futures Studies
Prem Sankar C - Dept of Futures Studies 2
Introduction to Agent Based Modeling
● An ABM is a computer simulation program:
● a collection of agents and their states
● the rules governing the interactions of the agents
● the environment (overall system) within which they live.
● ABM for Simulation of Complex Systems
● Helps to simulate artificial societies
Prem Sankar C - Dept of Futures Studies 3
Flying patterns – Birds -Flocking
Prem Sankar C - Dept of Futures Studies 4
Shortest path - Ants
http://agentbase.org/model.html?b24f11b263d0de2610f1#
Prem Sankar C - Dept of Futures Studies 5
ABM Definition
● An agent-based model is a class of computational
models for simulating the actions and interactions of
autonomous agents with a view to assessing their
effects on the system as a whole. - Wikipedia
● Agent Based Models can help analyze and simulate
Complex Systems.
Prem Sankar C - Dept of Futures Studies 6
Where ABM applied?
● Flows: evacuation, traffic, and
customer flowmanagement.
● Markets: stock market,
shopbots and software
agents,and strategic
simulation.
● Organizations: operational
risk and organizational design.
● Diffusion: diffusion of
innovation and adoption
dynamics.
Prem Sankar C - Dept of Futures Studies 7
ABM Examples
● Population Dynamics
● Predator-Prey Dynamics
● Political Dynamics
● Migration Modeling
● Epidemic Simulation
● Crowd modeling
● Pedestrian modeling and simulation
● Policy / Decision making
● Modeling Financial Markets
Assignment: Agent Based Simulation Industrial Applications?
Prem Sankar C - Dept of Futures Studies 8
Components of ABM model
● Space/ Enviornment
● Agents
● Time
● Visualization
● Interaction Rules
Prem Sankar C - Dept of Futures Studies 9
Who is an agent?
● An agent is a thing which does things to things
(Kauffman)
● A discrete entity with its own goals and behaviors
● Autonomous, with a capability to adapt and modify its
behaviors
● has some state
● interacts with other agents mutually modifying
each others’ states
● your model your rules!!!
Prem Sankar C - Dept of Futures Studies 10
OOPs V/s ABM
● Objects
● Class
● Attributes/ Properties
● Procedures/ Methods
● Agents
● Community
● Behaviour Values
● Interactions
● State to State
Yes, agents are objects!
Prem Sankar C - Dept of Futures Studies 11
Agent Environments
Types of Agent Environments
Prem Sankar C - Dept of Futures Studies 12
Agent Interactions
Depending on the environment agents interact in different
manners.
Typically an agent interact with neighbors
For Eg: In a Grid, surrounding cells are the neighborhood.
In a network, the first degree connections are neighbors.
Prem Sankar C - Dept of Futures Studies 13
What is simulation time? How it
calculated?
● A schedule implies a timeline
● ask agents [
# do something
]
advance-tick
Prem Sankar C - Dept of Futures Studies 14
Getting Started - NetLogo
Prem Sankar C - Dept of Futures Studies 15
Introduction to NetLogo
● The Center for Connected Learning (CCL) and Computer-Based
Modeling, Northwestern University, USA.
● Free and Open Source
● The name NetLogo comes from “Network Logo”
● Uses a Procedural Language called Logo
● Other Tools -SWARM, RePast, MASON, MESA etc.
● Docs & tutorial: bit.ly/abm-mesa
http://mesa.readthedocs.io/en/latest/#contributing-back-to-mesa
● Refer Wikipedia ABM tools list
Prem Sankar C - Dept of Futures Studies 16
NetLogo-User and Programming Interface
Prem Sankar C - Dept of Futures Studies 17
Why NetLogo?
Very popular tool (educational purpose).
Easy-to-use language, great for beginners.
Mature platform, rare bugs to none.
Contains many useful already-made primitives and structures.
Great for prototyping models, deploys web Java applets.
Many example available.
Great documentation, active community.
Can be used for complex models also.
Scalability issues.
Becomes slow when things get complicated.
Lack of Object Oriented style, debugger.
Prem Sankar C - Dept of Futures Studies 18
Wolf Sheep Predation model
● This model explores the stability of predator-prey ecosystems. [Biology]
Predator-Prey
Dynamics
Prem Sankar C - Dept of Futures Studies 19
Virus spread in a network
● Demonstrates the spread
of a virus through a
network.
● Each node may be in one
of three states:
susceptible, infected, or
resistant
● referred as SIR model for
epidemic
● Try Dengi !!!
Prem Sankar C - Dept of Futures Studies 20
Game of Life
Game Of Life:
 two-dimensional orthogonal grid
Agents are cells, state dead or alive
 
Rules:
1)Any live cell with fewer than two live
neighbors dies, as if caused by under-
population.
2)Any live cell with two or three live
neighbors lives on to the next generation.
3)Any live cell with more than three live
neighbors dies, as if by overcrowding.
4)Any dead cell with exactly three live
neighbors becomes a live cell, as if by
reproduction.
Prem Sankar C - Dept of Futures Studies 21
Try this !!!
Assignment : List out Steady State patterns
Prem Sankar C - Dept of Futures Studies 22
Preferential Attachment
The model starts with two
nodes connected by an edge.
At each step, a new node is
added. A new node picks an
existing node to connect to
randomly, but with some
bias
Node’s chance of being
selected is directly
proportional to the number
of connections it already has.
Prem Sankar C - Dept of Futures Studies 23
BeeSmart Hive Finding
● The BeeSmart Master model shows the swarm
intelligence of honeybees during their hive-
finding process.
● A swarm of tens of thousands of honeybees
can accurately pick the best new hive site
available among dozens of potential choices
through self-organizing behavior.
Story of Waggle Lab
Prem Sankar C - Dept of Futures Studies 24
When we use ABM ?
1)When there are decisions and behaviors that can be
well-defined.
2)When it is important that agents adapt and change
their behaviors.
3)When it is important that agents have a dynamic
relationship with other agents, and agent relationships
form, change and decay.
4)When the past is no predictor of the future because the
processes of growth and change are dynamic.
Prem Sankar C - Dept of Futures Studies 25
Why we use ABM ?
● Agent-based models represent individuals,
their behaviors and their interactions
● Equation-based models represent aggregates
and their dynamics.
● Agents have decision-making abilities and an
understanding of their environment
● Micro to Macro: Agent behaviors to System
Behaviors
Prem Sankar C - Dept of Futures Studies 26
ABM features
● Bottom-up approach
● No central authority
● Individual behavior is nonlinear
● Agent interactions are heterogeneous
● Studying effects of
– decentralized decision making
– local-global interaction, self-organization, emergence
– heterogeneity in the system
Prem Sankar C - Dept of Futures Studies 27
We have a model, then?
● Every model has a parameters space
● Simulate each possible combination many
times
● Compare what you have found with empirical
values
Prem Sankar C - Dept of Futures Studies 28
The research question is: “how
could the decentralized local
interactions of heterogeneous
autonomous agents generate
a global pattern?
Prem Sankar C - Dept of Futures Studies 29
How to ask for help ?
● Google Search
● Professional Communities
● Ask a question on www.stackoverflow.com
● Please be smart in the title:
● Please be specific in the message:
Prem Sankar C - Dept of Futures Studies 30
Reference
1) Vizzari, EASSS 2009 - Torino – 3-4/9/2009 Tutorial.
2) CM Macal and MJ North, Tutorial on agent-based modeling and simulation,
Journal of Simulation 2010.
3) CM Macal and MJ North, AGENT-BASED MODELING AND SIMULATION,
Proceedings of the 2009 Winter Simulation Conference.
4) Paul Davidsson , Agent Based Social Simulation: A Computer
Science View, Journal of Artificial Societies and Social Simulation vol. 5,
no. 1.
5) Rob Allan, Survey of Agent Based Modelling and Simulation Tools
Prem Sankar C - Dept of Futures Studies 31
Thank you for your attention!

Introduction to Agent Based Modeling Using NetLogo

  • 1.
    Introduction to Agent BasedModeling Using NetLogo Prem Sankar C Research Scholar, Dept of Futures Studies
  • 2.
    Prem Sankar C- Dept of Futures Studies 2 Introduction to Agent Based Modeling ● An ABM is a computer simulation program: ● a collection of agents and their states ● the rules governing the interactions of the agents ● the environment (overall system) within which they live. ● ABM for Simulation of Complex Systems ● Helps to simulate artificial societies
  • 3.
    Prem Sankar C- Dept of Futures Studies 3 Flying patterns – Birds -Flocking
  • 4.
    Prem Sankar C- Dept of Futures Studies 4 Shortest path - Ants http://agentbase.org/model.html?b24f11b263d0de2610f1#
  • 5.
    Prem Sankar C- Dept of Futures Studies 5 ABM Definition ● An agent-based model is a class of computational models for simulating the actions and interactions of autonomous agents with a view to assessing their effects on the system as a whole. - Wikipedia ● Agent Based Models can help analyze and simulate Complex Systems.
  • 6.
    Prem Sankar C- Dept of Futures Studies 6 Where ABM applied? ● Flows: evacuation, traffic, and customer flowmanagement. ● Markets: stock market, shopbots and software agents,and strategic simulation. ● Organizations: operational risk and organizational design. ● Diffusion: diffusion of innovation and adoption dynamics.
  • 7.
    Prem Sankar C- Dept of Futures Studies 7 ABM Examples ● Population Dynamics ● Predator-Prey Dynamics ● Political Dynamics ● Migration Modeling ● Epidemic Simulation ● Crowd modeling ● Pedestrian modeling and simulation ● Policy / Decision making ● Modeling Financial Markets Assignment: Agent Based Simulation Industrial Applications?
  • 8.
    Prem Sankar C- Dept of Futures Studies 8 Components of ABM model ● Space/ Enviornment ● Agents ● Time ● Visualization ● Interaction Rules
  • 9.
    Prem Sankar C- Dept of Futures Studies 9 Who is an agent? ● An agent is a thing which does things to things (Kauffman) ● A discrete entity with its own goals and behaviors ● Autonomous, with a capability to adapt and modify its behaviors ● has some state ● interacts with other agents mutually modifying each others’ states ● your model your rules!!!
  • 10.
    Prem Sankar C- Dept of Futures Studies 10 OOPs V/s ABM ● Objects ● Class ● Attributes/ Properties ● Procedures/ Methods ● Agents ● Community ● Behaviour Values ● Interactions ● State to State Yes, agents are objects!
  • 11.
    Prem Sankar C- Dept of Futures Studies 11 Agent Environments Types of Agent Environments
  • 12.
    Prem Sankar C- Dept of Futures Studies 12 Agent Interactions Depending on the environment agents interact in different manners. Typically an agent interact with neighbors For Eg: In a Grid, surrounding cells are the neighborhood. In a network, the first degree connections are neighbors.
  • 13.
    Prem Sankar C- Dept of Futures Studies 13 What is simulation time? How it calculated? ● A schedule implies a timeline ● ask agents [ # do something ] advance-tick
  • 14.
    Prem Sankar C- Dept of Futures Studies 14 Getting Started - NetLogo
  • 15.
    Prem Sankar C- Dept of Futures Studies 15 Introduction to NetLogo ● The Center for Connected Learning (CCL) and Computer-Based Modeling, Northwestern University, USA. ● Free and Open Source ● The name NetLogo comes from “Network Logo” ● Uses a Procedural Language called Logo ● Other Tools -SWARM, RePast, MASON, MESA etc. ● Docs & tutorial: bit.ly/abm-mesa http://mesa.readthedocs.io/en/latest/#contributing-back-to-mesa ● Refer Wikipedia ABM tools list
  • 16.
    Prem Sankar C- Dept of Futures Studies 16 NetLogo-User and Programming Interface
  • 17.
    Prem Sankar C- Dept of Futures Studies 17 Why NetLogo? Very popular tool (educational purpose). Easy-to-use language, great for beginners. Mature platform, rare bugs to none. Contains many useful already-made primitives and structures. Great for prototyping models, deploys web Java applets. Many example available. Great documentation, active community. Can be used for complex models also. Scalability issues. Becomes slow when things get complicated. Lack of Object Oriented style, debugger.
  • 18.
    Prem Sankar C- Dept of Futures Studies 18 Wolf Sheep Predation model ● This model explores the stability of predator-prey ecosystems. [Biology] Predator-Prey Dynamics
  • 19.
    Prem Sankar C- Dept of Futures Studies 19 Virus spread in a network ● Demonstrates the spread of a virus through a network. ● Each node may be in one of three states: susceptible, infected, or resistant ● referred as SIR model for epidemic ● Try Dengi !!!
  • 20.
    Prem Sankar C- Dept of Futures Studies 20 Game of Life Game Of Life:  two-dimensional orthogonal grid Agents are cells, state dead or alive   Rules: 1)Any live cell with fewer than two live neighbors dies, as if caused by under- population. 2)Any live cell with two or three live neighbors lives on to the next generation. 3)Any live cell with more than three live neighbors dies, as if by overcrowding. 4)Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
  • 21.
    Prem Sankar C- Dept of Futures Studies 21 Try this !!! Assignment : List out Steady State patterns
  • 22.
    Prem Sankar C- Dept of Futures Studies 22 Preferential Attachment The model starts with two nodes connected by an edge. At each step, a new node is added. A new node picks an existing node to connect to randomly, but with some bias Node’s chance of being selected is directly proportional to the number of connections it already has.
  • 23.
    Prem Sankar C- Dept of Futures Studies 23 BeeSmart Hive Finding ● The BeeSmart Master model shows the swarm intelligence of honeybees during their hive- finding process. ● A swarm of tens of thousands of honeybees can accurately pick the best new hive site available among dozens of potential choices through self-organizing behavior. Story of Waggle Lab
  • 24.
    Prem Sankar C- Dept of Futures Studies 24 When we use ABM ? 1)When there are decisions and behaviors that can be well-defined. 2)When it is important that agents adapt and change their behaviors. 3)When it is important that agents have a dynamic relationship with other agents, and agent relationships form, change and decay. 4)When the past is no predictor of the future because the processes of growth and change are dynamic.
  • 25.
    Prem Sankar C- Dept of Futures Studies 25 Why we use ABM ? ● Agent-based models represent individuals, their behaviors and their interactions ● Equation-based models represent aggregates and their dynamics. ● Agents have decision-making abilities and an understanding of their environment ● Micro to Macro: Agent behaviors to System Behaviors
  • 26.
    Prem Sankar C- Dept of Futures Studies 26 ABM features ● Bottom-up approach ● No central authority ● Individual behavior is nonlinear ● Agent interactions are heterogeneous ● Studying effects of – decentralized decision making – local-global interaction, self-organization, emergence – heterogeneity in the system
  • 27.
    Prem Sankar C- Dept of Futures Studies 27 We have a model, then? ● Every model has a parameters space ● Simulate each possible combination many times ● Compare what you have found with empirical values
  • 28.
    Prem Sankar C- Dept of Futures Studies 28 The research question is: “how could the decentralized local interactions of heterogeneous autonomous agents generate a global pattern?
  • 29.
    Prem Sankar C- Dept of Futures Studies 29 How to ask for help ? ● Google Search ● Professional Communities ● Ask a question on www.stackoverflow.com ● Please be smart in the title: ● Please be specific in the message:
  • 30.
    Prem Sankar C- Dept of Futures Studies 30 Reference 1) Vizzari, EASSS 2009 - Torino – 3-4/9/2009 Tutorial. 2) CM Macal and MJ North, Tutorial on agent-based modeling and simulation, Journal of Simulation 2010. 3) CM Macal and MJ North, AGENT-BASED MODELING AND SIMULATION, Proceedings of the 2009 Winter Simulation Conference. 4) Paul Davidsson , Agent Based Social Simulation: A Computer Science View, Journal of Artificial Societies and Social Simulation vol. 5, no. 1. 5) Rob Allan, Survey of Agent Based Modelling and Simulation Tools
  • 31.
    Prem Sankar C- Dept of Futures Studies 31 Thank you for your attention!