mis 585 special topics in ims agent-based modeling bertan badur [email protected] department of...
TRANSCRIPT
![Page 1: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/1.jpg)
MIS 585
Special Topics in IMS
Agent-Based Modeling
Bertan Badur
Department of
Management Information Systems
Boğaziçi University
![Page 2: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/2.jpg)
Outline
IntorductionLifeHeroes and CowardsSimple Economy
![Page 3: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/3.jpg)
Introduction
• Intorduction to Agent-Based Modeling
• By U. Wilensky, W. Rand.• IABM-WR • Chapter 2
![Page 4: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/4.jpg)
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
![Page 5: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/5.jpg)
Outline
IntorductionLifeHeroes and CowardsSimple Economy
![Page 6: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/6.jpg)
Life
• In 1970 British mathematician John Horton Conway, Conway (1976)
• cellular automata - the “Game of Life”
• Martin Gardner, • Scientific American colomn
![Page 7: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/7.jpg)
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
![Page 8: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/8.jpg)
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 then 2 alve neighbors – it dies– if it has more then 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
![Page 9: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/9.jpg)
NetLogo
• NetLogo has three tabs• Interface tab
– black area – “view”– white area – interface
• set user interface elements; buttoms, siliders..
• observe results: output, plots....
• Code tab• Info tab
![Page 10: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/10.jpg)
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 hirizonallyi vertically, see
IABM-WR pp 55 Box 2.1 Wrapping
![Page 11: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/11.jpg)
NetLogo Code
• modules – procedures• begin with to• end with end• usually• setup
– initializations
• go– processes taking place advences
clock by tick
![Page 12: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/12.jpg)
• procedures – commands• to proc 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
![Page 13: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/13.jpg)
to setup
end
to go
end
![Page 14: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/14.jpg)
Initialization
to setup
;;
]
end
ask primitive asks selected agents to do actions by commands in brackets
set color of all pathces to redset - primitive is assignmentpcolor – variable for patches
![Page 15: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/15.jpg)
Initialization
to setup
;;clear all setings
;; set dead patches to blue
;; 10% of patches are alive
;; initilize clock
end
![Page 16: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/16.jpg)
to setup
clear-all
ask patches
[
set pcolor blue
if random 100 < 10
[ set pcolor green ]
]
reset-ticks
end
![Page 17: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/17.jpg)
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%
![Page 18: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/18.jpg)
Box 2.2: Agent Centeric Thinking
![Page 19: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/19.jpg)
ask patches [
if random 100 < 10
[set pcolor green] ;; end if
] ;; end ask
• orask patches with [random 100 < 10]
[ set pcolor green ]
] ;; end ask
![Page 20: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/20.jpg)
Asking exactly 10% of patchesto setup ask n-of 0.1*(51*51) patches [ set pcolor green ] ] ;; end ask] ;;end setup• or more generallyto setup let number-of-patches count patches ask n-of 0.1*number-of-patches patches [ set pcolor green ] ] ;; end ask] ;;end setup
![Page 21: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/21.jpg)
go Procedureto 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
![Page 22: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/22.jpg)
go Implementationto go ask patches [ set live-neighbors count neighbors with [pcolor = green]
] ask patches [ 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]
]
![Page 23: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/23.jpg)
to setup ask n-of 4 patches [ ask n-of 20 patches in-radius 5
[ set pcolor red ] ]end4 patches are randomly selected for each randomly selected pathc for all patches in radius 5 select 20 randomly set their color to red
![Page 24: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/24.jpg)
clear-allto setup clear-all ;abriviares as – ca - ask n-of 4 patches [ ask n-of 20 patches in-radius 5
[ set pcolor red ] ]endclear-all: clear all default values
![Page 25: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/25.jpg)
using parametersglobals [ num-clusters ]to setup clear-all set num-clusters 4 ask n-of num-clusters patches [ ask n-of 20 patches in-radius 5 [ set pcolor red ] ]end
![Page 26: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/26.jpg)
creating 2 hunters - turtles
create-tutrles 2 ;crt 2
[
set sıze 2
set color yellow
]
create 2 turtles crt or create-tutlesbnild-in turtle variablessize and color
![Page 27: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/27.jpg)
variable for patches
patches-own [
live-neighbors
]
live-neighbors
variable
![Page 28: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/28.jpg)
go procedureto go ask turtles [search]end
to search ifelse tıme-sınce-last-found <= 20 [right (random 181) - 90] [right (random 21) - 10] forward 1end
cifelse boolean condition[ block whan true ][ block when false ] right: turn right by angle in degrees
![Page 29: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/29.jpg)
variable for turtlestutrles-own
[
tıme-sınce-last-found
]
tıme-sınce-last-found
variable for all turtlestime passed since last mushroom has
found by the hunter
![Page 30: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/30.jpg)
add to the search procedure
ifelse pcolor = red [ set tıme-sınce-last-found 0 set pcolor yellow ] [ set tıme-sınce-last-found tıme-sınce-
last-found + 1 ]end if found pcolor is red set tıme-sınce-last-found to 0 set pcolor yellowelse increment tıme-sınce-last-found by one
![Page 31: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/31.jpg)
command center
• select turtles• write commands • hatch 1 [right 160]• show count turtles
![Page 32: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/32.jpg)
firther modifications
• adding ticks• add reset-ticks• to the end of setup• add tick to the begining of go• following motion of hunters• add pen-down to the setup
procedute when initilizing turtles
![Page 33: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/33.jpg)
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
that repeats like an oscillator and periodically emits spaceships
![Page 34: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/34.jpg)
• 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
![Page 35: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/35.jpg)
Outline
IntorductionLifeHeroes and CowardsSimple Economy
![Page 36: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/36.jpg)
Heroes and Cowards
![Page 37: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/37.jpg)
Rules of the game• with people each choose a heroe and an
enemy• two stages:• first every one act – coward
– 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
![Page 38: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/38.jpg)
setup pseudocodeto 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 ticksend
![Page 39: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/39.jpg)
setup codeturtles-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-ticksend
![Page 40: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/40.jpg)
Interface elements
• slider:– variable: number– default 68
• Chooser– variable: personalities– choices: “”” “cowardly”, “brawe”,
”mixed”
• Settings– wrap off
![Page 41: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/41.jpg)
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 oneend
![Page 42: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/42.jpg)
to go
ask turtles [
if color = blue [act-bravely]
if color = red [act-cowadly]
]
tick
end
![Page 43: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/43.jpg)
acting submodelsto 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.1end
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 fd 0.1end
![Page 44: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/44.jpg)
Random number generation• sequance of random numbers• initial value is taken from the clock of
computer • if you want to strart from the same
seedrandom-seed 137
show random 100
show random 100
show random 100• always generate the same sequance of
random numbers 79 89 61
![Page 45: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/45.jpg)
Outline
IntorductionLifeHeroes and CowardsSimple Economy
![Page 46: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/46.jpg)
Simple Economy
• Economies – heterogenous actors – buyers and sellers
• in 1996, J. Epstein, R. Axtell, • SugerScape•
![Page 47: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/47.jpg)
• 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
![Page 48: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/48.jpg)
• is there a limiting distribution of money?
• Intiution:– flat –
• initially every body has the saime money• randomly seleced one to give
– normal -
![Page 49: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/49.jpg)
Version 1
to setup
;; clear everything
;; create 500 turtles with an initial wealth of 100 each
;; reset tick
end
![Page 50: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/50.jpg)
setup
turtles-own [wealth]
to setup
ca
crt 500 [
set wealth 100
]
reset-ticks
end
![Page 51: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/51.jpg)
Version 1 to go ;;ask turles to transact if thye have positive or 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
end
![Page 52: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/52.jpg)
go and transactto go ask turtles with [wealth > 0] [transact]
tickend
to transact set wealth wealth - 1 ask one-of other turtles [set wealth wealth + 1]
end
![Page 53: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/53.jpg)
Exercises
• can you move the wealth chacking condition to transact?
• can you use with instead of if?
![Page 54: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/54.jpg)
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– Color green
![Page 55: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/55.jpg)
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• During iterations set x coordinate
to wealth if wealth is less then 500
![Page 56: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/56.jpg)
Version 2 setupturtles-own [wealth]
to setup ca crt 500 [ set size 2 set shape "circle" set color green set wealth 100 setxy wealth random-ycor ] reset-ticksend
![Page 57: MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University](https://reader035.vdocuments.mx/reader035/viewer/2022062423/5697c00b1a28abf838cc84d4/html5/thumbnails/57.jpg)
go and transactto go ask turtles with [wealth > 0] [transact]
ask turtles [ if wealth <= max-pxcor [set xcor wealth]]
tickend
to transact set wealth wealth - 1 ask one-of other turtles [set wealth wealth + 1]
end