Agent-Based Modelling, the London riots, and Python
Thomas French (@trfrench) and Fred Farrell
Sandtable (@_sandtable)
Overview 20 June 2015
!   Agent-based modelling
!   London riots model
!   Data Science Platform
Context 20 June 2015
!   Live in increasingly complex, dynamic world.
!   Increasing computing power.
!   More and more data collected.
!   Understand world: make better decisions.
!   “Data only as valuable as the decisions it enables” Ion Stoica (Prof
UC Berkeley)
Strategic over tactical problems 20 June 2015
!   How will changing attitudes in health impact soft drinks sales?
!   Why are people not choosing my store anymore?
!   How do people respond to advertising?
!   How and why do people quit smoking?
!   How do STDs spread through social networks?
!   How to get people to wash their hands?
!   Goal: behaviour change
What is Agent-Based Modelling? 20 June 2015
! Modelling technique
ª  Build representations of real systems
!   Roots in complexity science
ª  Complex adaptive systems
ª  Emergence
! Behavioural modelling
ª  Hypotheses of behaviour
ª  Bottom-up
!   Accessible metaphor
Agent-Based Models 20 June 2015
AGENT
ENVIRONMENT
SENSORS
MESSAGES
ACTIONS
PERCEPTS
OBJECT
ACTUATORS
Based&on&Bordini&et&al&&(2007)
Schelling’s Model of Segregation 20 June 2015
Stay
Happy/
Unhappy
Move
Happy
Unhappy
Schelling’s Model of Segregation 20 June 2015
http://www.sandtable.com/a-coin-and-paper-model-of-segregation/
How do we derive rules of behaviour? 20 June 2015
!   Domain experts
!   Survey data
! Behavioural data
!   Machine learning
Building ABMs 20 June 2015
! NetLogo: IDE; JVM
!   Repast: Java & C++
!   Hybrid Repast
! Simpy: lightweight ABM library in Python
ª  Quick prototyping
ª  Agile
ª  Ecosystem: pandas; numpy; pytables; cython; scikit-learn
!   Sandman: cluster framework for large-scale simulation
Typical ABM algorithm 20 June 2015
!   Inputs:
ª  environment: time series
ª  agents: attributes; attitudes; social network
!   Simulation loop: 1 to T
ª  Agent loop: 1 to A
•  Take inputs from environment
•  Process messages from social network
•  Make decisions
•  Send messages over social network
How do we build confidence in models? 20 June 2015
!   Visual validation
ª  Types of behaviour
ª  Trends
!   Data
ª  Macro and micro levels
ª  Multiple datasets
ª  Validation against reference data
ª  Training/ testing data
2011 London riots model 20 June 2015
!   Ongoing proof of concept model
!   Good example to demonstrate capability of ABM to model behaviour
and explore policing strategies.
!   Interactions of two kinds of agents – rioters and police – whose
behaviour is dependent on other agents.
5 days in August 20 June 2015
!   Riots began on 6 August 2011
following protests over the
shooting by police of Mark
Duggan.
!   Riots spread across cities in
England, lasting 5 days; around
15000 people involved, more
than 5000 crimes committed.
!   Around £300 million damage in
London alone.
Images from wikipedia
Mathematical model of the riots 20 June 2015
Davies et al - mathematical model of riots 20 June 2015
!   Individual-based mathematical
model of rioters and police
!   Rioters are attracted to areas
where rioters outnumber police
!   Individuals from more deprived
areas more likely to riot
!   Able to broadly reproduce
geographical distribution of
rioting in London
Davies et al.
Our agent-based model 20 June 2015
!   We built an ABM inspired by this
work.
!   Environment: map of London
containing agents (potential
rioters), police, and retail centres
(potential riot sites).
!   Our focus is on police response.
Basic model 20 June 2015
!   Agents: 12000 citizens; 1000 police
!   Time horizon: 48 hours
!   Each timestep (1hr):
ª  Police move to sites with most rioters
ª  Police make arrests
ª  Potential rioters decide whether to riot
•  Choose site: number of rioters/ police, and distance to site
•  Want close sites with many rioters and few police
Additional effects 20 June 2015
!   Lag in police response: police take a certain time to respond to
changing circumstances
!   Media: agents do not have perfect information on riot activity but must
find out about it via media (social/ broadcast)
20 June 2015
Demo
Data Science Platform 20 June 2015
!   Pandas, numpy, scipy, cython, pytables, scikit-learn
! Jupyter notebooks
!   Luigi pipelines
!   Cloud-based platform for collaborative, agile data science
! www.sandtable.com/the-sandtable-model-foundry
Summary 20 June 2015
!   Build ABMs for understanding behaviour.
!   Applicable to strategic problems.
!   Simulation for exploring scenarios.
!   Package as data products.
!   Python data stack crucial to our work.
!   Developing a collaborative Platform around them.
20 June 2015
Project Title
Thanks!
@trfrench
thomas@sandtable.com
References 20 June 2015
! Macal and North ‘Agent-Based Modelling and Simulation’ in
Proceedings of the 2009 Winter Simulation Conference, pg 86-98,
IEEE.
!   ‘Model Thinking’ Scott Page on Coursera
! Bordini et al. ‘Programming Multi-Agent Systems in AgentSpeak using
Jason’, 2007, Wiley

