Introduction to Agent-Based Modelling Dr Andy Evans.

38
Introduction to Agent-Based Modelling Dr Andy Evans

Transcript of Introduction to Agent-Based Modelling Dr Andy Evans.

Page 1: Introduction to Agent-Based Modelling Dr Andy Evans.

Introduction to Agent-Based Modelling

Dr Andy Evans

Page 2: Introduction to Agent-Based Modelling Dr Andy Evans.

What are models?

Hypothetical or Theoretical statement of how a system works, ignoring “accidental” influences.

Physical recreation of the same using scaled objects and applying the same processes.

Computer recreation of the same using virtual objects and applying virtual processes.

Page 3: Introduction to Agent-Based Modelling Dr Andy Evans.

Why model?

Prediction:FuturePast (backcasting)

Testing our knowledge is complete.Emergence (how simple processes give us complicated patterns)

Holding our knowledge in a framework.

Page 4: Introduction to Agent-Based Modelling Dr Andy Evans.

Virtual model types

Analytical modelsMathematical equation.

LogicalProlog models; fuzzy logic; etc.

Iterative modelsFinite element models; agent-based models

Statistical modelsRegression equations; Bayesian nets; etc.

Page 5: Introduction to Agent-Based Modelling Dr Andy Evans.

Verisimilitude

Abstract models: Simplified objectsSubset of processes

Thought experimentsVerify that core processes are appropriate

Alternative is to try and model everything accurately.Is this possible in systems that don’t have closure?

Page 6: Introduction to Agent-Based Modelling Dr Andy Evans.

Model scale

Aggregate modelsRegression

Disaggregate modelsRange from area processing to individual-based

Individual elementsFinite-element modelsAgent-based models

Page 7: Introduction to Agent-Based Modelling Dr Andy Evans.

Individual level modelling

Aggregate representation was good when it all had to be done in our heads.

Now we have power for individual representation, i.e. as we understand the world.

We struggle to understand emergence – how simple rules of individuals end up in complicated system behaviour.

Page 8: Introduction to Agent-Based Modelling Dr Andy Evans.

Emergence

May seem subjective (how to do recognise “complicated”, why worry about other scales?)

But subjective aggregate elements have a big effect (e.g. inflation rates affect interest rates)

Systems of small scale elements that combine to make large scale systems in unclear ways are called complex.

Individual-level models are a useful way of exploring complexity.

Page 9: Introduction to Agent-Based Modelling Dr Andy Evans.

Modelling

Identify interesting patternsBuild a model of elements you think interact and the processes / decide on variablesVerify modelOptimise/Calibrate the model Validate the model/VisualisationSensitivity testingModel exploration and predictionPrediction validation

Page 10: Introduction to Agent-Based Modelling Dr Andy Evans.

Cellular Automata (CA) and Agent-Based Models (ABM)

Page 11: Introduction to Agent-Based Modelling Dr Andy Evans.

Cellular Automata (CA)

Can be used for searching/simulation but much much more.

Essentially a grid of cells which may be different states dependant on the conditions around them.Each cell has a rule base determining how it reacts.

For example, if a cell has less than two neighbours it dies, if it has more than two it reproduces and the

neighbouring cells come alive.Can be used for searches, modelling crowds, ecosystems etc.

Page 12: Introduction to Agent-Based Modelling Dr Andy Evans.

One dimensional CA

Simplest CA: a line of cells.

Each cell has a number of states it can be in, depending on the state of its neighbours and itself at the last time step.

Usually drawn as a line of cells, with each line below each other being another time step.

Simple rules can generate complex emergent behaviour.

Page 13: Introduction to Agent-Based Modelling Dr Andy Evans.

EmergenceFrom the simple rule: if both neighbours the same as you, go white else go black.

Page 14: Introduction to Agent-Based Modelling Dr Andy Evans.

One dimensional CA

Steven Wolfram classified CAs into…

Class 1 always end in the same stable state.

Class 2 settle into repeat patterns.

Class 3 chaotic / white noise patterns.

Class 4 complex patterns of near repetition with movement.

Shows the wide range of natural patterns that could develop from simple rules.

Page 15: Introduction to Agent-Based Modelling Dr Andy Evans.

One dimensional CA uses

While they show that complex patterns can emerge from simple rules, this isn’t necessarily happening.

However, we can use them to see if our simple rules develop complex patterns, and how resistant they are to perturbations to the starting conditions.

E.g. crowd flow, street development, river networks.

Page 16: Introduction to Agent-Based Modelling Dr Andy Evans.

The Schelling Model

Thomas Schelling (Harvard) looked at racial segregation.

Found that even if people were willing to live in areas made up of 50% other skin colours, segregation would develop.

1D CA. Cells either 1 or 0 (“black” or “white”).

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

Page 17: Introduction to Agent-Based Modelling Dr Andy Evans.

Two + dimensional CA

Real power in geography comes from having two dimensions.

Grid of cells that interact.Complex behaviour emerges that includes movement like a multi-cellular organism.

John von Neumann (1966) came up with the idea.John Conway (late 60’s) “Game of Life” simplified it and gave it purpose.

Page 18: Introduction to Agent-Based Modelling Dr Andy Evans.

The Game of Life

Game of LifeIf dead, and alive neighbours = 3 →

Alive If alive, and alive neighbours < 2 →

Die of lonelinessIf alive and alive neighbours > 3 →

Die of overcrowdingOtherwise, stays as it is.

Page 19: Introduction to Agent-Based Modelling Dr Andy Evans.

Classic two dimensional CA uses

