1 / 51

Programming for Geographical Information Analysis: Advanced Skills

Programming for Geographical Information Analysis: Advanced Skills. Lecture 9: Modelling I: Agents and Netlogo Dr Andy Evans With additions from Dr Nick Malleson. Modelling Cellular Automata Agent-based models Netlogo. What are models?.

mastersj
Télécharger la présentation

Programming for Geographical Information Analysis: Advanced Skills

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming for Geographical Information Analysis:Advanced Skills Lecture 9: Modelling I: Agents and Netlogo Dr Andy Evans With additions from Dr Nick Malleson

  2. Modelling Cellular Automata Agent-based models Netlogo

  3. 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.

  4. Why model? Prediction: Future Past (backcasting) Testing our knowledge is complete. Emergence (how simple processes give us complicated patterns) Holding our knowledge in a framework.

  5. Virtual model types Analytical models Mathematical equation. Logical Prolog models; fuzzy logic; etc. Iterative models Finite element models; agent-based models Statistical models Regression equations; Bayesian nets; etc.

  6. Verisimilitude Abstract models: Simplified objects Subset of processes Thought experiments Verifythat core processes are appropriate Alternative is to try and model everything accurately. Is this possible in systems that don’t have closure?

  7. Model scale Aggregate models Regression Disaggregate models Range from area processing to individual-based Individual elements Finite-element models Agent-based models

  8. 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.

  9. 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.

  10. Modelling Identify interesting patterns Build a model of elements you think interact and the processes / decide on variables Verify model Optimise/Calibrate the model Validate the model/Visualisation Sensitivity testing Model exploration and prediction Prediction validation

  11. This lecture/practical Individual based modelling. Relatively abstract models Next few lectures More complexity/detail.

  12. Modelling Cellular Automata Agent-based models Netlogo

  13. 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.

  14. 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.

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

  16. One dimensional CA Steven Wolfram classified CAs into… Class 1always 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.

  17. 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.

  18. 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.

  19. 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.

  20. The Game of Life Game of Life If dead, and alive neighbours = 3 → Alive If alive, and alive neighbours < 2 → Die of loneliness If alive and alive neighbours > 3 → Die of overcrowding Otherwise, stays as it is.

  21. Two dimensional Game of Life CA In two dimensions, over time, some CA cell combinations form moving or periodically repeating multi-cellular organisms.

  22. Classic two dimensional CA uses Modelling forest fires. Modelling animal and plant systems. Finding routes through mazes / landscapes etc.

  23. Other uses SLEUTH 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/

  24. 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?

  25. 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.

  26. Axelrod’s competition Imagine 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.

  27. SIMCity Jay 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”.

  28. The SIMs Latest 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.

  29. Other Basic Competitive Agent Environments SugarScape. RoboCode.

  30. 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 Class Has environmental conditions. Calls the agents to update. Agents might, for example, trade with their nearest neighbours.

  31. Examples 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.

  32. 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.

  33. 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).

  34. Flocks - how they act

  35. Massive http://www.lordoftherings.net/effects/simulator.html Prologue > Armies > Massive Simulator

  36. Uses of Flocking Agents Simulating how crowds move. Popular Post-Hillsborough. Notting Hill Carnival Controlling resilient robot networks.

  37. ABM Frameworks What are they? Pieces of software to help people build ABMs Wide range of tools Pre-written functions Entire graphical environment Somewhere in the middle

  38. Why use them? For non-programmers: Graphical “point-and-click” model development. Easier than having to learn a programming language. For programmers: No need to write ‘external’ functionality (e.g. drawing graphs, scheduling events, creating displays). Can concentrate on model logic. Save time (?)

  39. Other Advantages Create an Applet (Netlogo). Talk to other programs, e.g. R, Weka, MATLAB. Output information (to databases, flat files, reports etc). many more…

  40. Commonly Used Platforms Netlogo: http://ccl.northwestern.edu/netlogo/ Repast: http://repast.sourceforge.net/ MASON: http://cs.gmu.edu/~eclab/projects/mason/ Ascape: http://ascape.sourceforge.net/ ABLE: http://www.research.ibm.com/able/ Agent Analyst: http://www.spatial.redlands.edu/agentanalyst/

  41. Introduction to Netlogo Based on “StarLogo” Popular teaching tool Aimed at school children, very easy to learn and use Implemented in Java Cross-platform (models will run on any computer which runs Java). Uses its own scripting language –Java is hidden Excellent documentation http://ccl.northwestern.edu/netlogo/docs/

  42. NetLogo basics Two windows: Interface and Procedures Interface contains graphical elements Procedures are user-defined functions

  43. NetLogo Basics: The Interface Lots of items can be added to view or control the simulation These are linked to model code Sliders: set a variable value Buttons: call a procedure Monitors: output the value of a variable Plots: create a graph of variable(s)

  44. NetLogo Basics: Turtles and Patches Turtles are the agents Move around Make decisions Interact with other turtles Interact with patches Patches are the grid cells Cannot move, but can interact with other patches, and with turtles

  45. NetLogo Basics: buttons Example: ‘setup’ button and code

  46. NetLogo Basics: Built-in Commands Set the colour of all patches: ask patches [ set pcolor yellow ] Set the name of turtle 12: ask turtle 12 [ set name “bob”] 0.01 probability that each turtle will give birth ask turtles [ if random 100 <1 [ set give-birth? True] ] Change colour of houses surrounding person 12 ask turtle 12 [ ask neighbors4 [ set pcolor blue ] ]

  47. NetLogo Basics: Commands Commands make complicated functions easy: NetLogo command: Set the colour of the houses surrounding person 12: ask person 12 [ ask neighbors4 with [ ptype= "house" ] [ set pcolorblue ] ] Java command: for (inti=0; i<people.size(); i++) { // Loop over all people if (people.get(i).getID() == 12 ) { // Find person 12 for (int j=0; j<houses.size(); j++) { // Loop over all houses if ( <house next to person> ) { // Work out house/person position house.setColour(blue); // Set the house colour } } } }

  48. What’s Netlogo good for? Rapid model design. Abstract thought experiments. Verification testing on abstract landscapes.

  49. 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://mass.leeds.ac.uk/ Craig Reynold’s website. http://www.red3d.com/cwr/boids/

  50. 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.

More Related