Agent-based modelling, the London riots, and Python

  • 1.
    Agent-Based Modelling, theLondon riots, and Python Thomas French (@trfrench) and Fred Farrell Sandtable (@_sandtable)
  • 2.
    Overview 20 June2015 !   Agent-based modelling !   London riots model !   Data Science Platform
  • 3.
    Context 20 June2015 !   Live in increasingly complex, dynamic world. !   Increasing computing power. !   More and more data collected. !   Understand world: make better decisions. !   “Data only as valuable as the decisions it enables” Ion Stoica (Prof UC Berkeley)
  • 4.
    Strategic over tacticalproblems 20 June 2015 !   How will changing attitudes in health impact soft drinks sales? !   Why are people not choosing my store anymore? !   How do people respond to advertising? !   How and why do people quit smoking? !   How do STDs spread through social networks? !   How to get people to wash their hands? !   Goal: behaviour change
  • 5.
    What is Agent-BasedModelling? 20 June 2015 ! Modelling technique ª  Build representations of real systems !   Roots in complexity science ª  Complex adaptive systems ª  Emergence ! Behavioural modelling ª  Hypotheses of behaviour ª  Bottom-up !   Accessible metaphor
  • 6.
    Agent-Based Models 20June 2015 AGENT ENVIRONMENT SENSORS MESSAGES ACTIONS PERCEPTS OBJECT ACTUATORS Based&on&Bordini&et&al&&(2007)
  • 7.
    Schelling’s Model ofSegregation 20 June 2015 Stay Happy/ Unhappy Move Happy Unhappy
  • 8.
    Schelling’s Model ofSegregation 20 June 2015 http://www.sandtable.com/a-coin-and-paper-model-of-segregation/
  • 9.
    How do wederive rules of behaviour? 20 June 2015 !   Domain experts !   Survey data ! Behavioural data !   Machine learning
  • 10.
    Building ABMs 20June 2015 ! NetLogo: IDE; JVM !   Repast: Java & C++ !   Hybrid Repast ! Simpy: lightweight ABM library in Python ª  Quick prototyping ª  Agile ª  Ecosystem: pandas; numpy; pytables; cython; scikit-learn !   Sandman: cluster framework for large-scale simulation
  • 11.
    Typical ABM algorithm20 June 2015 !   Inputs: ª  environment: time series ª  agents: attributes; attitudes; social network !   Simulation loop: 1 to T ª  Agent loop: 1 to A •  Take inputs from environment •  Process messages from social network •  Make decisions •  Send messages over social network
  • 12.
    How do webuild confidence in models? 20 June 2015 !   Visual validation ª  Types of behaviour ª  Trends !   Data ª  Macro and micro levels ª  Multiple datasets ª  Validation against reference data ª  Training/ testing data
  • 13.
    2011 London riotsmodel 20 June 2015 !   Ongoing proof of concept model !   Good example to demonstrate capability of ABM to model behaviour and explore policing strategies. !   Interactions of two kinds of agents – rioters and police – whose behaviour is dependent on other agents.
  • 14.
    5 days inAugust 20 June 2015 !   Riots began on 6 August 2011 following protests over the shooting by police of Mark Duggan. !   Riots spread across cities in England, lasting 5 days; around 15000 people involved, more than 5000 crimes committed. !   Around £300 million damage in London alone. Images from wikipedia
  • 15.
    Mathematical model ofthe riots 20 June 2015
  • 16.
    Davies et al- mathematical model of riots 20 June 2015 !   Individual-based mathematical model of rioters and police !   Rioters are attracted to areas where rioters outnumber police !   Individuals from more deprived areas more likely to riot !   Able to broadly reproduce geographical distribution of rioting in London Davies et al.
  • 17.
    Our agent-based model20 June 2015 !   We built an ABM inspired by this work. !   Environment: map of London containing agents (potential rioters), police, and retail centres (potential riot sites). !   Our focus is on police response.
  • 18.
    Basic model 20June 2015 !   Agents: 12000 citizens; 1000 police !   Time horizon: 48 hours !   Each timestep (1hr): ª  Police move to sites with most rioters ª  Police make arrests ª  Potential rioters decide whether to riot •  Choose site: number of rioters/ police, and distance to site •  Want close sites with many rioters and few police
  • 19.
    Additional effects 20June 2015 !   Lag in police response: police take a certain time to respond to changing circumstances !   Media: agents do not have perfect information on riot activity but must find out about it via media (social/ broadcast)
  • 20.
  • 21.
    Data Science Platform20 June 2015 !   Pandas, numpy, scipy, cython, pytables, scikit-learn ! Jupyter notebooks !   Luigi pipelines !   Cloud-based platform for collaborative, agile data science ! www.sandtable.com/the-sandtable-model-foundry
  • 22.
    Summary 20 June2015 !   Build ABMs for understanding behaviour. !   Applicable to strategic problems. !   Simulation for exploring scenarios. !   Package as data products. !   Python data stack crucial to our work. !   Developing a collaborative Platform around them.
  • 23.
    20 June 2015 ProjectTitle Thanks! @trfrench thomas@sandtable.com
  • 24.
    References 20 June2015 ! Macal and North ‘Agent-Based Modelling and Simulation’ in Proceedings of the 2009 Winter Simulation Conference, pg 86-98, IEEE. !   ‘Model Thinking’ Scott Page on Coursera ! Bordini et al. ‘Programming Multi-Agent Systems in AgentSpeak using Jason’, 2007, Wiley