CRDC Logo

Agent-Based Modelling for Smarter Cities

Dr Nick Malleson
School of Geography, University of Leeds

http://nickmalleson.co.uk/
http://www.geog.leeds.ac.uk/people/n.malleson
Slides: http://mass.leeds.ac.uk/html/slides/Lipari2014/
computer room

First: About me

Education

BSc: Computer Science

MSc: GeoInformatics

PhD: (Computational) Human Geography

Note: 'computational' bit is important!

Now: Lecturer in Geographical Information Systems

Spatio-temporal behaviour of virtual agents

Research Interests:

Spatial analysis and simulation

Crime patterns

Agent-Based Modelling

Big data (particularly for social simulation)

Agent-Based Modelling for Smarter Cities

Session 1 - Modelling Society

Complex Cities

Social Simulation and Agent-Based Modelling

Modelling (Human) Behaviour

 

Session 2 - The Big Data Revolution

The Abundance of Data

The Big Data "Revolution"

Urban Dynamics and Social Media

Improving our Models of Human Behaviour

Agent-Based Modelling for Smarter Cities

Main aims / outcomes

Enthusiasm for agent-based modelling and its use in smart cities

Some appreciation for the benefits and drawbacks

The potential to use the technique in your research (or at least how to learn more)

This is a very coarse introduction!!

My undergraduate course consists of 20 hours of lectures and 10 hours of pratical classes

See the Introduction to CSS book - chapter 10

Outline: Modelling Society

Background: Complex Systems

A termite mound

Attribution: Yewenyi at the English language Wikipedia https://en.wikipedia.org/wiki/User:Yewenyi

Emergence

“A property of a collection of simple sub-units that comes about through the interactions of the subunits and is not a property of any single subunit”
- Gary Flake

 

“The way that complex systems and patterns arise out of a multiplicity of relatively simple interactions”
- Wikipedia

 

“The whole is greater than the sum of its parts”
- Aristotle

Background: Complex Systems

Emergence

Video (NOVA scienceNOW)

http://www.youtube.com/watch?v=aEaZHWXmbRw (up to 4:50)

When watching the video, think about:

1. If there is no leader, how are flocks etc. controlled?

2. List some of the organisms that demonstrate emergent behaviour.

3. Can you think of any other examples of emergent phenomena?

Background: Complex Systems

Emergence Example

Thomas Schelling's model of racial segregation

Cells either 1 or 0 ("black" or "white").

If neighbourhood > x% of another colour, move to nearest area where this isn’t true.

Demo: What do you think will happen when these different preference levels are selected?

35%

50%

80%

Background: Complex Systems

Schelling Results

Even with low individual preferences for neighbour similarity, segregation emerges.

35%
50%
80%

Background: Complex Systems

Emergence: Key messages

Simple rules → complex outcomes

Complex structures can emerge from simple rules

In the past, we have assumed that complex phenomena are driven by a complex mechanism

This is not always the case

Global (macro) level patterns are the result of micro interactions.

Understanding interactions is key to understanding macro behaviour.

Emergence is hard to anticipate

Cannot be deduced from solely analysis of individuals’ behaviour

Background: Complex Systems

Non-Linear Dynamics

Another fundamental characteristic of complex systems

In a linear system, the output linearly proportional to the inputs

However, complex systems to not behave in a linear fashion

A liner change in system inputs does not necessarily result in a linear change in model outputs

Background: Complex Systems

Non-Linear Dynamics Example

NetLogo Wolf-Sheep Predation Model

NetLogo Wolf-Sheep Predation Model

Grass grows

Sheep eat grass

Wolves eat sheep

What will happen to the sheep population when we:

Reduce the number of wolves?

Increase the number of sheep?

Reduce the speed at which grass regrows?

Interactions are key!

What does all this have to do with agent-based modelling and smart cities??

Cities are Complex Systems

Recent work recognises the complex characteristics of cities (e.g. Batty, 2005, 2012)

new york at night

Characterised by:

Enumerable micro-interactions

(both human-human and human-environment)

Emergence

Phenomena that arise (unexpectedly) from behaviour of individual units

