Creating Simple Agent-Based Models

Slides:



Advertisements
Similar presentations
Got Gas? Jim and Michael. Problem Statement (Weight 15%) An investigation of a gas pump queue as a function of rationing policy We modeled the queue at.
Advertisements

Netlogo! NetLogo is a programmable modeling environment for simulating complex systems. Modelers can give instructions to hundreds or thousands of independent.
Agents and Pervasive Computing Group Università di Modena e Reggio Emilia System Requirements NetLogo is designed: to run almost any type of computer.
13 giugno 2006Master in economia e politica sanitaria - Simulazione per la sanità 1 _Strumenti, seguito _______________________________________ Un modello.
Netlogo and its Relatives Logo (Papert) –Language for teaching mathematics graphically –Tell turtle how to move Starlogo (Resnick) & StarlogoT (Wilensky)
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 1 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference.
Earth sciences: diffusion Day 4 COLQ 201 Multiagent modeling Harry Howard Tulane University.
Day 1 Goal: To create a model of people hunting in the forest for mushrooms and then start working on improving their mushroom hunting ability mathematically.
Game of Life Rules and Games Linh Tran ECE 573. What is Life? Life is just one example of a cellular automaton, which is any system in which rules are.
CITS4403 Computational Modelling Game of Life. One of the first cellular automata to be studied, and probably the most popular of all time, is a 2-D CA.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
CELLULAR AUTOMATON Presented by Rajini Singh.
2-Day Introduction to Agent-Based Modelling Day 2: Session 5 Variables and Debugging.
Epidemiology Modeling the Spread of Disease Designing and Running Experiments Modeling and Simulation Module 1: Lesson 5.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Teaching Contemporary Mathematics Conference January 25, 2013 Christine Belledin NC School of Science and Mathematics.
Department of Computer Science What is NetLogo UH-DMML  Multi-agent programmable modeling environment  Well suited for modeling complex systems evolving.
An Introduction to NetLogo given by Gabriel Wurzer. ,
Modeling and Simulation Module 1: Lesson 1
2-Day Introduction to Agent-Based Modelling Day 1: Session 1 Introduction, commands, loops, conditionals.
ABM Frameworks Dr Andy Evans With additions from Dr Nick Malleson.
2-Day Introduction to Agent-Based Modelling Day 1: Session 4 Networks.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
CISC 1600 – Lecture 3.2 Simulations Complex Input & Output NetLogo.
2-Day Introduction to Agent-Based Modelling Day 2: Session 8 Exploring Model Collections, NetLogo Lists, Further Resources.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
Week 11 DO NOW QUESTIONS. An ask turtles block is a set of instructions that is issued to every turtle. Even though computers can do things very quickly,
An Introduction to NetLogo Gabriel Wurzer, Vienna University of Technology AnthropologischeGesellschaftWien.
Introduction to Algorithms using Netlogo. What’s an Algorithm Definitions of Algorithm on the Web: –A procedure or formula for solving a problem.
Models in NetLogo Day 3 COLQ 201 Multiagent modeling Harry Howard Tulane University.
The Game of Life A simulation of "life". From simple rules, complex behavior arises Rules –A cell that is alive and has fewer than two live neighbors dies.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
New Mexico Computer Science For All Variables and Scope Maureen Psaila-Dombrowski.
New Mexico Computer Science For All Patches and Agent/Environment Interactions Maureen Psaila-Dombrowski.
Cellular Automata FRES 1010 Eileen Kraemer Fall 2005.
MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur Department of Management Information Systems Boğaziçi University.
MIS 585 Special Topics in MIS: Agent-Based Modeling 2015/2016 Fall.
M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz
1 Agent-Based Tools: focus on NetLogo Ing. Cristina Ponsiglione University of Naples Federico II Laboratorio di Simulazione ad Agenti.
Chapter 6 Introduction to Hexa – Workshop 2 3D Pipe Junction
Cellular Automata and Music
An Introduction to NetLogo given by Gabriel Wurzer and Wolfgang E
Spatio-Temporal Information for Society Münster, 2014
Introduction Abstract
Management Information Systems
MIS 643 Agent-Based Modeling NetLogo: Summary of Manual and Dictionary.
Management Information Systems
Control Structures II Chapter 3
An introduction to Netlogo agent-based software
A Cellular Automata Approach to Population Modeling
Hands-On given by Gabriel Wurzer and Wolfgang E. Lorenz
Illustrations of Simple Cellular Automata
Computational methods in physics
MIS 643 Agent-Based Modeling and Simulation 2016/2017 Fall.
Cellular Automata + Reaction-Diffusion Systems
Learning to program with Logo
Cellular Automata.
Excursions into Logic Based Computation using Conway’s Game of Life
Introduction to Grasshopper for rhino
The Engineering of Functional Designs in the Game of Life
Modeling, Coding and good research
For loops Taken from notes by Dr. Neil Moore
Game of Life Presentation Byung-guk Kim
creating a ecosystems model in net logo
A Cellular Automata Approach to Population Modeling
Unsupervised Machine Learning in Agent-Based Modeling
Activity 2-1: The Game of Life
Modeling Rainfall using a Cellular Automata
2D Array and Matrix Application: Game of Life
Presentation transcript:

