Netlogo introduction

advertisement
ABM Frameworks
Dr Andy Evans
With additions from Dr Nick Malleson
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
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 (?)
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…
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/
Modelling4All: http://www.modelling4all.org/
SecondLife: http://secondlife.com/
Agent Analyst: http://www.spatial.redlands.edu/agentanalyst/
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/
Model Examples
Demo “Ants” from model library
NetLogo basics
Two windows: Interface and Procedures
Interface contains graphical elements
Procedures are user-defined functions
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)
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
NetLogo Basics: buttons
Example: ‘setup’ button and code
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 ]
]
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 pcolor blue ]
]
Java command:
for (int i=0; i<people.size(); i++) {
if (people.get(i).getID() == 12 ) {
for (int j=0; j<houses.size(); j++) {
if ( <house next to person> ) {
house.setColour(blue);
}
}
}
}
//
//
//
//
//
Loop over all people
Find person 12
Loop over all houses
Work out house/person position
Set the house colour
What’s Netlogo good for?
Rapid model design.
Abstract thought experiments.
Verification testing on abstract landscapes.
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/
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.
Download