Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.

Similar presentations


Presentation on theme: "Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University."— Presentation transcript:

1 Agent-Based Modeling and Simulation (ABMS) Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University

2 Outline Virtual Corridors of Butterflies From ODD to NetLogo Implementation

3 Virtual Corridors of Butterflies virtual corridores – Peer et al. (2005) mate-finding by butterflies (bf) “hilltoping” strategy - males and females –uphills for meet and mate Simple model formulation by ODD protocol

4 Purpose questions about virtual corridores (VC) interractions of butterflies hilltopping behavior and topograhpy emergence of virtusl corridores –nerrow paths butterflies move variabiity in butterfly strategy affects formation of VCs

5 Entities, State Variables and Scales Entities: –butterflies –square patches of land – State Variables: –elevation – land –positions of butterflies on patches – x,y coordinates Scales: –time and patch not impotant but –time length – time fo fly 25-35 meters –patch size 25 x25 meters 1000 time steps with a 150x150 square lanscape

6 Process Overwiew and Schedulling Process – movement of the butterflies at each time butterflies move one step order of movements – not impotant no interraction among butterflies

7 Design Concepts basic principle - virtual corridores emergence – how corridores emerge from –1 - adaptive movement behavior of butterflies –2 – topograhy of landscape adaptive behavior – moving behavior of butterflies based on an emprical law objective, learning, prediction – not included sensing – how bfs percive higher elevation interraction – not included stocasticity – –each butterfly at each step move uphill its neighbors with probability q and –move random to its neighbors with probability 1-q

8 Initilization topography of the lanscape 1- artificial 2- real values from a file 500 butterflies set to a patch

9 Input Data Environment is not chaning not needed

10 Submodels movement submodel: –how bfs decide to move uphill: highest neigboring patch random: randomly on of the eight naighboring pathces For each butterfly at each time step whether move uphill or random is by a contol parameter q q: random variable from a uiform distribution

11 From ODD to NetLogo Implementation Purpose – information tab model description Entities, State variables and Scales tutles-own [ ] patches-own [ ] globals [ ] Process and Schedule – go Design concepts Initilization - setup Input data – from file input Submodels - processes called from go

12 Entities State Variables Scales globals [] turtles-own [] patches-own [elevation] For a 150x150 lanscape from settings – corner – buttom left max-pxcor 149,max-pycor 149 Square landscape – turn off world wrapper s

13 Initialization to setup ca ask patches [ ] reset-ticks end Templeate for initialization

14 Initialization – set elevations ask patches [ let elev1 100 - distancexy 30 30 let elev2 50 - distancexy 120 100 ifelse elev1 > elev2 [ set elevation elev1] [ set elevation elev2] set pcolor scale-color green elevation 0 100 ]

15 Initialization – set elevations elev1 elev2 local variables for creating two hills hill1 at 30 30 at a height of 100 hill2 at 120 100 at a height of 50 distancexy set pcolor scale-color green elevation 0 100 Scales color scale-color

16 Initialization - turtles crt 1 [ set sıze 2 setxy 85 95 ] create one turtle at 85 95

17 Process Schedule to go ask turtles [move] tick if ticks >= 1000 [stop] end to move end in go procedure primitives tick, ticks stop

18 Submodels - move to move ifelse random-float 1 < q [uphill elevation] [move-to one-of neighbors] end probability q uphill with 1-q to random neighbor uphill move-to one-of define and initilize q

19 Chapter 5 of IABM 1.Introduction 2.Observation of Corridors 3.Analazing the Model 4.Time Series Resutls: Adding Plots and File Output 5.A Real Landscape 6.Summary and Conclusions

20 5.1 Introduction modeling – not formulating and implementing iterative process – modifying refining model Problem: –where and how corridors are formed? –quantitative outputs to be analized –replace artificial lanscape with a real topography Learning objectives: –version control –quantitative outputs and simulation experiments –slider or switchs for global variables, reportgers –output window, time series plot,exporting to files –importing data from a file

21 5.2 Observation of Corridors How to caracterize a corridore? if all bfs have the same path: –start from same posstion and q = 1.0 –corridor - very nerrow if movement – completely random –q = 0.0 –no corridore like feature How width of paths cahnge as q or topography varies