Creating Simple Agent-Based Models MIS 643 Agent-Based Modeling amd Simulation 2016/2017 Fall Creating Simple Agent-Based Models

Outline Intorduction Life Heroes and Cowards Simple Economy

Introduction Intorduction to Agent-Based Modeling by U. Wilensky and W. Rand Chapter 2

Introduction learn to construct simple ABMs “toy models” – not mean models of real phenomena thought experiments objects to think with simple to construct but exebits interesting, suprising emergent behavior

Outline Intorduction Life Heroes and Cowards Simple Economy

Life In 1970 British mathematician John Horton Conway, Conway (1976) cellular automata - the “Game of Life” Martin Gardner, Scientific American colomn

The Game Played on checkeboard – graph paper N x N cells – can be “alive” or “dead”: state of a cell surrounded by eight neighbour cells the grid is “wrap around” clock ticks – generation

Rules of the Game Each cell checks its own state and states of its neighbors and set itself as “alive” or ”dead” if the cell has less than 2 alve neighbors it dies if it has more than 3 alive neighbors it also dies if it has 2 alive neighbors it remains in its current state if it has 3 alive neighors if dead become alive, if alive, stay alive

NetLogo NetLogo has three tabs Interface tab Code tab Info tab black area – “view” white area – interface set user interface elements; buttoms, siliders.. observe results: output, plots.... Code tab Info tab

The view composed of grid of cells – patches how to open click settings in toolbar or on the visw double click and select edit Parameters to set Location of orgin max-pxcor, max-pycor 25 patch size: 13 to 8 world wraps hirizonally, vertically, see IABM-WR pp 55 Box 2.1 Wrapping

NetLogo Code modules – procedures begin with to end with end usually setup initializations go processes taking place advences clock by tick

Procedures procedures – commands to procedure_name commands end Create a button executing procedure setup Create a button executing procedure go forever is cheked – forever button write setup procedure code tab

Procedures (cont.) to setup end to go

Initialization to setup ;; ask patches [ comands ] .. ;; other commnads end ask primitive asks selected agents to do actions by commands in brackets set color of all pathces to red set - primitive is assignment pcolor – variable for patches

Initialization - algorithm to setup ;; clear all setings ;; set dead patches to blue ;; 10% of patches are alive ;; initilize clock end

to setup clear-all ask patches [ set pcolor blue if random 100 < 10 [ set pcolor green ] ] reset-ticks end

Exercise What is the difference between asking exactly 10% of the patches being alive How do you perform this in general for any number of patches, exactly X% being alive the chance of a randomly seleced patch being alive is 10%

Box 2.2: Agent Centreric Thinking WR-IABM Chapter 2 Box 2.2

Asking Patches Probabilistically each patch performs the tasks in ask with a probability probability of a patch being green is 0.1 in each run different number of patches turn into green

Probability of a Patch being green ask patches [ if random 100 < 10 [set pcolor green] ;; end if ] ;; end ask or ask patches with [random 100 < 10] [ set pcolor green ]

Asking exactly 10% of patches to setup ask no-of 0.1*(51*51) patches [ set pcolor green ] ] ;; end ask ] ;;end setup or more generally let number-of-patches count patches 0.1*number-of-patches patches

go Procedure - algorithm to go ;; each patch counts its alive neighbors ;; number of green neighboring patches ;; patches with 3 green naigbors turn or stay green ;; patches with 0 or 1 green neighbors turn or stay blue ;; patches with 4 or higher neighbors turn to blue end

go Implementation to go ask patches [ set live-neighbors count neighbors with [pcolor = green] ] if live-neighbors = 3 [set pcolor green] if live-neighbors = 1 or live-neighbors = 0 [set pcolor blue] if live-neighbors >= 4 [set pcolor blue]

clear-all to setup clear-all ;abriviares as – ca - ask patches [ set pcolor blue if random 100 < 10 [ set pcolor green ] ] end clear-all: clear all default values

variable for patches patches-own [ live-neighbors ] different variable for each patch initialized to 0

firther modifications adding ticks add reset-ticks to the end of setup add tick to the begining or as a last statemet of go procedure

to setup clear-all ask patches [ set pcolor blue if random 100 < 10 [ set pcolor green ] ] reset-ticks end