Non-linear dynamics

Difficult to predict output from inputs

Remember Braess’ paradox (Tuesday)

Feedback loops

Damping or amplifying

"The effects of an element's behaviour are fed back to in such a way that the element itself is altered." (Wikipedia)

Outline: Modelling Society

Modelling Urban Phenomena

Example of regression

To really understand urban phenomena, or to make predictions, we need to create models

Traditional approach: aggregate models

Work at an aggregate level, from the top-down

E.g. Regression, spatial interaction modelling, location-allocation, system dynamics, etc.

Also other Computational Social Science approaches (e.g. equation-based models) (Cioffi-Revilla, 2014)

Aggregate Models

Aggregate models work very well in some situations

Homogeneous individuals

Interactions not important

Very large systems (e.g. pressure-volume gas relationship)

BUT: many systems are driven by individuals

(cars, people, ants, trees, whatever)

Aggregate models miss some important elements:

Low-level dynamics, i.e. "smoothing out" (Batty, 2005)

Interactions and emergence

Unsuitable for modelling complex systems

An Alternative: Agent-Based Modelling (ABM)

THe Sims

Rather than controlling from the top, try to represent the individuals

"Grow" the phenomena from the ground up (Epstein and Axtell, 1996)

'Object-based models' - variables and equations are "encapsulated" within objects (Cioffi-Revilla, 2014)

Account for system behaviour directly

Can model emergence, non-linearity, and other features of complex systems

Essential ingredient for a smart city

An Alternative: Agent-Based Modelling (ABM)

THe Sims

Basic execution process

t=0 (initialisation) : create a population of agents and their environment

Each agent has variables that represent their state and rules to control their behaviour

t+1 : Each agent executes its behavioural rules and updates its state

This can involve moving, interacting with, interacting with other agents, performing no action etc.

ABM Example: MASSIVE

http://www.youtube.com/watch?v=W5pNPJAhsBI

http://www.lordoftherings.net/effects/index.html

When watching the video, think about:

What do the agents represent?

What behaviours have been implemented?

How many agents can they model?

How have the agents’ brains been represented?

What is an agent?

No universal definition, but most people agree that agents should exhibit some of the following criteria

Autonomy

Act independently, free from central control

Control its own state and make independent decisions

Heterogeneity

Agents should not normally be identical

Groups of similar agents are formed from the ground-up (e.g. by agents interacting with each other)

Reactivity (and proactivity)

