Presentation is loading. Please wait.

Presentation is loading. Please wait.

NetLogo Workshop Complexity And Business Analytics October 10, 2008, UM-Dearborn David Bowen, WSU Physics Slides and model files will.

Similar presentations


Presentation on theme: "NetLogo Workshop Complexity And Business Analytics October 10, 2008, UM-Dearborn David Bowen, WSU Physics Slides and model files will."— Presentation transcript:

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

2 10/10/08NetLogo Workshop2 As a result of this workshop, (I hope) you will be able to: 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

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

4 10/10/08NetLogo Workshop4 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): oCharacteristics or properties of agent Homogenous or diverse agents oRules or methods of interaction Example: Preferentially link to the most popular agent (the one that already has the most links)

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

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

7 10/10/08NetLogo Workshop7 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

8 10/10/08NetLogo Workshop8 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

9 10/10/08NetLogo Workshop9 Download and Install URL: ccl.northwestern.edu/netlogo/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

10 10/10/08NetLogo Workshop10 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

11 10/10/08NetLogo Workshop11 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 oTurtles-own establishes properties (characteristics) oButton name starts “to” procedure with that name o; for comment, can be whole or last part of line

12 10/10/08NetLogo Workshop12 Models Library File > Models Library > Computer Science > Cellular Automata > Life Cellular Automaton  Here, patches = cells, no turtles oDark = cell alive, background color = dead  Cell with 3 live neighbors comes to life  Live cell with two live neighbors continues to live oOtherwise cell dies

13 10/10/08NetLogo Workshop13 Models Library Social Science > Party (famous in another form)  Schelling model – two types of people oHere, men and women oOriginally, Black and White oOtherwise 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

14 10/10/08NetLogo Workshop14 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

15 10/10/08NetLogo Workshop15 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

16 10/10/08NetLogo Workshop16 Models on NetLogo site URL: ccl.northwestern.edu/netlogo/ > Community Modelsccl.northwestern.edu/netlogo/ 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

17 10/10/08NetLogo Workshop17 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 Modelswww.is.wayne.edu/drbowen/  Brownian motion works  Big Bang model Other things NetLogo can do

18 10/10/08NetLogo Workshop18 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

19 NetLogo Workshop Part 2 Modify Roll your own

20 10/10/08NetLogo Workshop20 Programming Resources Help > User Manual  Tutorials  Interface Guide – World, Menu items, Controls oWorld - Settings: size, wrapping Vs reflecting  Programming Guide – big picture oTypes: observer (starts off), turtle, patch, link oWhat can I do with agents?  NetLogo Dictionary – the nitty gritty oAlphabetical list oBy type

21 10/10/08NetLogo Workshop21 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 oBuilt-in: pxcor, pycor, pcolor oliving? - ? makes this logical (true/false only) 3  4, 2  3 File > Save As a new name, e.g. LifeDB on desktop

22 10/10/08NetLogo Workshop22 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

23 10/10/08NetLogo Workshop23 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

24 10/10/08NetLogo Workshop24 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?

25 10/10/08NetLogo Workshop25 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: oAlways link to n+1 oIf init-links = 2 or 3 then also link to n + 2 oIf init-links = 3 then also link to n + 3  Dictionary: if condition [ commands ]

26 10/10/08NetLogo Workshop26 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 oWe might eventually want a better fix

27 10/10/08NetLogo Workshop27 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

28 10/10/08NetLogo Workshop28 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?

29 10/10/08NetLogo Workshop29 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)

30 10/10/08NetLogo Workshop30 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 ?

31 10/10/08NetLogo Workshop31 Programming in NetLogo Context: who is acting?  ask turtles [ commands ] sets context to turtles oAgents 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 ]

32 10/10/08NetLogo Workshop32 Simple Model Model will:  Setup oCreate turtles with random headings (this is the default), positions, speed  Go oLet turtles go with speed and headings oRandomly change speed and headings  Sliders to control speed range and size of heading changes

33 10/10/08NetLogo Workshop33 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)

34 10/10/08NetLogo Workshop34 Network Model Model will:  Setup oCreate a set of turtles with random positions oCreate a random set of links between the turtles Each turtle has same chance of having links  Go Once oPick 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

35 10/10/08NetLogo Workshop35 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

36 10/10/08NetLogo Workshop36 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 agentset

37 10/10/08NetLogo Workshop37 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

38 10/10/08NetLogo Workshop38 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

39 10/10/08NetLogo Workshop39 And… 3D Numerical modeling (modeling number of agents, etc.) Flying behind a turtle Back


Download ppt "NetLogo Workshop Complexity And Business Analytics October 10, 2008, UM-Dearborn David Bowen, WSU Physics Slides and model files will."

Similar presentations


Ads by Google