netlogo workshop l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
NetLogo Workshop PowerPoint Presentation
Download Presentation
NetLogo Workshop

Loading in 2 Seconds...

play fullscreen
1 / 39
tanner

NetLogo Workshop - PowerPoint PPT Presentation

104 Views
Download Presentation
NetLogo Workshop
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. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Slides and model files will be at www.is.wayne.edu/drbowen > NetLogo workshop NetLogo Workshop Complexity And Business Analytics October 10, 2008, UM-Dearborn David Bowen, WSU Physics d.r.bowen@wayne.edu

  2. 12:30 – 2:10 Describe agent-based modeling Download & install NetLogo Find & use existing models installed with NetLogo & on NetLogo website 2:30 – 4:10 Modify an existing NetLogo model Build a new NetLogo model As a result of this workshop, (I hope) you will be able to: NetLogo Workshop

  3. NetLogo Workshop Part 1 Agent-based modeling Download and Install Find and run

  4. Agent-Based Modeling • What is agent-based modeling? • Simulating a set of acting/interacting agents • Examples of agents: people, organs, molecules, planets, family units, corporations, ribosomes • Modeler assigns (programs): • Characteristics or properties of agent • Homogenous or diverse agents • Rules or methods of interaction • Example: Preferentially link to the most popular agent (the one that already has the most links) NetLogo Workshop

  5. Agent-Based Modeling • What is agent-based modeling? • Agent-based modeling environment/toolkit: • Steps agents through actions/interactions • Displays agents, charts indicators, saves data • NetLogo has four basic types of agents A: always • A Observer: sees all • A Turtles (agents), modeler can create subtypes • S Links between turtles, can have subtypes • A Patches or pieces of background • Can be “invisible” but sometimes important (grass in Sheep and Wolves) NetLogo Workshop

  6. Agent-Based Modeling • Where is agent-based modeling used? • Everywhere, e.g. all academic departments • Natural systems (science, engineering etc.) • Many existing simulation techniques, question is purpose, strengths, weaknesses • Social systems (humanities, social science, business/marketing etc.) • Often the best or only laboratory available NetLogo Workshop

  7. Agent-Based Modeling • Types of use • Real-world simulation, optimization • Research • Classroom: learning, demo, homework • Alternatives to making your own models • Models Library downloads with installation • Publicly available models • Modify and existing model NetLogo Workshop

  8. Agent-Based Modeling • About NetLogo • Uri Wilensky et al. at Center for Connected Learning and Computer-Based Modeling at Northwestern University • “Low floors, high ceilings” • Free download • Java-based (run anywhere) but private Java copy • Discussion forums, technical support, continuous development NetLogo Workshop

  9. Download and Install • URL: ccl.northwestern.edu/netlogo/ • Notice: mail lists, Resources (more models) • Download on the left • Save to desktop (because of rights on these computers, elsewhere you can accept the default) • Double-click on downloaded file to install (NetLogo4.0.3Installer.exe) • Location: up-arrow to desktop, add \NetLogo > Next • Accept all other defaults NetLogo Workshop

  10. Run • Start > All Programs > NetLogo > NetLogo 4.0.3 • Notice: • File menu item (top left) – Models Library, etc • Interface – “the model” • Information – How to use & change the model • Procedures – the code NetLogo Workshop

  11. Models Library • File > Models Library • Checked except for (unverified) • Biology > Heatbugs (famous) • Double-click model name or picture to open • Setup then Go (Go again pauses) • Information – what the model is doing • Procedures • Turtles-own establishes properties (characteristics) • Button name starts “to” procedure with that name • ; for comment, can be whole or last part of line NetLogo Workshop

  12. Models Library • File > Models Library > Computer Science > Cellular Automata > Life • Cellular Automaton • Here, patches = cells, no turtles • Dark = cell alive, background color = dead • Cell with 3 live neighbors comes to life • Live cell with two live neighbors continues to live • Otherwise cell dies NetLogo Workshop

  13. Models Library • Social Science > Party (famous in another form) • Schelling model – two types of people • Here, men and women • Originally, Black and White • Otherwise the same – properties and methods • How comfortable are these agents with those of the other type – slider • Even a slight preference can lead to complete segregation NetLogo Workshop

  14. Models Library • File > Models Library > Networks > Small Worlds (famous – six degrees of separation) • Uses links • Path along links from one agent to another • Setup = ring, links to 2 nearest on each side • Average path length for all pairs of agents • Even a few links across the ring reduces the average path length significantly • Significant in organizations, e.g. businesses NetLogo Workshop

  15. Models Library • File > Open > Biology > Wolf Sheep Predation • Different kinds of agents, including patches • Click grass? Switch to On • Boom-and-bust cycles very common NetLogo Workshop

  16. Models on NetLogo site • URL: ccl.northwestern.edu/netlogo/ >Community Models • Possible problems if models are written for earlier versions of NetLogo • My Two-color gas works with 4.0.3 • My Brownian motion doesn’t NetLogo Workshop

  17. NetLogo Models on the Web • Solves problems with old versions since Java Virtual Machine (VM) downloaded also (but different versions can coexist) • www.is.wayne.edu/drbowen/ > Classroom Models • Brownian motion works • Big Bang model • Other things NetLogo can do NetLogo Workshop

  18. Extensions • Array, Table, GoGo, Profiler, GIS, Sample, and Sound are in the standard installation • In Extensions subfolder of NetLogo installation folder • Each is explained in Help > NetLogoUser Manual > Extensions • Some (GIS, Table) come with existing models NetLogo Workshop

  19. NetLogo Workshop Part 2 Modify Roll your own

  20. Programming Resources • Help > User Manual • Tutorials • Interface Guide – World, Menu items, Controls • World - Settings: size, wrapping Vs reflecting • Programming Guide – big picture • Types: observer (starts off), turtle, patch, link • What can I do with agents? • NetLogo Dictionary – the nitty gritty • Alphabetical list • By type NetLogo Workshop

  21. Modify One • File > Model Library > Computer Science > Cellular Automata > Life • Procedures – scan to numbers 3 and 2 • On the way • patches-own – creates properties for patches • Built-in: pxcor, pycor, pcolor • living? - ? makes this logical (true/false only) • 3  4, 2  3 • File > Save As a new name, e.g. LifeDB on desktop NetLogo Workshop

  22. Modify Life • Add a slider to vary number on interface • Click on down-arrow to select slider • Global variable init-number, 1 to 5, value 2 • Then right-click to Select, squeeze it in • In Procedures, 2 init-number, 3  init-number + 1 / Save, Setup then Go NetLogo Workshop

  23. Modify Life • You now load this modified version from the desktop or by double-clicking the desktop icon • “Back home” you can keep the .NLOGO file in any folder you choose NetLogo Workshop

  24. Modify Small Worlds • File > Models Library > Networks >Small Worlds • On interface, put in a slider: • Global variable init-links • Minimum 1 • Increment 1 • Maximum 3 • Value 2 • Save on desktop under a new name • Add initials? NetLogo Workshop

  25. Modify Small Worlds • Procedures, scroll through (bigger than Life) • Find to setup, then see make-turtles then wire-them (this creates the links) • About 75% down (Find?) find to wire-them • What we want to do: • Always link to n+1 • If init-links = 2 or 3 then also link to n + 2 • If init-links = 3 then also link to n + 3 • Dictionary: if condition [ commands ] NetLogo Workshop

  26. Modify Small Worlds • Error when running with init-links = 1; divide by zero • Divide by clustering-coefficient-of-lattice divide by dum, protect dum from being zero • We might eventually want a better fix NetLogo Workshop

  27. Modifying Models • Find a model that does something close to what you want, and modify it to suit • For these modified models, we should go back and update the information • Structured and commented code helps – do this for yourself, too NetLogo Workshop

  28. Roll Your Own • Decisions needed • System to be modeled • What do the agents represent? • What are the rules of action and interaction? • How will you approximate these rules for entry into the modeling environment? • What does a tick (cycle) represent? NetLogo Workshop

  29. Other • You might want to change the World settings • Size • Location of 0, 0 • Wrapping or box • Patch size (also determines size of world screen) NetLogo Workshop

  30. Programming in NetLogo • Case-insensitive • To set a equal to b: set a b • Arithmetic operators must have space on either side: set a 3 * b • Can use parentheses to control order • Use [ ] to block code statements • White space ignored after minimum space • Routines start with to, end with end • No number types • Logical variables end in ? NetLogo Workshop

  31. Programming in NetLogo • Context: who is acting? • ask turtles [ commands ] sets context to turtles • Agents can ask other agents or even other types of agents • ask turtles [ … ask links [ … ]… ] • Only that particular agent can find the value or change a value that it owns • If one agent (e.g. a turtle) is acting, other turtles is set of all other turtles, one-of other turtles is a random other • stop to stop asking • breed to subtype an agent: breed [ cats cat ] NetLogo Workshop

  32. Simple Model • Model will: • Setup • Create turtles with random headings (this is the default), positions, speed • Go • Let turtles go with speed and headings • Randomly change speed and headings • Sliders to control speed range and size of heading changes NetLogo Workshop

  33. Simple Model • Built-in turtle variables (each turtle has its own) • breed (sub-type) • Color (defaults to random for each turtle) • Heading (degrees, 0 = up, 90 = right) • hidden? • label, label-color • pen-mode, pen-size • shape • size • Who (a number) • xcor, ycor (by default 0, 0) NetLogo Workshop

  34. Network Model • Model will: • Setup • Create a set of turtles with random positions • Create a random set of links between the turtles • Each turtle has same chance of having links • Go Once • Pick a random turtle and a random one of its links, and replace it within one attached preferentially • Higher chance of linking to a turtle with the most links NetLogo Workshop

  35. Network Model • Start new model, save it to desktop as Network • Go to Model Library, open Network > Preferential Attachment, copy layout and limit-magnitude to clipboard and then into Procedures window, and resave • Will make a better World plot NetLogo Workshop

  36. Network Model • Agentset – a list set of agents • Defaults to a random order but can be sorted • Can be “traversed” – go through all agents in the list by asking • Can also pick a random agent from the list • If we want angentset to persist, must set it to a name we have previously declared in globals or locally • If we have picked a turtle, other turtles is an agentset of all of the other turtles NetLogo Workshop

  37. Agentsets and Lists • Agentset: an unordered set of agents of any type, including breeds • Order is randomized on each use • Can ask agentset [ list of commands ] • Current agent in “ask” sequence: self • List: an ordered list of any objects, including agents • Order is always the same unless you change it • Can be sorted, etc. • Current list item in “for each” sequence: ? Return to slide 36 NetLogo Workshop

  38. Jumpers • Transport • Agents jump by patches left to right • Have to wait at each patch for its individual wait count, can’t jump on top of another • Setup: • Initialize patches with wait counts, color-code • Go: • Turtles jump to right if wait count reached and that patch is empty • After jumping off last patch on right, turtle dies NetLogo Workshop

  39. And… • 3D • Numerical modeling (modeling number of agents, etc.) • Flying behind a turtle • Back NetLogo Workshop