Home
Introduction to NetLogo Outline
Contents
1. 17 10 2013 Introduction to NetLogo Advanced Methods of Modelling and Simulation 2013 2014 Outline e Introduction to NetLogo e Turtles Patches and others Interface Programming Concepts Skeleton set up Some about plotting in NetLogo Extensions amp Tools e Some examples 17 10 2013 Introduction to NetLogo What is NetLogo A programmable modelling environment for simulating natural and social phenomena Uri Winlensky 1999 Agent based M amp S tool Well suited for modelling complex systems Hundreds or thousands of independent agents operating concurrently Exploring the connection between the micro level behaviour of individuals and the macro level patterns that emerge from the interaction of many individuals Introduction to NetLogo What is NetLogo Easy to use application development environment Quickly testing hypotheses about self organized systems e Open simulations and play with them Large collection of pre written simulations in natural and social sciences that can be used and modified Simple scripting language User friendly graphical interface 17 10 2013 Introduction to NetLogo The World of NetLogo e NetLogo consists of agents living in a 2 D world divided into a grid of patches e Three different type of agents plus one more Turtles are the agents that move around the world Patches are the pieces of ground on which turtles can move Links are agents tha
2. a finite set of instructions and exists the procedure to setup to draw polygon num sides size clear all pd repeat num sides create 10 fd size rt 360 num sides end end e Reporter computes a result and report it e Usually begin with nouns or nouns phrases to report absolute value number ifelse number gt 0 report number report 0 number end Introduction to NetLogo Programming Concepts Variables i e Variables e Global variables there is only one value for the variable and every agent can access it e Agent variables Each turtle has its own value for every turtle variable The same goes for patches and links Think of it as agent properties e Local variable defined and used only in the context of a particular procedure e scope of a variable 11 17 10 2013 Introduction to NetLogo Programming Concepts Variables ii Any variable can typically receive any value type at any given time except global variables that come from GUI components sliders etc In NetLogo variable values can be of the following types Numbers 1 2 0 5 0 1235 Strings xpto a 123xpto Boolean true false Agents turtle 1 patch 0 0 link 0 one of turtles Agentsets turtles patches n of turtles n of links Lists 1 2 3 4 list 1 2 list 123 456 Introduction to NetLogo Programming Concepts Variables iii Built in e Turtle variables color xcor ycor h
3. ask patches in radius 1 set grass 0 1 my grass Change turtles e ask turtles here set sick true set color blue in Summary Introduction to NetLogo GUI Controls Settings Views Interface Information Procedures 4 3 e O Edit Delete Add CEE l normal speed Y view updates i mias ve CD keep treck of how much grass there 1s 33 Sheep ond solves ore both breeds of turtle breed sheep o sheep i breed wolves nol turtles onn energy sheep is its oan plurel so we use o sheep os the singular i both wolves end sheep have energy potches omn eount oan to setup cleer lt lt esk porches set peolor green 35 heck GRASS switch then gross grons ond the sheep eot i F At false then the sheep don t need to ect Af gross osk patches set contdomn rondom gress regronth tine initiolize gross grow clocks rondonty set peolor one of green brow Set defaslt shape sheep sheep create sheep initiel rumber sheeg t i create the sheep then initialize thelr voriobles set color shite set size 1 5 5 easter to see set Lebel color blue 2 set energy rondon 2 sheep gain fron food etay rendoe xcor rendom ycor Set defoslt shope wolves rolf crecte molves initicl nusber wolves crecte the wolves then initiclize their varicbles t set color block set size 1 5 5 easter to see set energy rondon 2 wolf goin froe food sety rendom acor rondom yco
4. ass 4 0 0 0 0 Plots display the history of a variable s value Turtles at Peaks 17 10 2013 Introduction to NetLogo GUI Views e Graphics window The main view of the 2 D NetLogo world Y view updates yr Adjust speed normal speed right click brings up turtle patch inspector Introduction to NetLogo Programming Concepts Agents Procedures Variables Ask Ageniset Breeds Synchronization 17 10 2013 Introduction to NetLogo Programming Concepts Agents Each agent can carry out its own activity all simultaneously e Patches e Form the 2D world They don t move but they sense e They have integer coordinates pxcor pycor e Can generate turtles e Turtles move on top of the patches e have decimal coordinates xcor ycor and orientation heading e Observer e Can create new turtles e Can have read write access to all the agents and variables Introduction to NetLogo Programming Concepts Procedures i Commands and Reporters tell agents what to do Acommand is an action for an agent to carry out resulting in some effect A reporter is instructions for computing a value which the agent then reports to whoever asked it Procedures Commands or Reporters implemented by the user Primitives Commands or Reporters built into NetLogo language keywords 20 10 17 10 2013 Introduction to NetLogo Programming Concepts Procedures ii e Command executes
5. ce Info rae US woso e In the go procedure e Tell to turtles what to do In this case to search for mushrooms e So we need a search procedure to go ask turtles search to search Let s define search search ifelse time since last found lt 20 right Crandom 181 90 right Crandom 21 10 forward 1 e After globals statement define lobals num clusters turtles own time since Last found 46 23 5 e We update the setup procedure to setup ca set num clusters 4 ask n of num clusters patches C ask n of 20 patches in radius 5 C set pcolor red J J create turtles 2 C set size 2 set color yellow set time since last found 999 reset ticks end 6 e and the search procedure as well as to search ifelse time since last found lt 20 right Crandom 181 90 right Crandom 21 10 forward 1 ifelse pcolor f red set time since last found set pcolor yellow J set time since last found time since last found 1 17 10 2013 24 num clusters time since last found set num clusters 4 Md gt Sticks 200 ask n of num clusters patches C ask n of 20 patches in radius 5 C set pcolc 1 create turtles 1 set size 2 set color yellow set time since last found 999 J reset ticks go tick ask turtles search search ifelse time since last found lt 20 right Crandom 181 90 right random 21 10 forward 1 ifelse pcolor red s
6. dependent thread e asynchronous commands e ask turtles fd random 10 do something turtle 1 turtle 2 LS L turtle 3 e time Agent threads wait and join at the end of a block Ren Doursat 2008 e synchronous commands e ask turtles fd random 10 e ask turtles do something turtle 1 Y QV turtle 2 Wy turtle 3 DUM time Ren Doursat 2008 30 15 17 10 2013 Introduction to NetLogo NetLogo Model Skeleton setup Typically you start by defining a button for setting up the initial model state When creating a button you have to assign a command to it in this case setup The command associated with the button has to exist in the code panel and will be executed when the button is pressed Each command is defined by a structure to command name set of instructions end Introduction to NetLogo NetLogo Model Skeleton setup this procedure is used to setup the simulation initial to setup clear all resets the world to its initial state reset ticks creates or resets the tick counter show cleared see Agentset in NetLogo dictionary ask agentset commands n of size agentset ask n of population patches sprout 1 you could set the turtle properties here 16 17 10 2013 Introduction to NetLogo NetLogo Model Skeleton go e You can then create two more buttons e one go step button that executes one step of the simulation e one go forever button a button t
7. eading etc e Patch variables pcolor pxcor pycor etc Defining global variables e globals variable name1 variable name2 at the beginning of the code e adding a switch slider chooser or input box Define turtle patch link variables using the command turtles own patches own or links own e turtles own energy speed e patches own friction Define a local variable using the let command let temp color of turtle1 12 17 10 2013 Introduction to NetLogo Programming Concepts Variables iv You can set variable values by using the set command set variable name value You can set global variables anywhere in the code as these can be accessed by any agent Local variables are only accessible inside the procedures or code blocks where they where defined with let Agent variables can be read outside an agent with the of command color of one of turtles Agent variables can only be set by the agents they belong to with ask inside an agent context this is 25 Introduction to NetLogo Programming Concepts Ask Ask specify commands to be run by turtles or patches Examples e asking all turtles e ask turtles fd 50 e asking one turtle e ask turtle 5 e asking all patches e ask patches diffuse Only the observer can ask all turtles or all patches 13 17 10 2013 Introduction to NetLogo Programming Concepts Agentsets i Agentset definition of a subset of age
8. el 18 17 10 2013 Introduction to NetLogo Plotting 1 Plots can be created using the NetLogo interface builder Each plot contains a number of pens Each pen draws lines points or bars in the plots and can be configured by editing the plot in your model interface Introduction to NetLogo Plotting 2 Each pen is associated with a command e plot value e histogram list Example e plot count turtles with color blue e histogram age of agents Note using the command of with an Agentset agents turtles or patches etc results in a list of values 19 17 10 2013 Introduction to NetLogo Plotting 3 e The plots in a NetLogo model are update e automatically with the tick command This means that each time tick is called the plots run the commands in each pen e To use automatic plotting in your model you need to use the following configuration to setup clear all reset ticks end to go tick end Introduction to NetLogo Extensions amp Tools Extensions Guide Applets Sound Shapes Editor Robotics NetLogoLab Arduino Behaviour Space GIS System Dynamics Bitmap HubNet Quicktime for Java Logging BDI like architecture Controlling FIPA like communication Mathematica link Prolog NetLogo 3D Matlab R SQL 20 17 10 2013 NetLogo References NetLogo user manual http ccl northwestern edu netlogo docs NetLogo Learning Lab http www professorgizzi org modelingcomplex
9. et time since last found set pcolor yellow set time since last found time since last found 1 The modelling cycle for the Mushroom hunter problem Formulate the problem e What search strategy maximizes the rate of finding items if are distributed in clusters Formulate hypothesis for essential processes and structures e process switches from large scale movements to small scale searching depending on previous e discoveries Choose scales entities state variables processes and parameters Implement the model Analyse test and revise the model e we could the model by trying different search algorithms and parameter values analyse to see which produces the highest rates 50 17 10 2013 25
10. hat executes a given command continuously that executes the step command forever or until a given condition is met e Associate the respective commands to each button e Note you can just call step on the go button or add multiple commands to it Introduction to NetLogo NetLogo Model Skeleton go In your setup command you want to e clear the model components e reset all the variables to their default initial values e create the initial state for your model o The sprout command creates a turtle on the same patch that calls it e Inthe step command you will e ask a group of agents to do something ask turtles lt set of instructions either existing netlogo commands or newly created commands gt 34 17 17 10 2013 Introduction to NetLogo NetLogo Model Skeleton go procedure to determine what happens in a simulation step to step ask turtles facexy takes two coordinates in this case random facexy random world width random world height forward 1 tick updates the tick count end step forever this is called by a forever button 35 Introduction to NetLogo Creating model reporters e Measurements about values you want to extract from a model e Examples e Percentage of agents that execute a specific behaviour e Number of agents with a given property e Distribution of a particular agent property e The reporters can be used by plots and behavior space to export data about your mod
11. ity netlogo index html NetLogo 4 0 Quick Guide Luis R Izquierdo Fundamentals of Multi agent Systems with NetLogo Examples Jos M Vidal http multiagent com p fundamentals of multiagent systems html Origins of Life From Geochemistry to the Genetic Code http origins santafe edu tutorials netlogo A simple tutorial Create via File New a new NetLogo program Save it via File Save as with the name MushroomHunt nlogo From the Settings button e view of the World s geometry To initialize the World and run the model e setup procedure e go prcedure 21 17 10 2013 e Interface tab gt Button e create setup button e similarly create a go button Button Agent s observer PP Disable until ticks start Comman ds gd Display name Action key Cancel e In Code tab e Create the skeleton of setup amp go feset ticks e Change setup to Etha C set pcolor red J e Create the clusters of mushrooms patches e The cluster can be a model parameter e Define a global variable num clusters 9102 s num clusters e Modify the setup to turn in red randomly a num cluster patches o setup ca ask n of num clusters patches ask n of 2 patches in radius 5 set pcolor red reset ticks 22 17 10 2013 create turtles 2 e create the turtles e use the primitive create turtles set Size set color yellow interfa
12. nts e Contain either turtles or patches e Isina random order e Allows to construct agentsts that contain some turtles or patches Example all red turtles e turtles with color red all red turtles on the patch of the current caller turtle or patch e turtles here with color red all patches on right side of screen e patches with pxcor gt 0 all turtles less than 3 patches away from caller turtle or patch e turtles in radius 3 Introduction to NetLogo Programming Concepts Agentsets ii Using agentsets e ask such agents to execute a command e ask lt agentset gt e check if there are such agents e show any lt agentset gt e count such agents e show count lt agentset gt example remove the richest turtle with the maximum assets value e ask max one of turtles sum assets die 14 17 10 2013 Introduction to NetLogo Programming Concepts Breeds Breed a natural kind of agentset e Different breeds can behave differently e breed wolves wolf breed sheep a sheep A new breed comes with automatically derived primitives e create lt breed gt create custom lt breed gt lt breed gt here lt breed gt at Breed is a turtle variable e ask turtle 5 if breed sheep A turtle agent can change breed e ask turtle 5 set breed sheep Introduction to NetLogo Programming Concepts Synchronization Agents run in parallel each agent is an in
13. r 1 Gispley lebels wpate plot 17 10 2013 17 10 2013 Introduction to NetLogo GUI Controls Settings Views controls BLUE allow to run and control the flow of execution e buttons e command centre settings GREEN allow to modify parameters e sliders e switches e choosers views BEIGE allow to display information monitors plots output text areas graphics window Introduction to NetLogo GUI Controls Controls allow to run and control the flow of execution e Buttons e Command center Buttons initialize start stop step through the model e Once buttons execute one action one step setup e Forever buttons repeat the same action a go Command center ask observer patches or turtles to execute specific commands during the execution Command Center O gt ask patches set pcolor yellow 17 10 2013 Introduction to NetLogo GUI Settings Settings allow to modify parameters e Sliders e Switches Sliders adjust a quantity from min to max by an increment es bree reef initial number sheep 82 Switches set a Boolean variable true false Mog show energy Choosers select a value from a list Reatsirack rew Beats rock1 csv Beats seth1 csv Beats seth2 csv Introduction to NetLogo GUI Views Views allow to display information e Monitors e Plots e Graphics window Monitors display the current value of variables time ticks sheep wolves gr
14. t connect two turtles Observer is an agent without location that observes everything going on in the world Introduction to NetLogo NetLogo Components e Important concepts All the components can be seen as agents They can have their own properties can be given commands can detect and interact with other agents in their environment The simulation model is controlled by the observer The definition of agent behaviours is defined by the observer by using the ask command 17 10 2013 Introduction to NetLogo Patches Turtles System e Patches Elements of space e Change e Do not move e Turtles Social actors e Change e Mobile e All turtles and patches put together e Typically we wish to observe the system e How many turtles are sick Alive Introduction to NetLogo Rules e Turtles and patches have rules that can e Change themselves reflexive e Change other turtles e Change other patches 17 10 2013 Introduction to NetLogo Rules for Turtles Reflexive behaviour e ask turtles forward 1 Reflexive state e ask turtles if sick set color blue Change other turtles e f sick ask turtles here set sick true set color blue Change patches e ask turtles if sick ask patch here set grass grass 5 J Introduction to NetLogo Rules for Patches Reflexive state patches change themselves e ask patches set grass grass 1 Change other patches e
Download Pdf Manuals
Related Search
Related Contents
Adhesivo de Lunas Kensington Universal Case for 9 and 10” Tablets — Black Online Backup Client User Manual Mac OS Eagle ET-CSWSIU2-BK storage enclosure Taille-haie FPHT22 thermique 取扱説明書 ACDSee Photo Editor 6 User Guide decl-00992-rondochoc vrac Bilan social et tableaux de bord: - Centre interdépartemental de Product Manual - Boston Acoustics Copyright © All rights reserved.
Failed to retrieve file