Modelling forest fires.Modelling animal and plant systems.Finding routes through mazes / landscapes etc.

Page 20: Introduction to Agent-Based Modelling Dr Andy Evans.

Other usesSLEUTH Model of Keith Clarke (Santa Barbara).Uses CA to investigate urban growth.

Uses current urban areas, slope, transport, landuse, exclusions.

Grows cities. Used to study “what if?” scenarios.Essentially a whole new way of looking at urban form.Gigalopolis: http://www.ncgia.ucsb.edu/projects/gig/

Page 21: Introduction to Agent-Based Modelling Dr Andy Evans.

The lessons of CA

Perfect fidelity (representation) isn’t necessary to model the world.

Simple rules can lead to realistic and complex behaviour.

These can be quite robust – missing information can turn out to be irrelevant to generating patterns, and they can often survive changes.

However, representing the world as fixed and movement by state-changes seems wrong. Why not move the objects?

Page 22: Introduction to Agent-Based Modelling Dr Andy Evans.

Intelligent Agents

In part evolved from CAs.

Essentially free moving cells or programs that intelligently interact with each other and their environment.

One of the most important was Robert Axelrod’s 1980 cooperation competition.

Page 23: Introduction to Agent-Based Modelling Dr Andy Evans.

Axelrod’s competitionImagine you’re an agent.

If you cooperate with another agent, you get a moderate reward.Alternatively, if they’re suckered into cooperating with you, and you stab them in the back, you get a massive reward.However, if you both stab each other in the back, you get very little.

The competition invited people to put in agents with different behaviours to see who won after hundreds of rounds. Consistently it was “Tit-for-tat”. Starts off cooperating but punishes backstabbers.This competition was later run with intelligent 2D CAs.

Page 24: Introduction to Agent-Based Modelling Dr Andy Evans.

SIMCityJay Forrester (1970) “Urban Dynamics” Describes cities as complex interacting dynamic systems.

1985 - 1987 Will Wright takes Forrester’s principals and builds them into a “bottom up” system of CA-like components “SIMCity”.

Page 25: Introduction to Agent-Based Modelling Dr Andy Evans.

The SIMsLatest version “The SIMs” moved to direct autonomous humanoid intelligent agents.Similar agent based games include Populus (1989) and Civilization (1991). Intelligent agents are also used in games like Half-Life (1999). The agents adapt to player strategies.

Page 26: Introduction to Agent-Based Modelling Dr Andy Evans.

Other Basic Competitive Agent Environments

SugarScape.RoboCode.

Page 27: Introduction to Agent-Based Modelling Dr Andy Evans.

Coding an Agent

Agent Class Has an update method called each iteration, eg. move(),

trade().Has a position.Has a list of all other agents and can get their position.Can communicate with other agents if necessary.

Environment ClassHas environmental conditions.Calls the agents to update.

Agents might, for example, trade with their nearest neighbours.

Page 28: Introduction to Agent-Based Modelling Dr Andy Evans.

Uses

Modelling crime.

Modelling city development.

Modelling ecology.

Modelling land management.

Page 29: Introduction to Agent-Based Modelling Dr Andy Evans.

Petrol Price Modelling: can we determine the rules used by petrol stations to set their prices by guessing them from the patterns?

Landscape fragmentation and aphid infection.

Itzhak Benenson’s model of Tel-Aviv migration under ethnic influxes.

Kai Nagel’s team at ETH in Switzerland. Model ~1million people in Zurich.

Examples

Page 30: Introduction to Agent-Based Modelling Dr Andy Evans.

Flocks: agent based swarms

Utilise the emergent character of agents working together to produce groups that follow each other

Like herds of animals, flocks of birds, or schools of fish.

Page 31: Introduction to Agent-Based Modelling Dr Andy Evans.

Flocks

Invented by Craig Reynolds (1986).Each agent has the following rules…

Avoid colliding with your neighbour most of all.Fly in the average direction of your neighbours.Try to move into the centre of the flock (to prevent being

eaten / to go for optimal solutions).

Page 32: Introduction to Agent-Based Modelling Dr Andy Evans.

Flocks - how they act

Page 33: Introduction to Agent-Based Modelling Dr Andy Evans.

Massive

http://www.lordoftherings.net/effects/simulator.htmlPrologue > Armies > Massive Simulator

Page 34: Introduction to Agent-Based Modelling Dr Andy Evans.

Uses of Flocking Agents

Simulating how crowds move.Popular Post-Hillsborough.

Notting Hill CarnivalControlling resilient robot

networks.

Page 35: Introduction to Agent-Based Modelling Dr Andy Evans.

Our model

Agents like herbivores.Move round and eat resources.Communicate with other agents to check not in area.

Could equally be the base of:Burglar modelTrade model Farm management

Page 36: Introduction to Agent-Based Modelling Dr Andy Evans.

Our software

Read data file.Save results file.Do some processing.

Page 37: Introduction to Agent-Based Modelling Dr Andy Evans.

Further info

Steven Wolfram “A new kind of science”A major project applying CAs to Life, the Universe and Everything.

MultiAgent Systems and Simulation http://www.geog.leeds.ac.uk/groups/mass/

Craig Reynold’s website.http://www.red3d.com/cwr/boids/

Page 38: Introduction to Agent-Based Modelling Dr Andy Evans.

Further info

Flake (2000) The Computational Beauty of Nature: Computer Explorations of Fractals, Chaos, Complex Systems, and Adaptation.

Wooldridge (2009) An Introduction to MultiAgent Systems.