Agents can sense their environment and respond to changes (or respond to expected changes

Responses should be goal-directed

What is an agent?

Bounded rationality

Agents should not have full knowledge of the world (this would be very unrealistic)

Environmental perception can be limited

Choices will not be perfectly rational – they can make mistakes

Interactive

Agents can communicate with each other

Could be dependent on environment (e.g. distance)

Mobile

Often agents will be able to navigate a space.

Learning / adaption

Agents should be able to adapt future decisions, based on past experiences

The Environment

In models of human systems, agents are usually placed in some sort of geographical environment

Structure / type of the environment depends on the research question(s)

2D Schelling example

Abstract: discrete grids

Objects located at discrete (integer) coordinates

Can only move onto cells

Often conduct neighbourhood / proximity queries (e.g. which cells are next to me?)

Cells can have different shapes (squares, hexagons, triangles ... )

The Environment

Continuous geography

Abstract: continuous space

Objects located at arbitrary decimal coordinates

Can move to any location within the boundary of the world

Often the researcher restricts these movements to roads, paths, etc.

Conduct spatial queries

Find all objects within 10 meters

Find objects that are within a boundary

Continuous space example: asteroids!

Boundaries of the world

What happens if an agent tries to walk outside the boundary of the world?

Agents bounce back from the boundary (bouncy?)

Walls absorb agent momentum (absorbent?)

Left/right and up/down borders joined together (torus)

Choice of boundaries depends on the application area

Boundaries Quiz

Can you think of some example applications that require the different types of boundary.


Bouncy:


Absorbent:


Torus:

But what about geography?

Mastermap topography

Sometimes including a realistic geographic space is important, somtimes not

Explanatory vs Predictive modelling

Abstract environments great for exploring theory (e.g. Schelling)

But in some cases the underlying geography is a fundamental part of the model and abstracting space is not appropriate

E.g. predicting positive / negative impacts of smart cities initiatives

Including geography increases complexity, need to consider its value to answering the research questions.

Remember Claudio's chair?

Challenge: integrating geogrpahical data with an ABM

Linking an ABM and GIS

Loose coupling

Loose coupling

Linking an ABM and GIS

Tight coupling

Tight coupling

Loose vs. Tight coupling

Loose

Efficient: GIS are slow, allowing the model to run on its own will almost certainly be quicker

Flexible: The model can run on any computer system, including high-performance 'grid' systems

Free: The model is not tied to a proprietary GIS so can be released and reused freely by others. (Note: Open-source GIS systems are available, e.g. QuantumGIS and GRASS)

Tight

Convenient: Easy to see what the model is doing while it is running

Interactive: Possible to interact with the model and influence an individual model run.

Reusable: Stakeholders / users will find it easier to use if it is built into their GIS.

A-Spatial Environments

So far, we have come across grid, continuous and geographical environments.

In some models, a spatial environment is not needed.

E.g. a social network

Can still account for interactions, complexity, emergence, non-linearity, etc. etc.

fox hunting
Photo attributed to Justortitri, (CC BY-NC-SA 2.0)

Environment Quiz

You want to create a model to better understand fox hunting by simulating a hunt in progress (riders, hounds, foxes). The aim is to find out how many foxes are needed for an enjoyable killing spree, and where they should be located.

List some elements that you would want to include in a virtual environment for this model.

 
 
 

Would you use an abstract or a more realistic environment?

Appeal of ABM

Most 'natural' way of thinking about social systems

Individual actions drive the system

Able to model emergence

“A phenomenon is emergent when it can only be described and characterised using terms and measurements that are inappropriate or impossible to apply to the component units”
- Gilbert (2004) page 3.

Appeal of ABM

Can include physical space / social processes

Designed at abstract level: easy to change scale

Bridge between verbal theories and mathematical models

Dynamic history of system

An essential ingredient for smart cities

Disadvantages of ABM

Known unknowns

We don’t know exactly what someone will do.

So we guess

E.g. there is a 30% change of little Jacob playing with his duck this morning, and a 70% chance of playing with his truck.

Models that use randomness like this are probabilistic

The need to run many times to ensure robust results

Disadvantages of ABM

Computationally expensive.

Complicated agent decisions

Lots of decisions!

Multiple model runs (robustness)

Modelling "soft" human factors

A benefit is that we can include complex psychology

But this is really hard!

Potential to over-complicate

Need to think carefully about what to include

Another disadvantage: data

Data required at every stage

Understanding the system / behaviour

Calibration and validation

But high-quality data are hard to come by

—Many sources are too sparse, low spatial/temporal resolution

Censuses focus on attributes rather than behaviour and occur infrequently

Also need data from numerous scales (e.g. pattern oriented modelling; Grimm et al. 2005)

Understanding social behaviour

How to estimate leisure times / locations? Where to socialise?

More on this later..

Another disadvantage: data

Question

Can you suggest some sources of information that we can use to inform our agent-based models?

What are we missing? (In a perfect world, what would you also like to know?)

Outline: Modelling Society

Modelling (Human) Behaviour

Human brain

Photo attributed to Arts Electronica ( CC BY-NC-ND 2.0)

One of the main advantages to Agent-Based Modelling.

But also really difficult

Subjective choices

Complicated psychology

(Seemingly) irrational behaviour

Also difficult decisions about what to include in a model

Modelling (Human) Behaviour

Quiz

Choose a number between 1 and 4

Write the number down on a slip of paper

What percentage of people do you think chose:

1?

2?

3?

4?

Modelling (Human) Behaviour

Results

"The most common response is 'three' and there is a secondary effect of this task: people feel a need to explain why they chose whatever answer they did. The second most common answer is 'two'. Very few people decide to respond with either 'one' or 'four'. Sadly, there is not a serious study of this behaviour but undocumented sources suggest that the response statistics are close to 50% for 'three', 30% for 'two' and about 10% for the other two answers." (Kennedy, 2012)

Key message: "Humans are not random. They (we) are strange and wonderful" (Kennedy, 2012)

The previous example shows that even simple decisions can be hard to predict

Fortunately there are architectures that can help with building behavioural models.

Rule-Based Systems

(Simple) Rules


IF hunger < hungerThreshold1 THEN 
    agent-dies
IF hunger > hungerThreshold2 THEN 
    address-another-goal
IF hunger > hungerThreshold1 and hunger < hungerThreshold2 THEN 
    search-for-food.
                    
Example decision tree

Node-based

E.g. decision trees

(Remember LOTR and MASSIVE ?)

Behaviour Based Artificial Intelligence (BBAI)

Layered behaviour

Upper layers take control when they can

Robot can default to lower-level behaviour

Behavioural modules, working concurrently compete/contribute to overall behaviour

Popular in robotics, less common in simulation.

See: Brooks, R. (1996) From Earwigs to Humans. Robotics and Autonomous Systems 20: 291--304

BDI flowchart

Beliefs, Desires, Intentions (BDI)

Beliefs:

Internal knowledge about the world

Memory of past experiences

Desires

Goals the agent is trying to achieve

Can be short and long term (e.g. 'eat food', 'raise children')

Can be contradictory

Intentions

The most important immediate goals

Can alter the rapidity with which an agent changes intentions (e.g. 'caution').

BDI flowchart

Beliefs, Desires, Intentions (BDI)

Probably the most common / popular architecture in ABM

Rational model

All action requires some deliberation

Good representation of human cognition (?). But:

Core elements hard to observe directly

Rational decisions only useful to a limited degree (e.g. pulling hand away from fire requires no rational thought)

PECS

Physical conditions, Emotional states, Cognitive capabilities and Social status (Schmidt, 2000)

Example PECS motives and intensity functions

Internal states

Physical

Emotional

Cognitive

Social

Motives

Intensity functions determine motive strength

Include level of need, personal preference, environment, others..

Strongest motive becomes action guiding motive

How realistic / complicated does the behaviour need to be?

Cognitive architectures help us to structure behaviour. But don't suggest what we should include

Two broad approaches that think about behavioural complexity:

KISS

Keep It Simple, Stupid

Start with the simplest model, build complexity if necessary

KIDS

Keep It Descriptive, Stupid

Start with a model that fully describes the system, then simplify if possible.

Remember Claudio's chair?

 

Axelrod, R. (1997). Advancing the art of simulation in the social sciences. In Conte, R., Hegselmann, R., and Terna, P. (eds) Simulating Social Phenomena , pages 21–40. Springer-Verlag, Berlin. (Draft chapter available online)

Edmonds, B. and Moss, S. (2005). From KISS to KIDS: an 'anti-simplistic' modelling approach. In Davidsson, P., Logan, B., and Takadama, K., editors, Multi Agent Based Simulation 2004, Lecture Notes in Artificial Intelligence, pages 130–144. Springer. Available online.

How to find out which behaviour is important?

Published literature

Talking to the experts

Numerical experimentation

Rigorous data analysis

Outline: Modelling Society

Agent-Based Modelling in Practice

Creating an agent-based model can be difficult

No standard software (e.g. R, SPSS, etc.)

Some programming usually required

Steep learning curve

Fortunately, numerous tools and libraries exist to help

Software tools

Computer code ('libraries')

Researchers write software to perform useful functions:

Draw graphs

Visualise the model

Manage the schedule

Great for programmers

Less time spend worrying about admin, more time on modelling

Examples:

MASON

Repast Simphony

Mageo

Loads of others listed here

Repast Simphony

Screen shot of Repast software

Written in Java

Models can be developed by programming (Java, CoffeeScript, ReLogo), or using the GUI

Relatively steep learning curve

Powerful and popular

C++ version designed for high-performance computer grids

Repast Simphony Example

Burglary

Mastermap topography

This model accurate geographical data for Leeds, UK

Buildings / houses

Roads

etc.

Behaviour:

PECS: drug addiction, sleep, socialise..

Able to explore the impacts that changes to the environment or changes in behaviour have on crime in a real area

www.youtube.com/embed/5ySbS075MyA

MASON

MASON 3D window

A joint effort between George Mason University's Evolutionary Computation Laboratory and the GMU Center for Social Complexity.

Simple, light-weight. Written in Java.

Coding skills needed, so steep learning curve.

But very powerful and easy extend / customise

Can run on high performance computer Grids

Crooks, A.T. and Wise, S. (2013), GIS and Agent-Based models for Humanitarian Assistance, Computers, Environment and Urban Systems, 41: 100-111. (pdf)

MASON

Example

ABM for modelling natural disasters and humanitarian assistance

Lots of 'crowd-sourced' becomming avaiable, but models are needed to predict (crowd) behaviour

Scenarios:

Reactions to distribution of aid

Rumour propogation

Emergency evacuations

For more information, see: http://www.css.gmu.edu/haiti/

Repast Simphony & MASON

Critique

Advantages

Flexible / customisable

Easy integration with other (Java) libraries

Free / Open Source

Execute on high performance grids

Disadvantages

Need to be programmed: steep learning curve

Complicated (?)

Graphical Environments

Repast behaviour editor

Entirely visual - no programming needed

Most useful for non-programmers

Examples

Agent Sheets

VisualBots

Repast Simphony

Modelling4All

Somewhere in the middle

NetLogo GUI

Some code writing, some visual development

More powerful than purely visual tools, but easier to use.

Save time having to learn to do simple tasks and concentrate on model behaviour

e.g. NetLogo

Base on Star Logo.

Popular teaching tool, originally Designed to be used by children

Very powerful, but also easy to learn

Easy to build models

Easy to interact with models

East to extract data and create plots

Excellent documentation: http://ccl.northwestern.edu/netlogo/docs/

NetLogo

Graphical part (Interface) with sliders, graphs, buttons and a map

Scripting part (Procedures) which contains instructions (code)

NetLogo program

NetLogo

Example: Exploring crime theory

Birks (2012) model environment

Birks et al. (2012)

Randomly generated abstract environments

Theoretical 'switches' (activate three different criminology theories)

Compare results to expected outcomes:

Spatial crime concentration

Repeat victimisation

Journey to crime curve

NetLogo

Example: Exploring crime theory

TheoryEnabledDisabled
Routine activities Agents assigned a 'home' and routine paths Random movements
Rational choice Victim attractiveness (based on risk, reward, effort) Homogeneous target attractiveness
Awareness space Dynamic awareness - alters offender decision-making Uniform environment awareness
Theoretical 'switches' in the model

Results:

All hypotheses are supported

Rational choice theory has lower influence

... somewhere else ...

There are loads of other packages that people are using in novel ways. E.g.

Second Life (see http://www.casa.ucl.ac.uk/abm/secondlife/

Conclusion / Final Thoughts

Cities are complex systems

ABM can capture many 'complex' properties

This makes them essential for understanding urban dynamics and designing 'smart' cities

Frameworks exist to organise behaviour in computer models

BUT: data to understand individual behaviour are hard to come by

Data sparcity for predictive modelling

The 'Big Data Revolution' might help...

Reading and Other Resources (I)

Papers - all offer excellent introductions to agent-based modelling

Macal, C. M., and North, M. J. (2010). Tutorial on agent-based modelling and simulation. Journal of Simulation, 4(3), 151-162. doi: 10.1057/jos.2010.3.

Bonabeau, E. (2002). Agent-based modeling: Methods and techniques for simulating human systems. Proceedings of the National Academy of Sciences, 99(90003), 7280-7287. doi: 10.1073/pnas.082080899.

O'Sullivan & Haklay (2000), Agent-based models and individualism: is the world agent-based?, Environment and Planning A (32), 1409-25

Castle, C. J. E. and Crooks, A. T. (2006). Principles and concepts of agent-based modelling for developing geospatial simulations. UCL Working Papers Series, Paper 110, Centre For Advanced Spatial Analysis, University College London. Available online.

Reading and Other Resources (II)

There is also a long list of papers here:

http://mass.leeds.ac.uk/2013/02/13/an-excellent-abm-paper/.

Textbooks

Batty, M., 2013. The New Science of Cities. MIT Press.

Heppenstall, A.J., Crooks, A.T., See, L.M., Batty, M. (2012) Agent-Based Models of Geographical Systems. Springer.

Cioffi-Revilla, C., 2014. Introduction to Computational Social Science, Texts in Computer Science. Springer, London. (Esp. chapter 10)

Prof. Bruce Edmonds is one of the big names in agent-based modelling. He has two videos that provide excellent introductions to the methodology

A short one: http://www.youtube.com/watch?v=JANTkSa4hmA

A longer version from a conference presentation: http://www.youtube.com/watch?v=9nEPxb2J73w

References

Axelrod, R. (1997). Advancing the art of simulation in the social sciences. In Conte, R., Hegselmann, R., and Terna, P. (eds) Simulating Social Phenomena , pages 21–40. Springer-Verlag, Berlin. (Draft chapter available online)

Batty, M. (2005). Agents, cells, and cities: new representational models for simulating multiscale urban dynamics. Environment and Planning A, vol. 37, pp. 1373-1394, 2005.

Batty, M., Axhausen, K.W., Giannotti, F., Pozdnoukhov, A., Bazzani, A., Wachowicz, M., Ouzounis, G., Portugali, Y., 2012. Smart cities of the future. The European Physical Journal Special Topics 214, 481–518. doi:10.1140/epjst/e2012-01703-3

Birks, Daniel, Michael Townsley, and Anna Stewart (2012). Generative Explanations of Crime: Using Simulation to Test Criminological Theory. Criminology 50(1) 221-254.

Cioffi-Revilla, C., 2014. Introduction to Computational Social Science, Texts in Computer Science. Springer, London.

Crooks, A.T. and Wise, S. (2013), GIS and Agent-Based models for Humanitarian Assistance, Computers, Environment and Urban Systems, 41: 100-111. (pdf)

Edmonds, B. and Moss, S. (2005). From KISS to KIDS: an 'anti-simplistic' modelling approach. In Davidsson, P., Logan, B., and Takadama, K., editors, Multi Agent Based Simulation 2004, Lecture Notes in Artificial Intelligence, pages 130–144. Springer. Available online.

Epstein, J., Axtell, R., 1996. Growing Artificial Societies: Social Science from the Bottom Up. Brookings Institution Press.

Gilbert, N. (2004). Agent-based social simulation: dealing with complexity. Available online [accessed - January 2007].

Groff, E. R. (2006). Exploring the Geography of Routine Activity Theory: A Spatio-temporal Test Using Street Robbery. Unpublished Dissertation, University of Maryland, College Park, MD.

Groff, E.R. (2007). "Situating" Simulation to Model Human Spatio‐Temporal Interactions: An Example Using Crime Events. Transactions in GIS 11, 507–530.

Heppenstall, A.J., Crooks, A.T., See, L.M., Batty, M. (2012) Agent-Based Models of Geographical Systems. Springer.

Kennedy, W.G., 2012. Modelling Human Behaviour in Agent-Based Models, in: Heppenstall, A.J., Crooks, A.T., See, L.M., Batty, M. (Eds.), Agent-Based Models of Geographical Systems. Springer Netherlands, pp. 167–179.

Malleson, N., Heppenstall, A., See, L., Evans, A. (2013) Using an Agent-Based Crime Simulation to Predict the Effects of Urban Regeneration on Individual Household Burglary Risk. Environment and Planning B: Planning and Design 40(3) 405–426

Schmidt, B., 2000. The Modelling of Human Behaviour. Society for Computer Simulation International, Ghent, Belgium.

CRDC Logo

Understanding Complex Social Phenomena with Agent-Based Modelling

Dr Nick Malleson
School of Geography, University of Leeds

http://nickmalleson.co.uk/
http://www.geog.leeds.ac.uk/people/n.malleson
Slides: http://mass.leeds.ac.uk/html/slides/Lipari2014/