Download presentation
Presentation is loading. Please wait.
Published byFerdinand Hodges Modified over 9 years ago
1
Agent-Based Modeling and Simulation (ABMS) Bertan Badur badur@boun.edu.tr Department of Management Information Systems Boğaziçi University
2
Outline Introduction Searching Mushrooms in a Forest
3
Introduction NetLogo –simple to install and experiment its model library User Manual –Tutorials, Interface Guide and Programming Guide –Dictionary Model Library –code examples
4
Agents Four kind of agents Moving agents – Turtles Patches – square cells – space in world Links – connect two turtles networks Observer - controler of the model –create other agents –global variables Each type of agents –commands –variables – build-in such as color and location user defined – additional –observer – gloabal variables
5
Global variables: –all agent can read and change –environment characteristics –model parameters Primitives – build-in procedure or command –commands tell agents something to do – retukrn void –reoprters calculte and report something – return a value or list –Ex: mean reports mean of a list of numbers – neighbors reports list of surrounding patches
6
Context –each pice of code is “in the contxt of ” one kind or occationally more then one kind of agent –can be changed during execution –Ex: ask turtles [move] agents – directly access variables for their own type Exceptions: –observer varibles by all agents –turtles can access patchs variables they are currenlty on
7
Searching Mushrooms in a Forest Is there a best strategy for searching mushrooms? observation: –mushrooms in clusters An intuitive strategy: –scanning an area in wide sweeps –upon finding a mushroom turning to smaller scale sweeps –as mushrroms in clusters What is large, small sweeps? and How long to search in smaller sweeps? Humans searching –pizzas, jobs, low prise goods, peace with neighbors
8
model of the problem try different search strategies Purpose: –what search strategy maximizes musrooms found in a given time Ignore trees and vegitables, soil type Musrooms are distributed as clusters mushroom hunter –moving point –having a sensing radius –track of how many mushrooms found –how much time passed since last mushroom fouınd
9
clusters of items (mushrooms) If the agent (hunter) finds an item smaller-scale movement If a critical time passes since last item found swithes back to more streight movement so as to find new clusters of items
10
Demonstrating Program: Mushroom Hunt File/New File/Save with extension “nlogo” Settings World geometry: –0,0 orgin, max-pxcor=16, max-pycor=16 –33x33 squre latice 2 hunters – turtels cluster of mushrooms – red patches all other patches are black setup – initialization go – continuous operations
11
procedukres – 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
12
to setup end to go end
13
to setup ask patches [ set pcolor red ] 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
14
to setup ask n-of 4 patches [ ask patches in-radius 5 [ set pcolor red ] end n-of : n-of number ageent set in-radius : agents in-radius number
15
to setup ask n-of 4 patches [ ask n-of 20 patches in-radius 5 [ set pcolor red ] end 4 patches are randomly selected for each randomly selected pathc for all patches in radius 5 select 20 randomly set their color to red
16
to setup clear-all ;abriviares as – ca - ask n-of 4 patches [ ask n-of 20 patches in-radius 5 [ set pcolor red ] end clear-all: clear all default values
17
using parameters globals [ 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
18
creating 2 hunters - turtles create-tutrles 2 ;crt 2 [ set sıze 2 set color yellow ] create 2 turtles crt create-tutles bnild-in turtle variables size and color
19
go procedure to go ask turtles [search] end to search ifelse tıme-sınce-last-found <= 20 [right (random 181) - 90] [right (random 21) - 10] forward 1 end cifelse boolean condition [ block whan true ] [ block when false ] right: turn right by angle in degrees
20
algorithm of move if timelast-found <= critical value make a small turn else make a biger turn if found – come on a red patch set timelasf-fournd to 0 set color to yellow else increment timelast-found by one
21
variable for turtles tutrles-own [ tıme-sınce-last-found ] tıme-sınce-last-found variable for all turtles time passed since last mushroom has found by the hunter
22
tıme-sınce-last-found initial value crt 2 [ set sıze 2 set color yellow set tıme-sınce-last-found 999 ] initialze tıme-sınce-last-found to a very high value greater then 20
23
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 yellow else increment tıme-sınce-last-found by one
24
command center select turtles write commands hatch 1 [right 160] show count turtles
25
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.