22 quantifying width bfs can start and end – different places Assume: –bfs stop – rich a local hilltop – –a patch higher then all its neighboringpatches quantify width of the corridor – all bfs –#pathces visited – any bf divided by –mean distance – starting and edning locations – all bfs lower bound 1.0 when all bfs follow a streigth line increases as bfs diverge Analysis: –plot q v.s. corridor width

23 First modifications slider for q –from 0.0 to 1.0 with increments 0.01 modify setup –creatre 50 bfs starting from same position experiment with different q values Programming Notes: moving variables to the interface –remove globals –remove initialization in setup procedure

24 modifying move bfs stop when they rich a local hill –a patch with an elevation higher then its neighbors –stop rest of the move procedure code – start of the move if elevation >= [elevation] of max-one-of neighbors [elevation] [stop] if condition ; turtle context [stop] move - in turtle context turtles get patch veriable - elevation

25 right side of condition of and max-one-of commands: of: [reporter or agent variable] of agent or agentset agent variable: elevation agent: agent in the neighborhood of the current turtle with maximum elevation max-one-of agentset [reporter or agent variable] report an agent from the agentset based on the reporters value

26 width of the bf population a - # of patches visited b- mean distanc between bfs starting andending positions two new state variables –for each patch – keep track of whether a turtle visited –for each turtle – store its starting patch Add a boolean variable to pathces – used? patchs-own [used?] –turn to true is the patch is ever visited Add a variable to turtles – start-patch turtles-own [start-patch] –set to the start patch when inilizing bfs

27 initilize in setup ask patches [... set used? false ] create-turtles [... set start-patch patch-here ] patch-here reports the patch the turtle is currently on Programming note: initializing variables –all variables has an initial value of 0

28 move and go procedure When a bf moves to a patch –set the patch variable to true –add end of move in the go procedure before the program stops let final-corridor-width corridor-width a laocal variable is assigned the value of the corridor width computed by another procedure (reporter) to-report corridor-width let patchs-visited count patches with [used?] let mean-distance mean [distance start- patch] of turtles report patches-visited / mean-distance end print the value of final-corridor-width to an output

29 go procedure to go ask turtles [move] tick if ticks >= 1000 [ let final-corridor-width corridor- width output-print word "corridor width " final-corridor-width stop ] end

30 corridor-width to-report corridor-width let patches-visited count patches with [used?] let mean-distance mean [distance start-patch] of turtles report patches-visited / mean- distance end

31 move to move if elevation >= [elevation] of max-one-of neighbors [elevation] [stop] ifelse random-float 1 < q [uphill elevation] [move-to one-of neighbors] set used? true end

32 5.3 Analazing the Model How corridor width output is affected from q plot corridor width v.s. q as q increases – corridor width falls as expected but when q=1.0 corridor widthis <1.0 How can this be?

33 5.4 Time Series Resutls: Adding Plots and File Output to go ask turtles [move] plot corridor-width if ticks >= 1000 [... stop] end add a ploter to tthe interface give plot name “corridor width” write the results of plots to a file export-plot “corridor width” word “corridor-output-for-q ” q

34 exporting plots to a file add the command to the end of go before the program stops export-plot “corridor width” word “corridor-output-for-q” q export-plot ploter_name filr_name

35 5.5 A Real Landscape real data from “ElevationData.txt” from books web side Programming Note: –grid-based: x-coordinate, y-coordinate and a value –one data line for each grid point

36 add to setup file-open “ElevationData.txt” while [not file-at-end?] [ let next-x file-read let next-y file-read let next-elevation file-read ask patch next-x next-y [set elevation next-elevation] ] file-close

37 next do determine dimensions of the world examining the data file adjust the scale of the color for the new nax and min values of the elevations initial positions of bfs in a 10x10 area –randomly asign xcor and ycor of bfs setxy (80 + radnom 10) (90 + radnom 10)

38 scaling color let min-elevation min [elevation] of patches let max-elevation max [elevation] of patches ask patches [ set pcolor scale-color green elevation min-elevation max- elevation set used? false ]

39 5.6 Summary and Conclusions NetLogo for agent-based science Modeling a system of multiple agents –quantitative variables –analyzing ouputs –simulation experiments –real spatial data butterfly model – simple but... other environments –movement of ideas people –social networks –economic or political lanscapes


Download ppt "Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University."

Similar presentations


Ads by Google