1.08k likes | 1.09k Views
MIS 643 Agent-Based Modeling and Simulation 2017/2018 Fall Chapter 4: Creating Agent-Based Models. Outline. Intorduction Designing s Model Building a Model Examining a Model Predator-Prey Models: Additional Context Conclusion. Introduction. This chapter is based on
E N D
MIS 643 Agent-Based Modeling and Simulation 2017/2018 Fall Chapter 4: Creating Agent-Based Models
Outline Intorduction Designing s Model Building a Model Examining a Model Predator-Prey Models: Additional Context Conclusion
Introduction • This chapter is based on • IABM-WR: Chapter 4 • Creating Agent-Based Models
Introduction • This chpapter: • Devising a question or area to explore • designing and building a model • refineing question • revising the model to analize results to answering the question
Introduction • iterative exploration and refinment of the model and motivating question • Three sections: • 1 – Designing a model: • what elements to include • 2 – Building a model • from conceptual to a computational object • 3- Examining a model • running, creating and analizing results to provcide a useful answer to the motivating question
Introduction • In this chapter • desining, building and examining • Wolf Sheep Simple Model • The basic quesiton addressed: • How do population levels of two habitat-shering animal species change over time? • Generalized: • companies competing for customers • electral parites competing for wotes • viruses evolving in a computer system • Basic components of most ABMs
Outline Intorduction Designing a Model Building a Model Examining a Model Predator-Prey Models: Additional Context Conclusion
Designing a Model • Choosing Questions • Choosing Agents • Choosing Agent Properties • Choosing Environmental Characteristics and Stationary Agents • Choosing Agent Behavior • Designing a Time Step • Choosing Parameters of the Model • Choosing Measures • Summary of the Wolf Sheep Simple Model Desing
Designing a Model • Two major categories of modeling • phenomena-based modeling • exploratory modeling
Phenomena-Based Modeling • begin with a target phenomena • characterisitc pattern – reference pattern • E.g.: • common housing segregation patterns in cities • spral shaped galaxies in space • oscilating population patterns of interraction speices • goal: to somehow capture the reference pattern
Phenomena-Based Modeling • In ABM: • finding agents and rules of behavior and interrection so as to generate the observed patterns • once generated: candidate explanatory mechanism for that pattern • vary parameters to see • other patterns can be emereged • find in data or by conducting experiments • In EBM: writting equations that wiill give rise to the reference pattern
Exploratory Modeling • less common in EBM than in ABM • create agents, • define their behavior • explore the emerging patterns • may be • abstract forms; Game of Life • similaritiies • behavior of the model and • phenomena in the world • refine the model in the direction of perceived similarities to explanatory modeling of the phenomena
Degree of Questions • Specific research question(s) • E.g.: • How does a colony of ants forage for food? • -How does a flock of geese fly in a V-shaped • other extream without a clear question • modeling ants or birds • gradually refine question • a specific one answered by a model
Combining conceptual model and coding • top-down design • conceptual model then coding • designing agents, behavor and environment • before any line of coding • butom-up design • conceptual model and coding coevolve • start with a phenomena – with or without a formal question • E.g.: how a market evolves • start with sellers and buyers then add brokers
In practice • modelers use rearly use one style • switch between forms and styles • collaborating with a programmer • top-down design approach
Top-Down Design Approach • phenomena specific RQ • design agents properties, rules, • conceptual model • revise and refine until at a fine level
ABM Design Principle • ABM Design Principle: • start simple and build towards the question you want to answer • Two components
First Aspect • begin with simplest agents and rules to explore the system • A. Einstein (1933) • “Every thing should be made as simple as possible but not simpler”
Second Aspect • keep your quesiton in mind • do not add anything in your model that does not help you in answering your question • G. Box (1979) • “All models are wrong but some models are useful” • all models are incomplete – simplify some aspects of the world, • some are useful because they are designed to answer particular questions and the simplifications in the model do not interfere with the answer
ABM Design Principle Useful • 1- examine every possible agent and rules • eliminate if progress can be made without it • Starting simple and adding elements slowly – those irrelevant components never appear
More understanable and easier to varify • Verification: a computational model correctly implements its conceptual model • just in time results • at every point in model development • the model give same answer about the
Choosing Questions • first research question • may be too general • may change as new versions of the model are developed • for SWSM • How do population levels of two habitat-shering animal species change over time? • is it appropriate for ABM or refine it for ABM?
Choosing Questions • ABM: interacting, autonomous, heterogoenus entites • Some questions are more amenable to ABM some not • so try other modeling approaches • E.g.: examine population dynamics of two species, well mixed (no spatial dependence), homogenous, change depends on only levels of each • system dynamics more appropriate
Choosing Questions • ABM more relevant • how animals use resources – food at specific locations to get energy • Aggregates depends on agents interractions with themselfs and their environments • start simple only prey with a simple environment • add resources, predator-prey interractions • Time dependen processes
Refined Question • suitable for ABM • can we find model parameters for two species that will sustain with positive population levels in a limited area when one is a predator the other – prey – consuming resources from the environment.
Example • some times reference pattern is observed or • from the rules examine generated patterns • One reference pattern: wolf-moose species, Isle Royale, Michigan • Figure 4.2, 1959 – 2009 • no population going extinct, but oscilating • a phenomena-based modeling • RQ refined: can we find oscilating patterns of two species without going to extinct in a limited area
Choosing Agents • after research question • what are the agents? • compoents of the model: automomous, heterogenous, having states, properties and behavior and bearing on the quesiton • Avoid agent overload – any component could be an agent • more relevant to RQ
Choosing Agents • Granularity of agents: every entity is composed of smaller levels of entities • what is the rigth level of entiy to choose • proto-agents: in future versions of the model candidates to be agents • not individual characteristics but global • E.g.: a humman hunter – affects the two species. • E.g.: WSSM-wolf ,sheep, grass • added: hunter or soil
Choosing Agent Properties • properties distinguish agents from others • E.g.: in WSSM • wolves and sheep: location, heading and energy • notion of vitality, abstracting messy details of methabolism, caloric storage or starvation • condencing all to a single measure • other properties may be added but not related to the RQ
Choosing Environmental Characteristics and Stationary Agents • Environment: mobile agent live and interact with • E.g.: in WSSM • grass sheep consume • not every blade of grass • patches – grass amount • granularity shold be choosen properly • Not the deal with boundary conditions • the world will wrap verrically and horizontally – torus
Choosing Agent Behavior • behaviors of agents determine how they interact with each other and environment • E.g.: in WSSM, wolves and sheep • common behavior - turn, move forward, reproduce, die • differs – sheep consume grass whereas wolves consume sheep • may have many other common or differing behaviors – but not relevant to the RQ
Choosing a Time Step • designing the time step • all behavior of agents • in what order in a time step • in ABM time discrete • each step is divided into serialized, ordered phases • determining the order of events in each step may be tricky
Choosing a Time Step • In WSSM wolves and sheep have the behavior:move, die,eat, reproduce • grass grows • order for animals arbitary – any order • movement – truning and stepping forward • costs energy • death – if no energy • eating – to store energy, if something in their local envirnoment to eat • reproduce – if hes enough energy, which consumes energy • The grass agents may grow • before next time step
Choosing Parameters of the Model • agent behavior with specified rules • parameters control the model • In the WSSM • initial number of sheep and wolves • how much energy it costs an egent to move • energy gained from eating • from grass or sheep • how much energy is needed to reproduce • grass regrowth rate • not included in WSSM
Choosing Measures • What measures to be collected from the model • what measures – RQ • most relevant to the RQ • In WSSM – most relevant measures: • population levels of sheep and wolves • relevant to RQ: what parameters sets enable two populationns oscilating together • other may not be so relevant – energy • Some may be added for debuging the model
Summary of the Wolf Sheep Simple Model Design • Driving Question: Under what conditions the two species sustain oscilating positive levels in a limited geographical area when one is a predator of the other and the other consumes limited but regenerating resource from the environment • Agent Types: sheep, wolves, grass • Agent Properties: location, heading, energy (sheep,wolves), grass amount (grass)
Summary of the Wolf Sheep Simple Model Design • Agent Behavior: Move, die, reproduce (sheep and wolves), eat sheep (wolves), eat grass (sheep), regrow (grass) • Parameters: number of sheep, number of wolve, move cost, energy gain from grass, energy gain from sheep, grass regrowth rate • Time Step: 1-sheep and wolves move 2-sheep and wolves die 3-sheep and wolve eat 4-sheep and wolve reproduce 5-grass regrows • Measures: sheep and wolve population over time
Top-Down Design Approach • Take notes and dates of versions • Answer the following quesitons: • What part of the phenomena would you like to build a model of? • What are the principle types of agents involed in the phenomenon? • In what kind of environment do these agents operwate? Are there environmental agents? • What properties do these agents have? (describe by agent type) • What actrions or behavior can these agents take? (describe by agent type) • How do these agents interact with the environemt and with each other? • What do you hope to observe from the model?
A more buttom-up Approach to Modeling • Start with an ecological problem • add sheep – spread around • then they move, eat, reproduce, die • they eat grass • grass should regrow • something should eat sheep – wolves • come to the research question
Outline Intorduction Designing a Model Building a Model Conclusion
Building a Model • First Version • Second Version • Third Version • Forth Version • Fifth Version
Building a Model • Fife iterations • Many times in ABM, the end result is not what modeler expects • error in coding • core propertiy of compled systems – emergent behavior • Building models gradually • observe unusual behavior • determine its causes
First Version • Simplest model – behavor • one species • ignore the environment • Some sheep wondering around on a lanscape breed [sheep a-sheep] • a breed: class of turtles • plural form: sheep • singular form: a-sheep • all mobile agents are turtles
Update World in NetLogo • origin: center • nax x cor 17 • nax y cor 17 • wraping on • size of pathces 12
creating sheep to setup clear-all create-sheep 100 [ ;;initialize sheep ;; randomly spread around the world ;; set their color to white ;; give shape “sheep” ] reset-ticks end
setup breed [sheep a-sheep] to setup clear-all ask patches [ set pcolor green ] create-sheep 100 [ setxy random-xcor random-ycor set color white set shape "sheep" ] reset-ticks end
iterations • sheep behavior – moving around • break into two • turning and moving forward
iterations: go, wiggle and move at each iteration each sheep first turn a little bit in each direction then step forward wiggle: sheep procedure, the sheep changes its heading turn right then left, so the average is straight ahead move: sheep procedure take a step forward
go, wiggle and move to go ask sheep [ wiggle move ] tick end to wiggle rt random 90 lt random 90 end to move fd 1 ;; take a step forward end
Second Version • movements costly – consumes energy • Properties of sheep: • location, heading – build in turtles’ • energy – specific to sheep sheep-own [energy] • initialize and change when sheep move • number-of-sheep: from a silider • min value: 1 • max value: 1000 • increment: 1 • default: