Waiting Bar Customers
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a model that simulates a crowded bar where the turtles are the patrons of the bar. The key concept of this model is that the turtles have different amounts of pushiness, some are inherently pushier than others. Turtles can also become pushier if they've waited a while to get their drink, or they can become pushier the more drinks they have.
The point of the model is to see how this distribution of pushiness affects the average wait times of the turtles trying to get drinks. It looks at that average wait as a whole in addition to looking at the average wait times of turtles with a specific range of pushiness values.
HOW IT WORKS
The model's core is based on D. Helbing and P. Molnar's social forces model. Each turtle has a force that tends towards the bartender (goal/green patches), a force that repels from the walls (white patches), and a force that repels from other turtles. The force from other turtles is reduced if they are not in the field of view.
Once every few ticks a turtle becomes thirsty and will start wandering to the bar counter. Likewise, every few ticks the bartender (one of the green patches) will choose a turtle near the counter to serve a drink to. The bartender can either do this randomly or in order of who was waiting the longest.
After a turtle gets a drink, it returns to where it was created and waits until it becomes thirsty again.
HOW TO USE IT
Unless you have read Helbing and Molnar's paper on the social forces model and want to try playing with the variables under "Force Constants", I suggest that you just play with the variables on the left column first.
Just set the variables to what you want them to be, hit setup, then go.
Explanation of variables:
- patrons, number of turtles to create
- lower-pushiness, the smallest base-pushiness value a turtle can have
- upper-pushiness, the biggest base-pushiness value a turtle can have
- mean-time-between-arrivals, the average number of ticks between turtles getting thirsty
- field-of-view, the field of view of the turtles
- c, if something is not in the field of view, the percentage that its corresponding force is reduced to
- max-speed, the highest step size of the turtles
- get-impatient?, whether turtles get impatient
- impatience-rate, how fast turtles get impatiend
- get-belligerent?, whether turtles get pushier with the number of drinks they've had
- belligerence-rate, how much each drink contributes to the pushiness of a turtle
- mean-service-time, the average time it takes for the bartender to serve a turtle
- service-plan, whether the bartender randomly chooses a turtle or chooses the one thats been waiting the longest to serve
- v0, corresponds to the V^0 constant in the equation in the report on the model's page
- sigma, corresponds to the sigma constant in the equation in the report on the model's page
- u0, corresponds to the U^0 constant in the equation in the report on the model's page
- r, corresponds to the R constant in the equation in the report on the model's page
- tau, corresponds to the tau constant in the equation in the report on the model's page
THINGS TO NOTICE
- Keep a look out for how the turtles move towards the bartender and how they crowd around the counter
- Watch out for turtles that are deep red and see if they push their way to the counter more easily than other turtles
THINGS TO TRY
- Try playing with the mean-time-between-arrivals and mean-service-time. What would happen if one is greater than the other? If they are equal?
- See what playing with the field-of-view would do
- When you're more comfortable with the model, play around with the variables under "Force Constraints"
EXTENDING THE MODEL
It would be interesting to see how agents who tip well will do when they try to get the bartender's attention in the future. I've also thought of implementing a behavior where turtles "wave" cash to get the bartender's attention. After interviewing some bartenders though, it turns out they don't necessarily get any preferential treatment.
NETLOGO FEATURES
This model keeps track of the different waiting times for agents at each decile by maintaining a list of accumulated values where each item corresponds with a decile. It also has a plot that doesn't plot as a function of time so you should check that out.
CREDITS AND REFERENCES
Modeling Commons URL This model is based on the social forces model
Comments and Questions
turtles-own [ thirsty? ;; am i thirsty? start-of-thirst ;; when did i start getting thirsty? drinks-had ;; the number of drinks i've had base-pushiness ;; the pushiness i am born with pushiness ;; how pushy i am at the moment vx ;; x velocity vy ;; y velocity desired-direction ;; my desired direction driving-forcex ;; my main motivating force driving-forcey obstacle-forcex ;; force exerted by obstacles obstacle-forcey territorial-forcex;; force exerted by neighbors territorial-forcey ] globals [ total-times ;; a list containing 10 accumulators for total time spent waiting by agents with the nth decile pushiness value total-counts ;; a list containing 10 accumulators for total times agents with the nth decile of pushiness was served ] ;; Set up the view to setup ca set-default-shape turtles "circle" ;; initialize the globals set total-times (list 0 0 0 0 0 0 0 0 0 0) set total-counts (list 0 0 0 0 0 0 0 0 0 0) ;; create patrons create-turtles patrons [ setxy 0 0 set thirsty? false ;; give the turtles an initial nudge towards the goal let init-direction -90 + random 180 set vx sin init-direction set vy cos init-direction set drinks-had 0 set base-pushiness (random-float 1) * (upper-pushiness - lower-pushiness) + lower-pushiness set pushiness base-pushiness color-turtle ] ;; set boundary patches as walls ask patches with [pxcor = min-pxcor or pxcor = max-pxcor or pycor = min-pycor or pycor = max-pycor] [ set pcolor white ] ;; create the bar counter ask patches with [pycor = (max-pycor - 2) and abs pxcor < 3] [ set pcolor white ] ask patches with [pycor = (max-pycor - 1) and abs pxcor = 2] [ set pcolor white ] ;; create the goals ask patches with [pycor = (max-pycor - 1) and abs pxcor < 2] [ set pcolor green ] reset-ticks end ;; run the simulation to go ;; run the social forces model on thirsty turtles ;; calculate the forces first... ask turtles with [ thirsty? = true ] [ calc-desired-direction calc-driving-force calc-obstacle-force if any? other turtles [ calc-territorial-forces ] ] ;; then move the turtles and have them grow impatient if need be ask turtles with [ thirsty? = true ] [ move-turtle if get-impatient? [ grow-impatient ] ;; color the turtle to show how pushy it is color-turtle ] ;; control the arrival of new thirsty turtles if any? turtles with [thirsty? = false] [ wait-around ] ;; control the service rate of bartenders. follow an exponential distribution for service times let p 1 / mean-service-time if random-float 1 < p [ ask one-of patches with [pcolor = green] [ service-patron ] ] tick end ;;;; Function for waiting around and other functions ;;;; ;; returns a value from 0-9 which is the decile of pushiness that an agent has to-report pushiness-index [pushiness-value] let p-index floor (((pushiness-value - lower-pushiness) / (upper-pushiness - lower-pushiness)) * 10) ifelse p-index = 10 ;; if it's 10, just treat it as 9 [ report 9 ] [ report p-index ] end ;; "serve" a turtle a drink to service-patron if any? turtles in-radius 2.5 [ ;; default to "random" service-plan let next-served one-of turtles in-radius 2.5 if service-plan = "waited-longest" [ set next-served max-one-of turtles in-radius 2.5 [ ticks - start-of-thirst ] ] ask next-served [ ;; reset the turtle setxy 0 0 set thirsty? false let init-direction -90 + random 180 set vx sin init-direction set vy cos init-direction set drinks-had drinks-had + 1 set pushiness base-pushiness let p-index pushiness-index pushiness ;; increment the corresponding elements in the global arrays to keep track of wait times and service counts set total-counts replace-item p-index total-counts ((item p-index total-counts) + 1) set total-times replace-item p-index total-times ((item p-index total-times) + (ticks - start-of-thirst)) if get-belligerent? [ set pushiness min (list upper-pushiness (base-pushiness + belligerence-rate * drinks-had)) ] color-turtle ] ] end ;; get more pushy over time to grow-impatient set pushiness pushiness + impatience-rate ;; make sure i'm not too pushy set pushiness min list pushiness upper-pushiness end ;; color a turtle according to its pushiness to color-turtle set color 19 - ((pushiness - lower-pushiness) / (upper-pushiness - lower-pushiness)) * 4 end ;; control when newly thirsty turtles arrive. follow an exponential distribution of inter-arrival times to wait-around let p 1 / mean-time-between-arrivals if random-float 1 < p [ ask one-of turtles with [thirsty? = false] [ set thirsty? true set start-of-thirst ticks ] ] end ;; helper function to find the magnitude of a vector to-report magnitude [x y] report sqrt ((x ^ 2) + (y ^ 2)) end ;; returns 1 if the angle between the desired vector and the force vector is within a threshold, else return c to-report field-of-view-modifier [desiredx desiredy forcex forcey] ifelse (desiredx * (- forcex) + desiredy * (- forcey)) >= (magnitude forcex forcey) * cos (field-of-view / 2) [ report 1 ] [ report c] end ;;;; Functions for calculating the social forces ;;;; ;; move the turtle according to the rules of the social forces model to move-turtle let ax driving-forcex + obstacle-forcex + territorial-forcex let ay driving-forcey + obstacle-forcey + territorial-forcey set vx vx + ax set vy vy + ay ;; scale down the velocity if it is too high let vmag magnitude vx vy let multiplier 1 if vmag > max-speed [set multiplier max-speed / vmag] set vx vx * multiplier set vy vy * multiplier set xcor xcor + vx set ycor ycor + vy end ;; find the territorial force according to the social forces model to calc-territorial-forces set territorial-forcex 0 set territorial-forcey 0 ask other turtles with [distance myself > 0] [ let to-agent (towards myself) - 180 let rabx [xcor] of myself - xcor let raby [ycor] of myself - ycor let speed magnitude vx vy let to-root ((magnitude rabx raby) + (magnitude (rabx - (speed * sin desired-direction)) (raby - (speed * cos desired-direction)))) ^ 2 - speed ^ 2 if to-root < 0 [set to-root 0] let b 0.5 * sqrt to-root let agent-force (- v0) * exp (- b / sigma) ask myself [ let agent-forcex agent-force * (sin to-agent) let agent-forcey agent-force * (cos to-agent) ;; modify the effect this force has based on whether or not it is in the field of view let vision field-of-view-modifier driving-forcex driving-forcey agent-forcex agent-forcey set territorial-forcex territorial-forcex + agent-forcex * vision set territorial-forcey territorial-forcey + agent-forcey * vision ] ] end ;; find the obstacle force of the turtle according to the social forces model to calc-obstacle-force set obstacle-forcex 0 set obstacle-forcey 0 ask patches with [pcolor = white] [ let to-obstacle (towards myself) - 180 let obstacle-force (- u0) * exp (- (distance myself) / r) ask myself [ set obstacle-forcex obstacle-forcex + obstacle-force * (sin to-obstacle) set obstacle-forcey obstacle-forcey + obstacle-force * (cos to-obstacle) ] ] end ;; find the driving force of the turtle to calc-driving-force set driving-forcex (1 / tau) * (max-speed * (sin desired-direction) - vx) * pushiness set driving-forcey (1 / tau) * (max-speed * (cos desired-direction) - vy) * pushiness end ;; find the heading towards the nearest goal to calc-desired-direction let goal min-one-of (patches with [pcolor = green]) [ distance myself ] set desired-direction towards goal end
There are 6 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
5-19-13_progress.docx | word | Progress Report | over 12 years ago, by wesley sun | Download |
5-27_progress.docx | word | Progress Report | over 12 years ago, by wesley sun | Download |
6-3_progress.docx | word | Progress Report | about 12 years ago, by wesley sun | Download |
EECS 472 Slam Slides - Wesley Sun.pptx | powerpoint | poster slam slides | about 12 years ago, by wesley sun | Download |
Pushy Jerks.pdf | Project Poster | about 12 years ago, by wesley sun | Download | |
Waiting Bar Customers.png | preview | model preview | about 12 years ago, by wesley sun | Download |
WesleySun_FinalPaper.docx | word | final project paper | about 12 years ago, by wesley sun | Download |
WesleySun_May13.docx | word | Progress Report | over 12 years ago, by wesley sun | Download |
Abhishek Bhatia
Escape Panic Netlogo Model
I wish to know if there is a model of "Simulating Dynamical Features of Escape Panic" (http://arxiv.org/pdf/cond-mat/0009448.pdf) available in NetLogo.
Posted almost 11 years ago