1 / 170

MIS 643 Agent-Based Modeling Chapter 5 The Components of Agent-Based Modeling

MIS 643 Agent-Based Modeling Chapter 5 The Components of Agent-Based Modeling. Outline. Overview Agents Environments Interactions Observer/User Interface Schedule Wrapping It All Up Summary. The Components of Agent-Based Modeling. Individual components of ABMs

eguillory
Download Presentation

MIS 643 Agent-Based Modeling Chapter 5 The Components of Agent-Based Modeling

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MIS 643 Agent-Based Modeling Chapter 5 The Components of Agent-Based Modeling

  2. Outline Overview Agents Environments Interactions Observer/User Interface Schedule Wrapping It All Up Summary

  3. The Components of Agent-Based Modeling • Individual components of ABMs • Overview of components of ABM • Discuss each components • How components come together for the construction of ABMs

  4. Outline Overview Agents Environments Interactions Observer/User Interface Schedule Wrapping It All Up Summary

  5. Overview • Complex systems – described • agents, environment • behavior - agent rules • Basic components of ABMs • agents – basic ontological units • environment – world in which agents live • interactions – between agents and agents and environments

  6. Overview • agent actions – internanlly • directly affacting agents internal state • E.g.: in Segregation – agents move • The environment may not be passive • E.g.: grass regrows • Two more:

  7. Overview • Observer/User Interface: an agent but can access all agents and environment • ask agents to carry out specific tasks • users interact with ageents with UI • Schedule: the observer tells agents when to do

  8. Trafic Basic Model • Trafic basic model –a simple model of trafic flow • in Social Science section • to explore how trafic jams form • they thought to include • trafic accidents, radar traps • but without such hindrances • trafic jams form as • cars approach to cars in front of them • they slow down, • cars behind slow down and so on... • a ripple effect backwords – trafic jam moves backward • emergence

  9. Outline Overview Agents Environments Interactions Observer/User Interface Schedule Wrapping It All Up Summary

  10. Agents • Properties • Behavior (Actions) • Collections of Agents • The Granularity of an Agent • Agents Cognition • Other Kind of Agents

  11. Agents • basic building blocks of ABM • properties – they have • internal and external states • actions – behavior • what they do • Several issues: • agents grin-size – most effective • e.g.: political model: actors, institutions • agent cognition- capability to observe and decision about world • proto agnets and meta-agents

  12. Properties • describe agent’s current state • individual agents - inspected by monitors: • patch, turtle, link • Figure 5.2 • Two sets of properties • Standard turtle properties • WHO, COLOR, HEADING, XCOR, YCOR, SHAPE, LABEL, LABEL-COLOR, BREED, HIDEN?, SIZE, PEN-SIZE, PEN-MODE

  13. Properties (cont.) • Standard patch properties: • PXCOR, PYCOR, PLABEL, PLABEL-COLOR • Standard link properties: • END1, END2, COLOR, LABEL, LABEL-COLOR, HIDEN?, BREED, THICKNESS, SHAPE, THE-MODE • turtles can directly access patch properties they are currently on • sit on exactly one patch at a time

  14. accessing turtles from patches: • turtles-here: set of turtles on the patch • turtles-on: set of turtles on a specified patch

  15. user defined prrperties • author defined properties: • E.g.: for Simple Trafic model: • SPEED, SPEED-LIMIT, SPEED-MIN • should be described in info tab • SPEED: curent speed of the car • SPEED-LIMIT: maximum speed of the car • SPEED-MIN: its minimum speed

  16. set in the SETUP-CARS procedure at the srart of the model set speed .1 + random-float .9 set speed-limit 1 set speed-min 0

  17. uniformly distributed random variable random-float value • 0 <= random number < value • normally distributed random variables random-normal mean standard-dev • E.g.: random-normal .5 .1 • mean and starndard deviation of a normal distribution

  18. Initialize agent properties from • lists or files • emprical data • Example: from file: • Higths of patches in the Butterfly model are red from a file • Example: from lists: • colors of people are assigned from red or blue set color one-of [red blue]

  19. agent properties can be changed during the running of the model • E.g.: in Trafic Basic model • speed propertiy can be increased or decreased in the SPEED-UP-CAR procedure set speed speed + acceleration

  20. Behaviors (Actions) • how the agents can behave – actions it can take • the agent can change the state of the • environment, other agents’ or it self • List of all predefined behavior • NetLogo dictionary: • turtles, patches, links FORWARD/BACKWARD RIGHT/LEFT HATCH/DIE

  21. Behaviors (Actions) • author defined behavior • E.g.: in TBM, SPEED-UP-CAR, SLOW-DOWN-CAR to slow-down-car ;; turtle procedure set speed speed - deceleration end to speed-up-car ;; turtle procedure set speed speed + acceleration end

  22. initialization globals [ sample-car ] turtles-own [ speed speed-limit speed-min ] to setup clear-all ask patches [ setup-road ] setup-cars watch sample-car reset-ticks end to setup-road ;; patch procedure if (pycor < 2) and (pycor > -2) [ set pcolor white ] end

  23. setup-cars to setup-cars if number-of-cars > world-width [ user-message (word "There are too many cars for the amount of road. Please decrease the NUMBER-OF-CARS slider to below " (world-width + 1) " and press the SETUP button again. The setup has stopped.") stop ] set-default-shape turtles "car" crt number-of-cars [ set color blue set xcor random-xcor set heading 90 ;;; set initial speed to be in range 0.1 to 1.0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars ] set sample-car one-of turtles ask sample-car [ set color red ] end

  24. seperate-cars • this procedure is needed so when we click "Setup" we • don't end up with any two cars on the same patch to separate-cars ;; turtle procedure if any? other turtles-here [ fd 1 separate-cars ] end

  25. go • adjust their speed according to speed limits to go ;; if there is a car right ahead of you, match its speed then slow down ask turtles [ let car-ahead one-of turtles-on patch-ahead 1 ifelse car-ahead != nobody [ set speed [speed] of car-ahead slow-down-car ] ;; otherwise, speed up [ speed-up-car ] ;;; don't slow down below speed minimum or speed up beyond speed limit if speed < speed-min [ set speed speed-min ] if speed > speed-limit [ set speed speed-limit ] fd speed ] tick end

  26. slow-down-car/speed-up-car to slow-down-car ;; turtle procedure set speed speed - deceleration end to speed-up-car ;; turtle procedure set speed speed + acceleration end

  27. agents - cars can change their speed and indirectly affect the speed of other cars • can chnge environment properties • E.g.: speed of a car makes the road – the patches worm-up by a precedure WEAR • E.g.: sheep eat grass , change the amount of grass in a place

  28. Collections of Agents • Three types • mobile agents – turtles in NetLogo • stationary agents – ptches in NetLogo • connecting agents: links in NetLogo

  29. Collections of Agents • mobile agents – turtles in NetLogo • shapeless; arealess points • even shape and size, • when created: • x,y coordinats - at center • headings - random • coordinates : xcor,ycor

  30. Collections of Agents • stationary agents – ptches in NetLogo • acted upon by turtles; pasive environments • take actions and perform operations • defined space/area

  31. Collections of Agents • connecting agents: links in NetLogo • link two or more agents • relation between turtles • friendship, communiciation, • envirnonments: roads

  32. Breeds of Agents • particular set of agents with their own preperties and actions • breed of an agent: class or category to which the agent belongs • if different agents have different properties or actions • E.g.: sheep and wolves has the same properties but actions are different tutles-own [energy] sheep-own [wooliness] volves-own [fang-strength] sheep – energy and wooliness volves - energy and fang-strength

  33. Sets of Agents • NetLogo – agentset: unordered collection of agents • collecting agents something in common • or randomly selecting subset of another agentset let fast-cars turtles with [speed > 0.5] ask fast-cars [set size 2.0] • or without let ask turtles with [speed > 0.5] [set size 2.0]

  34. all turn to size 2 • slow turtels sizes 1 ask turtles with [speed > 0.5] [set size 2.0] ask turtles with [speed <= 0.5] [set size 1.0] • another way of doing ask turtles [ ifelse [speed > 0.5] [set size 2.0] [set size 1.0] ] :: end ask

  35. collection of agents based on location let car-ahead one-of turtles-on patch-ahead 1 ifelse car-ahead != nobody [ set speed [speed] of car-ahead slow-down-car ] • TURTLES-ON PATCH-AHEAD 1 • turtles on the patch 1 unit ahead of a turtles • accessing collections agents based on their locations • TURTLES-HERE, TURTLES-AT, NEIGHBORS, IN-RADIUS

  36. choosing agents randomly • choosing agents randomly • N-OF, ONE-OF ;; create turtles on random patches ask n-of number patches [ sprout 1 [set color one-of [red green]] ] ;; end ask

  37. Agentsets and Lists • creating an empty list set a-list [] • add items to list set a-list fput 1 a-list set a-list fput “and” a-list set a-list fput turtle 0 a-list show a-list [(turtle 0) “and” 1]

  38. an agentsets hold same type of agents • empty agentsets • no-turtles, no-patches, no-links • creates an empty agentset of turtles set an-agentset no-trutles set an-agentset (turtle-set turtle 0) set an-agentset (turtle-set an-agentset turtle 1 turtle 2) :: an-agentset has three turtles

  39. agentsets can be asked to do something • lists cannot be asked • agentsets are unordered • when printing they are printed randomly turtles-own [information] let a-list [] set a-list sort-on [information] turtles • a-list: list of turtles in ascending order by information

  40. foreach a-list [ ask ? [] ;; do something ] • ? as a special variable takes on each value of the list elements

  41. let n 0 foreach sort patches [ ask ? [ set plabel n set n n + 1 ] ] ;; patches are labeled with numbers in left-to-right, ;; top-to-bottom order

  42. Agentsets and Computation • when an agentset is asked to perform an action, agents collected at that moment are asked to do • agent A, agent B, are in the collection • agent C not in the collection • if agent A action causes agent B not satisfy collection criteria but agent B is also asked • if agent A action causes agent C satisfy collection criteria but agent C is not asked • E.g.: Agentset Ordering Model (AOM) in IABM Ch 05

  43. setup ;; create 100 blue turtles of size between 0.0 and 2.0 to setup clear-all create-turtles 100 [ set size random-float 2.0 forward 10 set color blue ] reset-ticks end

  44. go to go ;; ask all turtles with size < 1 to ask a larger turtle to decrease its size, and then turn themselves red ask turtles with [ size < 1.0 ] [ ask one-of turtles with [size > 1.0][ set size size - 0.5 ] set color red ] print count turtles with [color = red] print count turtles with [size < 1.0] end

  45. Computational Efficiency • Sometimes it is better to form an agentset before performing operations on it • E.g.: Agent Efficiency Model (AEM) in IABM Ch 05 • trade off between efficiency and code readability

  46. setup ;; SETUP colors the patches so that roughly half are red and half are green to setup clear-all ask patches [ set pcolor one-of [red green] ] reset-ticks end

  47. go-1 ;; GO-1 sets the labels of red patches to a small random number (0-4) ;; and the labels of green patches to a larger random number (5-9) to go-1 if any? patches with [pcolor = red] [ ask patches with [ pcolor = red ] [ set plabel random 5 ] ] if any? patches with [pcolor = green] [ ask patches with [ pcolor = green ] [ set plabel 5 + random 5 ] ] tick end

  48. go-2 ;; GO-2 has the same behavior as GO-1 above, but it is more ;; efficient as it computes each of the agentsets only once. to go-2 let red-patches patches with [ pcolor = red ] let green-patches patches with [ pcolor = green ] if any? red-patches [ ask red-patches [ set plabel random 5 ] ] if any? green-pathces [ ask green-patches [ set plabel 5 + random 5 ] ] tick end

  49. go-3 ;; GO-3 explores what happens if patch colors are changed on the fly. ;; GO-3 results in the entire world becoming red to go-3 if any? patches with [pcolor = red] [ ask patches with [ pcolor = red ] [ set pcolor green ] ] if any? patches [with pcolor = green] [ ask patches with [ pcolor = green ] [ set pcolor red ] ] tick end

  50. go-4 ;; GO-4 explores what happens if you first keep track ;; of which patches are red and which are green. ;; GO-4 results in the patches swapping their colors. to go-4 let red-patches patches with [ pcolor = red ] let green-patches patches with [ pcolor = green ] if any? red-patches [ ask red-patches [ set pcolor green ] ] if any? green-patches [ ask green-patches [ set pcolor red ] ] tick end

More Related