to go ask patches [ set live-neighbors count neighbors with [pcolor = green] ] if live-neighbors = 3 [set pcolor green] if live-neighbors = 1 or live-neighbors = 0 [set pcolor blue] if live-neighbors >= 4 [set pcolor blue] ] ;; end ask tick ] ;; end go procedure

Stable Patterns 1 – Still Lifes: stable shapes unless other shapes collide with them block, the beehive, the loaf,... 2 – Oscillators: repeat over time 3 – Spaceships: move across the life world Unstable Patterns: guns: a pattern with a main part thatg repeats like an oscillator and periodically emits spaceships

One dimensional CA with only one neighbor in each side In 1983, Stephan Wolfram – physisist and mathematical software entrepreneur One dimensional CA with only one neighbor in each side classified all possible rules into four behavioral regions homogenous, periodic, chatoic and complex Complexity in nature – due to CA like simple mechanisms

Outline Intorduction Life Heroes and Cowards Simple Economy

Heroes and Cowards

Rules of the game with people each choose a heroe and an enemy two stages: first every one act – cowardly move be sure that your friend is always between you and your enemy hiding from your enemy behind your friend cowardly second – behave like a heroe move between your friend and enemy protecting your friend from your enemy – herotic manner

setup pseudocode to setup ;; clear all previous settings variables ;; make patches white ;; create a set of turtles reand tne number froma slider ;; set x y corrdinates randomly ;; set colors to blue for cowards and red for heroes ;; if mixed is choosen determine crowads and heroes randomly while settng their colors ;; set one other turtle as their friends and oneother turtle as their enemies ;; reset ticks end

setup code turtles-own [friend enemy] to setup ca ask patches [set pcolor white] crt number [ setxy random-xcor random-ycor if personalities = "cowardly" [set color red] if personalities = “breverly" [set color blue] if personalities = "mixed" [set color one-of [blue red]] set friend one-of other turtles set enemy one-of other turtles ] reset-ticks end

Interface elements slider: Chooser Settings variable: number default 68 Chooser variable: personalities choices: “coward”, “heroe”, ”mixed” Settings wrap off

go pseudocode go at each tick if the agent is heroe act brawely – in a herotic manner if the agent is cowars act cowardly advance clock by one end

to go ask turtles [ if color = blue [act-bravely] if color = red [act-cowadly] ] tick end

acting submodels to act-bravely ;; move toward the mod of your friend and your enemy facexy ([xcor] of friend + [xcor] of enemy) / 2 ([ycor] of friend + [ycor] of enemy) / 2 fd 0.1 end to act-cowadly ;; set your friend between you and your enemy facexy [xcor] of friend + ([xcor] of friend - [xcor] of enemy) / 2 [ycor] of friend + ([ycor] of friend - [ycor] of enemy) / 2

Random number generation sequance of random numbers initial value is taken from the clock of computer if you want to strart from the same seed random-seed 137 show random 100 always generate the same sequance of random numbers 79 89 61

Outline Intorduction Life Heroes and Cowards Simple Economy

Simple Economy Economies – heterogenous actors buyers and sellers in 1996, J. Epstein, R. Axtell, SugerScape

Fixed number of people: 500 each starting out with inital amount of money: 100 At each tick, each person gives one of her 1 dollar‘s to any other person at random What will happen to the distribution of money? constraint – total amount of money fixed no one can have negative money if income is zore, connot give any away

is there a limiting distribution of money? Intiution: flat – initially every body has the saime money randomly seleced one to give normal -

Version 1 to setup ;; clear everything ;; create 500 turtles with an initial wealth of 100 each ;; reset tick end

setup turtles-own [wealth] to setup ca crt 500 [ set wealth 100 ] reset-ticks end

Version 1 to go ;;ask turles to transact if they have positive wealth ;; advence clock end to transact ;; contect turtle ;; decrement wealth of current turtle by one ;; for one of the other turtles, increment its wealth by one

go and transact to go ask turtles with [wealth > 0] [transact] tick end to transact set wealth wealth - 1 ask one-of other turtles [set wealth wealth + 1]

Exercises can you move the wealth chacking condition to transact? can you use with instead of if?

Monitoring by histogram Adjust settings world size orgine: left button max-xcor 500 max-ycor 80 patch size 1 no wraping in both dimensions Interface – plot max-x:500, max-y:40 histrogram [wealth] of turtles pen mode: bar

Using view with an histogram For turtles: size:2 color: green shape: “circle” x coordinate of view – wealth y coordinate of view – randomly assigned kind of bar of a histogram

Version 2 setup turtles-own [wealth] to setup ca crt 500 [ set size 2 set shape "circle" set color green set wealth 100 setxy wealth random-ycor ] reset-ticks end

go and transact to go ask turtles with [wealth > 0] [transact] ask turtles [ if wealth <= max-pxcor [set xcor wealth]] tick end to transact set wealth wealth - 1 ask one-of other turtles [set wealth wealth + 1]