;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Variable declarations ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; globals [ grid-x-inc ;; the amount of patches in between two roads in the x direction grid-y-inc ;; the amount of patches in between two roads in the y direction acceleration ;; the constant that controls how much a car speeds up or slows down by if it is to accelerate or decelerate phase ;; keeps track of the phase clock ;; keeps track of the total times thru the go procedure num-cars-stopped ;; the number of cars that are stopped during a single pass thru the go procedure display-which-metric old-display-which-metric ;; holds the value of display-which-metric for the last time through the go procedure ;; patch agentsets intersections ;; agentset containing the patches that are intersections roads ;; agentset containing the patches that are roads vroads ;; agentset containing the patches that are vertical roads hroads ;; agentset containing the patches that are horizontal roads Sroads ;; Southbound roads Nroads ;; Northbound roads Eroads ;; Eastbound roads Wroads ;; Westbound roads exits ;; agentset containing the patches where cars will go out of simulation if torus off gates ;; agentset containing the patches where cars will sprout from if torus off ;vgates ;; vertical gates ;hgates ;; horizontal gates Ngates ;; Northbound gates Sgates ;; Southbound gates Egates ;; Eastbound gates Wgates ;; Westbound gates ;; string and list variables that hold data passed accumulated in the model run wait-data ;; list that holds the average wait time of the cars for each pass through the go procedure stopped-data ;; list that holds the number of stopped of the cars for each pass through the go procedure speed-data ;; list that holds the average speed of the cars for each pass through the go procedure cars-data ;; list that holds the number of cars for each pass through the go procedure time-data ;; list that holds the value of clock for each pass through the go procedure avg-range ;; range (time steps) for plot averages (blue lines) ;; vectors for keeping averages in range stopped-avgs speed-avgs wait-avgs ] turtles-own [ speed ;; the speed of the turtle v-car? ;; this will be true if the turtle moves vertically and false if it moves horizontally SE-car? ;; true if car is southboung OR eastbount (all true if four-dirs? = false) wait-time ;; the amount of time since the last time a turtle has moved ] patches-own [ intersection? ;; this is true if the patch is at the intersection of two roads accident? ;; this is true if a crash has occurred at this intersection. this will never be true for a non-intersection patch green-light-v? ;; this is true if the green light is for the vertical road. otherwise, it is false. this is only true for patches that are intersections. yellow-light? ;; this is true if there is any yellow light in the intersection. otherwise, it is false. this is only true for patches that are intersections. my-row ;; this holds the row of the intersection counting from the upper left corner of the graphics window. it is -1 for patches that are not intersections. my-column ;; this holds the column of the intersection counting from the upper left corner of the graphics window. it is -1 for patches that are not intersections. ;p = ticks-per-cycle = period ;; for now global p q ;; translation; this holds the phase for the intersection. it is -1 for patches that are not intersections. pg1 ;; period of green light 1 (north-south) pg2 ;; period of green light 2 (east-west) ;;pgx... could add more directions... kappa1 ;; number of cars * number of time steps waiting (north-south) kappa2 ;; number of cars * number of time steps waiting (east-west) lambda1 ;; number of tolerances reached (kappa1 resetted) lambda2 ;; number of tolerances reached (kappa2 resetted) greensteps ;; steps since last change of lights no-corr-p ;; p for no-corr method faulty? ;; if faulty?, then use no-corr... intersection-dirs ;; indicates directions of streets at intersection ;0=SE , 1= SW, 2= NW, 3= NE dir ;; direction ;0=E , 1= S, 2= W, 3= N southbound? eastbound? northbound? westbound? ] ;;;;;;;;;;;;;;;;;;;;; ;; Setup Functions ;; ;;;;;;;;;;;;;;;;;;;;; to startup if not four-dirs?[;; patch not to have empty variables even in 2dirs... cloc! set four-dirs? true setup true set four-dirs? false ] setup true end ;; Initialize the display by giving the global and patch variables initial values. ;; Create num-cars of turtles if there are enough road patches for one turtle to be created per road patch. ;; Setup the plots ;; "setup false" is done by the re-run button. to setup [full-setup?] clear-output if full-setup? ;; We only want to clear the patches if the we are doing a full-setup [ clear-patches ] clear-turtles clear-all-plots setup-globals full-setup? ;; First we ask the patches to draw themselves and set up a few variables setup-patches full-setup? set-default-shape turtles "car" if (((number * %vertical * %southbound) / 10000) > count Sroads ) or (((number * (100 - %vertical) * %eastbound) / 10000) > count Eroads ) or (((number * %vertical * (100 - %southbound)) / 10000) > count Nroads ) or (((number * (100 - %vertical) * (100 - %eastbound)) / 10000) > count Wroads ) [ user-message "There are too many cars for the amount of road. " + "Either increase the amount of roads by increasing the GRID-SIZE-X " + "or GRID-SIZE-Y sliders, or decrease the number of cars by lowering " + "the NUMBER slider.\nThe setup has stopped." stop ] ;; Now create the turtles and have each created turtle call the functions setup-cars and set-car-color cct number [ setup-cars true ;;true for initial setup set-car-color record-data ] ;; give the turtles an initial speed ask turtles [ set-car-speed ] update-list-info setup-plots end ;; Initialize the global variables to appropriate values to setup-globals [full-setup?] set phase 0 set clock 0 set num-cars-stopped 0 set display-which-metric 4 set avg-range 100 if full-setup? [ set grid-x-inc screen-size-x / grid-size-x set grid-y-inc screen-size-y / grid-size-y ] ;; initialize the lists and string set wait-data [] set stopped-data [] set speed-data [] set cars-data [] set time-data [] set wait-avgs n-values avg-range [0] set stopped-avgs n-values avg-range [0] set speed-avgs n-values avg-range [0] ;; don't make acceleration 0.1 since we could get a rounding error and end up on a patch boundary set acceleration 0.099 end ;; Make the patches have appropriate colors, setup the roads and intersections agentsets, ;; and initialize the traffic lights to one setting to setup-patches [full-setup?] if full-setup? [ ;; initialize the patch-own variables and color the patches to a base-color ask patches [ set intersection? false set accident? false set green-light-v? true set yellow-light? false set my-row -1 set my-column -1 set q -1 set no-corr-p -1 set faulty? false set intersection-dirs -1 set dir -1 set southbound? false set eastbound? false set northbound? false set westbound? false set pcolor brown + 3 ] ;; initialize the global variables that hold patch agentsets ifelse (homo?) [;homogeneous streets set roads patches with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2)) mod grid-x-inc) = 0) or (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 )) mod grid-y-inc) = 0) ] set intersections roads with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2)) mod grid-x-inc) = 0) and (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 ) ) mod grid-y-inc) = 0) ] set vroads roads with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2 )) mod grid-x-inc) = 0)] set hroads roads with [ (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 ) ) mod grid-y-inc) = 0)] ] [;non-homo streets ;set roads patches with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2)) mod grid-x-inc) = abs floor(pxcor / grid-x-inc)) or ; (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 )) mod grid-y-inc) = abs floor(pycor / grid-y-inc))] ;works nice for 8x8 set roads patches with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2)) mod grid-x-inc) = floor((pxcor ^ 2 )/ (grid-x-inc ^ 2 ))) or (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 )) mod grid-y-inc) = floor((pycor ^ 2 )/ (grid-y-inc ^ 2 )))] set intersections roads with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2)) mod grid-x-inc) = floor((pxcor ^ 2 )/ (grid-x-inc ^ 2 ))) and (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 ) ) mod grid-y-inc) = floor((pycor ^ 2 )/ (grid-y-inc ^ 2 ))) ] set vroads roads with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2 )) mod grid-x-inc) = floor((pxcor ^ 2 )/ (grid-x-inc ^ 2 )))] set hroads roads with [ (floor ((pycor + screen-edge-y - floor(grid-y-inc / 2 ) ) mod grid-y-inc) = floor((pycor ^ 2 )/ (grid-y-inc ^ 2 )))] ] ifelse (four-dirs?)[ set Sroads vroads with [(floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 0] set Nroads vroads with [(floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 1] set Eroads hroads with [(floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 0] set Wroads hroads with [(floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 1] set exits roads with [(((floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 0) and (pycor = (- screen-edge-y))) or (((floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 1) and (pycor = screen-edge-y)) or (((floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 0) and (pxcor = screen-edge-x)) or (((floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 1) and (pxcor = (- screen-edge-x))) ] set gates roads with [(((floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 0) and (pycor = screen-edge-y)) or (((floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 1) and (pycor = (- screen-edge-y))) or (((floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 0) and (pxcor = (- screen-edge-x))) or (((floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 1) and (pxcor = screen-edge-x)) ] set Sgates vroads with [((floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 0) and (pycor = screen-edge-y)] set Ngates vroads with [((floor ((pxcor + screen-edge-x) / grid-x-inc ) mod 2) = 1) and (pycor = (- screen-edge-y))] set Egates hroads with [((floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 0) and (pxcor = (- screen-edge-x))] set Wgates hroads with [((floor ((pycor + screen-edge-y) / grid-y-inc ) mod 2) = 1) and (pxcor = screen-edge-x)] ][ set Sroads vroads set Eroads hroads set exits roads with [(pxcor = screen-edge-x) or (pycor = (- screen-edge-y))] set gates roads with [(pxcor = (- screen-edge-x)) or (pycor = screen-edge-y)] set Egates gates with [(pxcor = (- screen-edge-x))] set Sgates gates with [(pycor = screen-edge-y)] ] ;0=E , 1= S, 2= W, 3= N if (four-dirs?)[ ask Wroads [ set dir 2 set westbound? true ] ask Nroads [ set dir 3 set northbound? true ] ] ask Eroads [ set dir 0 set eastbound? true ] ask Sroads [ set dir 1 set southbound? true ] ask roads [ set pcolor white ] ask gates [ set pcolor sky] ask exits [ set pcolor gray] ] setup-intersections full-setup? end ;; Give the intersections appropriate values for the intersection?, my-row, and my-column ;; patch variables. Make all the traffic lights start off so that the lights are red ;; horizontally and green vertically. to setup-intersections [full-setup?] reset-traffic-lights ask intersections [ set intersection? true set green-light-v? true set yellow-light? false if full-setup? [ set my-row floor ((pycor + screen-edge-y) / grid-y-inc ) set my-column floor ((pxcor + screen-edge-x) / grid-x-inc ) ;intersection-dirs 0=SE , 1= SW, 2= NW, 3= NE ifelse southbound?[ ifelse eastbound?[ set intersection-dirs 0 ][ set intersection-dirs 1 ] ][ ifelse eastbound?[ set intersection-dirs 3 ][ set intersection-dirs 2 ] ] ] set-signal-colors ] end ;; Initialize the turtle variables to appropriate values and place the turtle on an empty road patch. to setup-cars [ini?] ;; turtle procedure set speed 0 set wait-time 0 if ini?[ put-on-empty-road ] ifelse intersection? [ ifelse ((random 100) < %vertical) [ set v-car? true ] [ set v-car? false ] ;intersection-dirs 0=SE , 1= SW, 2= NW, 3= NE ifelse (v-car?)[ ifelse (intersection-dirs < 2) [ set SE-car? true ] [ set SE-car? false ] ][ ifelse (intersection-dirs = 0) or (intersection-dirs = 3) [ set SE-car? true ] [ set SE-car? false ] ] ] [ ;ifelse (floor ((pxcor + screen-edge-x - floor(grid-x-inc / 2)) mod grid-x-inc) = 0) ;dir 0=E , 1= S, 2= W, 3= N ifelse ((dir mod 2) = 1) [ set v-car? true ] ; car going in vertical direction [ set v-car? false ] ifelse (dir < 2) [ set SE-car? true ] ; car going south or east [ set SE-car? false ] ] ifelse SE-car?[ ifelse v-car? [ set heading 180 ];S [ set heading 90 ];E ][ ifelse v-car? [ set heading 0 ];N [ set heading 270 ];W ] end ;; Find a road patch without any turtles on it and place the turtle there. to put-on-empty-road ;; turtle procedure locals [road] ifelse four-dirs?[ ifelse ((random 100) < %vertical)[ ifelse ((random 100) < %southbound) [set road random-one-of Sroads] [set road random-one-of Nroads] ][ ifelse ((random 100) < %eastbound) [set road random-one-of Eroads] [set road random-one-of Wroads] ] ][ ifelse ((random 100) < %vertical) [set road random-one-of vroads] [set road random-one-of hroads] ] setxy (pxcor-of road) (pycor-of road) if any? other-turtles-here [ put-on-empty-road ] end ;; Initialize the plots to setup-plots set-current-plot "% Stopped Cars" set-plot-y-range 0 100 set-current-plot-pen "default" plot num-cars-stopped set-current-plot "Average Wait Time of Cars" set-current-plot-pen "default" plot mean values-from turtles [wait-time] set-current-plot "Average Speed of Cars" set-current-plot-pen "default" set-plot-y-range 0 speed-limit plot mean values-from turtles [speed] set-current-plot "Number of Cars" set-current-plot-pen "default" plot count turtles end ;"uncorrelates" self-org. T.L. to reset-traffic-lights ask intersections [ set q 0 set pg1 (p / 2) set pg2 (p / 2) ;set pg1 round (p / 3) ;set pg2 round (2 * p / 3) ;set pg1 (p / 3) ;set pg2 (2 * p / 3) set kappa1 0 set kappa2 0 set lambda1 0 set lambda2 0 set greensteps 0 set no-corr-p (random (screen-edge-x + 3)) if yellow-light? [set-signal-colors] ] end ;;;;;;;;;;;;;;;;;;;;;;; ;; Runtime Functions ;; ;;;;;;;;;;;;;;;;;;;;;;; ;; receives information from the clients and runs the simulation to go every delay [ ;; clear any accidents from the last time thru the go procedure clear-accidents ;; if there are any intersections that are to switch automatically, have them change their color set-signals set num-cars-stopped 0 ;; set the turtles speed for this time thru the procedure, move them forward their speed, ;; record data for plotting, and set the color of the turtles ;; to an appropriate color based on their speed ask turtles [ set-car-speed fd speed record-data set-car-color ] ;; crash the cars if crash? is true if crash? [ crash-cars ] if not torus?[ cars-remove-create ] ;; update the information in the lists of plot data update-list-info ;; update the plots with the new information from this pass thru the procedure if plots? [do-plotting] ;; update the clock and the phase clock-tick ] end ;;removes leaving cars, creates incoming cars to cars-remove-create ask turtles-on exits[;;if you please die ;; thank you... ] ifelse ((random 100) < %vertical) [ ifelse (((random 100) < %southbound) or (not four-dirs?)) [ ask Sgates[ if ((random (1 + number)) > count turtles) [;;need to do this for each gate to keep up numbers... do we? ;if ((random-float 1) >= ((count turtles) / number)) [ sprout 1 [] ] ] ][ ask Ngates[ if ((random (1 + number)) > count turtles) [ sprout 1 [] ] ] ] ][ ifelse (((random 100) < %eastbound) or (not four-dirs?)) [ ask Egates[ if ((random (1 + number)) > count turtles) [ sprout 1 [] ] ] ][ ask Wgates[ if ((random (1 + number)) > count turtles) [ sprout 1 [] ] ] ] ] ask turtles-on gates[ setup-cars false ;; false for sprouting setups set-car-color set-car-speed ] end ;; reports the amount of seconds by which to slow the model down to-report delay ifelse simulation-speed <= 0 [ report ln (10 / 0.001) ] [ report ln (10 / simulation-speed) ] end ;; have the traffic lights change color if phase equals each intersections' q to set-signals locals [ intersections-to-change intersections-to-yellow] if (control = "sotl-request") [ ;;do self-org traffic lights (crappy version) ask intersections [ self-org-request ] set intersections-to-yellow intersections with [((q = (clock mod pg1)) and (green-light-v?)) or ((q = (pg1 + (clock mod pg2))) and (not green-light-v?))] set intersections-to-change intersections with [((q = ((clock - 1) mod pg1)) and (green-light-v?)) or ((q = (pg1 + ((clock - 1) mod pg2))) and (not green-light-v?))] ] if (control = "sotl-phase") [ ;;do self-org traffic lights ask intersections [ self-org-phase ] set intersections-to-change intersections with [(((q + pg2 + 1) mod p = phase) and (green-light-v?)) or (((q + 1) mod p = phase) and (not green-light-v?))] set intersections-to-yellow intersections with [(((q + pg2) mod p = phase) and (green-light-v?)) or (((q) mod p = phase) and (not green-light-v?))] ] if (control = "sotl-platoon") [ ;;do self-org traffic lights ask intersections [ self-org-platoon ] set intersections-to-change intersections with [(((q + pg2 + 1) mod p = phase) and (green-light-v?)) or (((q + 1) mod p = phase) and (not green-light-v?)) ;and (faulty? = false)) ;or ((phase = no-corr-p) and (faulty? = true)) ] set intersections-to-yellow intersections with [(((q + pg2) mod p = phase) and (green-light-v?)) or (((q) mod p = phase) and (not green-light-v?)) ;and (faulty? = false)) ;or ((phase = no-corr-p - 1) and (faulty? = true)) ] ] if (control = "marching") [;; marching control set intersections-to-change intersections with [(phase = 0) ;or ((phase = no-corr-p) and (faulty? = true)) ] set intersections-to-yellow intersections with [(phase = p - 1) ;or ((phase = no-corr-p - 1) and (faulty? = true)) ] ] if (control = "optim");; optimized for south+eastbounds [;; "green-wave" control set p (screen-edge-x + 3) ;NOTE:!!! screen-edge-x = screen-edge-y set intersections-to-change intersections with ;[phase = round (((screen-edge-x + pxcor)) / 2)] ;;; works for horizontal cars... the tricky bit comes when there are also vertical... cannot synch torus... [(phase = round (((screen-edge-x + pxcor) + (screen-edge-y - pycor)) / 4)) ;or ((phase = no-corr-p) and (faulty? = true)) ] set intersections-to-yellow intersections with [(phase = round (((screen-edge-x + pxcor) + (screen-edge-y - pycor)) / 4) - 1) ;or ((phase = no-corr-p - 1) and (faulty? = true)) ] ] if (control = "no-corr") [;; no correlation in phases set p (screen-edge-x + 3) ;NOTE:!!! screen-edge-x = screen-edge-y set intersections-to-change intersections with [phase = no-corr-p] set intersections-to-yellow intersections with [phase = no-corr-p - 1] ] if (control = "cut-off") [;; turn green when WAITING queue reaches queue-cut ask intersections [ cut-off-count ] set intersections-to-change intersections with [(q = 1) ;or ((phase = no-corr-p) and (faulty? = true)) ] set intersections-to-yellow intersections with [(q = 0) ;or ((phase = no-corr-p - 1) and (faulty? = true)) ] ] ask intersections-to-change [ set green-light-v? (not green-light-v?) set-signal-colors ] if (yellow?) [ ask intersections-to-yellow [ set-signal-yellow ] ] end ;; This procedure counts waiting cars in redlight, q=0 if >=queue-cut... (for yellow) to cut-off-count ;; intersection (patch) procedure locals [ cars i] ifelse (q != 0)[ set cars 0 set q -1 set i 0 ifelse (not green-light-v?) [ while [i <= queue-cut] [ ;intersection-dirs 0=SE , 1= SW, 2= NW, 3= NE ifelse southbound? [set cars (cars + count (turtles-at 0 i))] [set cars (cars + count (turtles-at 0 (- i)))] set i (i + 1) ] ] [ while [i <= queue-cut] [ ifelse eastbound? [set cars (cars + count (turtles-at (- i) 0))] [set cars (cars + count (turtles-at i 0))] set i (i + 1) ] ] if (cars >= queue-cut) and (greensteps > mingreen)[ set q 0 ] ] [ set q 1 ] end ;; This procedure self-organizes the pg's and q's of intersections to optimize traffic flow... to self-org-request ;; intersection (patch) procedure locals [ cars1 cars2 x y i] ifelse (not green-light-v?) [ set i 0 set cars1 0 while [i < grid-y-inc] [ ;intersection-dirs 0=SE , 1= SW, 2= NW, 3= NE ifelse southbound? [set cars1 (cars1 + count (turtles-at 0 i))] [set cars1 (cars1 + count (turtles-at 0 (- i)))] set i (i + 1) ] set kappa1 (kappa1 + cars1) if (kappa1 > tolerance) [ set q (pg1 + (clock mod pg2)) set kappa1 0 ] ] [ set i 0 set cars2 0 while [i < grid-x-inc] [ ifelse eastbound? [set cars2 (cars2 + count (turtles-at (- i) 0))] [set cars2 (cars2 + count (turtles-at i 0))] set i (i + 1) ] set kappa2 (kappa2 + cars2) if (kappa2 > tolerance) [ set q (clock mod pg1) set kappa2 0 ] ] end ;; This procedure self-organizes the pg's and q's of intersections to optimize traffic flow... to self-org-phase ;; intersection (patch) procedure locals [ cars1 cars2 i] ifelse (not green-light-v?) [;;red light from north set i 1 set cars1 0 while [i < grid-y-inc - 1] [ ifelse southbound? [set cars1 (cars1 + count (turtles-at 0 i))] [set cars1 (cars1 + count (turtles-at 0 (- i)))] set i (i + 1) ] set kappa1 (kappa1 + cars1) if (kappa1 > tolerance) and (not yellow-light?) and (greensteps > mingreen)[ set q phase adj-q set kappa1 0 set lambda1 (lambda1 + 1) if (metatolerance > 0) and (lambda1 >= metatolerance) ;; adjust pg's [ if (pg2 > 1) [ ;; should change if more than two pg's set pg2 (pg2 - 1) set pg1 (pg1 + 1) ] set lambda1 0 ] ] ] [;;red light from west set i 1 set cars2 0 while [i < grid-x-inc - 1] [ ifelse eastbound? [set cars2 (cars2 + count (turtles-at (- i) 0))] [set cars2 (cars2 + count (turtles-at i 0))] set i (i + 1) ] set kappa2 (kappa2 + cars2) if (kappa2 > tolerance) and (not yellow-light?) and (greensteps > mingreen)[ set q (phase - pg2) adj-q set kappa2 0 set lambda2 (lambda2 + 1) if (metatolerance > 0) and (lambda2 >= metatolerance) ;; adjust pg's [ if (pg1 > 1) [ ;; should change if more than two pg's set pg1 (pg1 - 1) set pg2 (pg2 + 1) ] set lambda2 0 ] ] ] end ;; This procedure self-organizes the pg's and q's of intersections to optimize traffic flow... to self-org-platoon ;; intersection (patch) procedure locals [ cars i] ifelse (not green-light-v?) [;;red light from north set i 1 set cars 0 while [i < grid-y-inc - 1] [ ifelse southbound? [set cars (cars + count (turtles-at 0 i))] [set cars (cars + count (turtles-at 0 (- i)))] set i (i + 1) ] set kappa1 (kappa1 + cars) set i 1 set cars 0 while [i < keep-platoon] [ ifelse eastbound? [set cars (cars + count (turtles-at (- i) 0))] [set cars (cars + count (turtles-at i 0))] set i (i + 1) ] if (kappa1 > tolerance) and (not yellow-light?) and (greensteps > mingreen) and ((0 = cars) or ((cars >= cut-platoon) and (cars < (keep-platoon - 1))))[ set q phase adj-q set kappa1 0 set lambda1 (lambda1 + 1) if (metatolerance > 0) and (lambda1 >= metatolerance) ;; adjust pg's [ if (pg2 > 1) [ ;; should change if more than two pg's set pg2 (pg2 - 1) set pg1 (pg1 + 1) ] set lambda1 0 ] ] ] [;;red light from west set i 1 set cars 0 while [i < grid-x-inc - 1] [ ifelse eastbound? [set cars (cars + count (turtles-at (- i) 0))] [set cars (cars + count (turtles-at i 0))] set i (i + 1) ] set kappa2 (kappa2 + cars) set i 1 set cars 0 while [i < keep-platoon] [ ifelse southbound? [set cars (cars + count (turtles-at 0 i))] [set cars (cars + count (turtles-at 0 (- i)))] set i (i + 1) ] if (kappa2 > tolerance) and (not yellow-light?) and (greensteps > mingreen) and ((0 = cars) or ((cars >= cut-platoon) and (cars < (keep-platoon - 1))))[ set q (phase - pg2) adj-q set kappa2 0 set lambda2 (lambda2 + 1) if (metatolerance > 0) and (lambda2 >= metatolerance) ;; adjust pg's [ if (pg1 > 1) [ ;; should change if more than two pg's set pg1 (pg1 - 1) set pg2 (pg2 + 1) ] set lambda2 0 ] ] ] end ;; bounds q to adj-q ;; intersection (patch) procedure if (q < 0) [ set q (q + p) ] if (q > p) [ set q (p mod q)] end ;; This procedure checks the variable green-light-v? at each intersection and sets the ;; traffic lights to have the green light up or the green light to the left. to set-signal-colors ;; intersection (patch) procedure ifelse power? [ set yellow-light? false set greensteps 0 ;intersection-dirs 0=SE , 1= SW, 2= NW, 3= NE if (intersection-dirs = 0)[;SE ifelse green-light-v?[ set (pcolor-of patch-at -1 0) red set (pcolor-of patch-at 0 1) green ][ set (pcolor-of patch-at -1 0) green set (pcolor-of patch-at 0 1) red ] ] if (intersection-dirs = 1)[;SW ifelse green-light-v?[ set (pcolor-of patch-at 1 0) red set (pcolor-of patch-at 0 1) green ][ set (pcolor-of patch-at 1 0) green set (pcolor-of patch-at 0 1) red ] ] if (intersection-dirs = 2)[;NW ifelse green-light-v?[ set (pcolor-of patch-at 1 0) red set (pcolor-of patch-at 0 -1) green ][ set (pcolor-of patch-at 1 0) green set (pcolor-of patch-at 0 -1) red ] ] if (intersection-dirs = 3)[;NE ifelse green-light-v?[ set (pcolor-of patch-at -1 0) red set (pcolor-of patch-at 0 -1) green ][ set (pcolor-of patch-at -1 0) green set (pcolor-of patch-at 0 -1) red ] ] ] [ set (pcolor-of patch-at -1 0) white set (pcolor-of patch-at 0 1) white set (pcolor-of patch-at 1 0) white set (pcolor-of patch-at 0 -1) white ] end ;; to set-yellow-lights to set-signal-yellow ;; intersection (patch) procedure ifelse power? [ set yellow-light? true ;intersection-dirs 0=SE , 1= SW, 2= NW, 3= NE if (intersection-dirs = 0)[;SE ifelse green-light-v?[ set (pcolor-of patch-at -1 0) red set (pcolor-of patch-at 0 1) yellow ][ set (pcolor-of patch-at -1 0) yellow set (pcolor-of patch-at 0 1) red ] ] if (intersection-dirs = 1)[;SW ifelse green-light-v?[ set (pcolor-of patch-at 1 0) red set (pcolor-of patch-at 0 1) yellow ][ set (pcolor-of patch-at 1 0) yellow set (pcolor-of patch-at 0 1) red ] ] if (intersection-dirs = 2)[;NW ifelse green-light-v?[ set (pcolor-of patch-at 1 0) red set (pcolor-of patch-at 0 -1) yellow ][ set (pcolor-of patch-at 1 0) yellow set (pcolor-of patch-at 0 -1) red ] ] if (intersection-dirs = 3)[;NE ifelse green-light-v?[ set (pcolor-of patch-at -1 0) red set (pcolor-of patch-at 0 -1) yellow ][ set (pcolor-of patch-at -1 0) yellow set (pcolor-of patch-at 0 -1) red ] ] ] [ set (pcolor-of patch-at -1 0) white set (pcolor-of patch-at 0 1) white set (pcolor-of patch-at 1 0) white set (pcolor-of patch-at 0 -1) white ] end ;; set any intersection's color that had an accident back to white and make accident? false to clear-accidents if crash? [ ask patches with [accident?] [ set pcolor white set accident? false ] ] end ;; set the turtles' speed based on whether they are at a red traffic light or the speed of the ;; turtle (if any) on the patch in front of them to set-car-speed ;; turtle procedure ifelse (pcolor = red) or (pcolor = yellow) [ set speed 0 ] [ if intersection?[ if ((random 100) < prob-turn)[ turn-car ] ] ifelse v-car?[ ifelse SE-car? [ set-speed 0 -1 ] ;S [ set-speed 0 1 ] ;N ][ ifelse SE-car? [ set-speed 1 0 ] ;E [ set-speed -1 0 ] ;w ] ] end ;; set the speed variable of the turtle to an appropriate value (not exceeding the ;; speed limit) based on whether there are turtles on the patch in front of the turtle to set-speed [delta-x delta-y] ;; turtle procedure locals [ up-cars?-ahead turtles-ahead ] ;; get the turtles on the patch in front of the turtle ask patch-at delta-x delta-y [ set turtles-ahead turtles-here ] ;; if there are turtles in front of the turtle, slow down ;; otherwise, speed up ifelse any? turtles-ahead [ set up-cars?-ahead values-from turtles-ahead [v-car?] ifelse member? v-car? up-cars?-ahead and member? (not v-car?) up-cars?-ahead [ if not crash? [ set speed 0 ] ] [ set speed speed-of one-of turtles-ahead slow-down ] ] [ speed-up ] end ;; decrease the speed of the turtle to slow-down ;; turtle procedure ifelse speed <= 0 ;;if speed < 0 [ set speed 0 ] [ set speed speed - acceleration ] end ;; increase the speed of the turtle to speed-up ;; turtle procedure ifelse speed >= speed-limit ;;should be >= if speed should not go above 1... [ set speed speed-limit ] [ set speed speed + acceleration ] end ;; set the color of the turtle to a different color based on how fast the turtle is moving to set-car-color ;; turtle procedure ifelse speed < (speed-limit / 2) [ set color blue ] [ set color cyan - 2 ] end ;; changes direction of car at intersection to turn-car ;; turtle procedure slow-down ;;setxy (int xcor) (int ycor) ifelse v-car?[ ifelse eastbound? [set SE-car? true set heading 90 ] ;->E [set SE-car? false set heading 270 ] ;->W ][ ifelse southbound? [set SE-car? true set heading 180 ] ;->S [set SE-car? false set heading 0 ] ;->N ] set v-car? (not v-car?) end ;; keep track of the number of stopped turtles and the amount of time a turtle has been stopped ;; if its speed is 0 to record-data ;; turtle procedure ifelse speed = 0 [ set num-cars-stopped num-cars-stopped + 1 set wait-time wait-time + 1 ] [ set wait-time 0 ] end ;; crash any turtles at the same intersection going in different directions to crash-cars ask intersections with [any? turtles-here with [v-car?] and any? turtles-here with [not v-car?]] [ set accident? true set pcolor orange ] end ;; add the new information from this pass thru the go procedure to the HubNet lists to update-list-info set num-cars-stopped (100 * num-cars-stopped / number) set wait-data lput (mean values-from turtles [wait-time]) wait-data set stopped-data lput num-cars-stopped stopped-data set speed-data lput (mean values-from turtles [speed]) speed-data set cars-data lput (count turtles) cars-data set time-data lput clock time-data set wait-avgs replace-item (clock mod avg-range) wait-avgs (mean values-from turtles [wait-time]) set stopped-avgs replace-item (clock mod avg-range) stopped-avgs (num-cars-stopped) set speed-avgs replace-item (clock mod avg-range) speed-avgs (mean values-from turtles [speed]) end ;; plot the data from this pass thru the go procedure to do-plotting set-current-plot "% Stopped Cars" set-current-plot-pen "default" plot num-cars-stopped set-current-plot-pen "avg" plot mean stopped-avgs ;plot mean filter [(position ? reverse stopped-data) < avg-range] stopped-data set-current-plot-pen "global" plot mean stopped-data set-current-plot "Average Wait Time of Cars" set-current-plot-pen "default" plot mean values-from turtles [wait-time] set-current-plot-pen "avg" ;plot mean filter [(position ? reverse wait-data) < avg-range] wait-data plot mean wait-avgs set-current-plot-pen "global" plot mean wait-data set-current-plot "Average Speed of Cars" set-current-plot-pen "default" plot mean values-from turtles [speed] set-current-plot-pen "avg" ;plot mean filter [(position ? reverse speed-data) < avg-range] speed-data plot mean speed-avgs set-current-plot-pen "global" plot mean speed-data set-current-plot "Number of Cars" set-current-plot-pen "default" plot count turtles set-current-plot-pen "global" plot mean cars-data end to plot-new-value [name-of-plot value] set-current-plot name-of-plot plot value end to clear-plots-and-plot-in-new-plot [name-of-plot list-to-plot] clear-all-plots plot-new-list name-of-plot list-to-plot end to plot-new-list [name-of-plot list-to-plot] locals [index] set index 0 set-current-plot name-of-plot clear-plot repeat length list-to-plot [ plot item index list-to-plot set index index + 1 ] end to plot-value-and-lists [value-plot value list-plot1 list-to-plot1 list-plot2 list-to-plot2] plot-new-value value-plot value plot-new-list list-plot1 list-to-plot1 plot-new-list list-plot2 list-to-plot2 end ;; increases the clock by 1 and cycles phase to the next appropriate value to clock-tick set clock clock + 1 ;; The phase cycles from 0 to p, then starts over. set phase phase + 1 if phase mod p = 0 [ set phase 0 ] ask intersections [ set greensteps (greensteps + 1) ] end ; *** NetLogo Model Copyright Notice *** ; ; This activity and associated models and materials was created as part of the projects: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and ; INTEGRATED SIMULATION AND MODELING ENVIRONMENT. ; These projects gratefully acknowledge the support of the ; National Science Foundation (REPP & ROLE programs) -- grant numbers ; REC #9814682 and REC-0126227. ; ; Copyright 2002 by Uri Wilensky & Walter Stroup. Updated 2002. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from the copyright holders. ; Contact the copyright holders for appropriate licenses for redistribution ; for profit. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. & Stroup, W. (2002). NetLogo HubNet Gridlock model. ; http://ccl.northwestern.edu/netlogo/models/HubNetGridlock. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky and Walter Stroup. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/HubNetGridlock ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 491 10 984 524 80 80 3.0 1 12 1 1 1 0 1 1 1 CC-WINDOW 5 872 993 967 Command Center 0 PLOT 0 669 279 858 Average Wait Time of Cars Time Average Wait 0.0 100.0 0.0 5.0 true false PENS "default" 1.0 0 -2674135 true "avg" 1.0 0 -13345367 true "global" 1.0 0 -16777216 true PLOT 0 292 279 481 Average Speed of Cars Time Average Speed 0.0 100.0 0.0 1.0 true false PENS "default" 1.0 0 -2674135 true "avg" 1.0 0 -13345367 true "global" 1.0 0 -16777216 true SLIDER 100 10 197 43 grid-size-y grid-size-y 1 20 8 1 1 NIL SLIDER 3 10 97 43 grid-size-x grid-size-x 1 20 8 1 1 NIL SWITCH 195 82 285 115 crash? crash? 1 1 -1000 SWITCH 4 82 99 115 power? power? 0 1 -1000 SLIDER 4 46 155 79 number number 1 3000 320 1 1 cars PLOT 0 479 279 668 % Stopped Cars Time % Stopped Cars 0.0 100.0 0.0 100.0 true false PENS "default" 1.0 0 -2674135 true "avg" 1.0 0 -13345367 true "global" 1.0 0 -16777216 true BUTTON 212 257 276 290 Go go T 1 T OBSERVER T NIL SLIDER 3 119 131 152 simulation-speed simulation-speed 0 10.0 10.0 0.1 1 NIL BUTTON 396 83 480 116 Setup setup true NIL 1 T OBSERVER T NIL SLIDER 135 119 227 152 speed-limit speed-limit 0.0 1.0 1.0 0.1 1 NIL BUTTON 2 257 58 290 Re-Run setup false NIL 1 T OBSERVER T NIL MONITOR 282 237 359 286 Current Phase phase 3 1 SLIDER 4 154 99 187 p p 1 200 83 1 1 timesteps BUTTON 132 257 206 290 Refresh Plots clear-all-plots NIL 1 T OBSERVER T NIL SLIDER 4 187 176 220 tolerance tolerance 1 300 41 1 1 cars * timesteps BUTTON 64 257 126 290 ResetTL reset-traffic-lights NIL 1 T OBSERVER T NIL SLIDER 156 46 261 79 %vertical %vertical 0 100 50 1 1 % SLIDER 3 222 176 255 metatolerance metatolerance 0 10 0 1 1 tolerances SWITCH 101 82 191 115 yellow? yellow? 0 1 -1000 CHOOSER 179 210 282 255 control control "marching" "optim" "cut-off" "sotl-request" "sotl-phase" "sotl-platoon" "no-corr" 5 SLIDER 102 153 230 186 mingreen mingreen 0 50 20 1 1 timesteps SWITCH 202 10 292 43 torus? torus? 0 1 -1000 MONITOR 419 237 476 286 cars count turtles 0 1 PLOT 281 290 481 440 Number of Cars Time cars 0.0 100.0 0.0 100.0 true false PENS "default" 1.0 0 -2674135 true "global" 1.0 0 -16777216 true SWITCH 295 10 393 43 four-dirs? four-dirs? 1 1 -1000 SLIDER 263 47 370 80 %southbound %southbound 0 100 50 1 1 NIL SLIDER 373 46 472 79 %eastbound %eastbound 0 100 50 1 1 NIL SWITCH 291 450 394 483 plots? plots? 0 1 -1000 MONITOR 360 237 417 286 NIL clock 3 1 SLIDER 287 82 393 115 prob-turn prob-turn 0 1 0.0 0.01 1 NIL SLIDER 232 153 366 186 keep-platoon keep-platoon 0 10 5 1 1 patches SLIDER 367 153 491 186 cut-platoon cut-platoon 0 10 3 1 1 cars SLIDER 287 189 394 222 queue-cut queue-cut 1 10 3 1 1 cars SWITCH 395 10 485 43 homo? homo? 0 1 -1000 @#$#@#$#@ WHAT IS IT? ----------- This simulation was exended from the model "Gridlock" by Uri Wilensky & Walter Stroup, which comes with NetLogo 2.0.0 (see more info at the bottom) Traffic lights try to "self-organize" for improving traffic. Traffic is not so much an optimization problem, but an adaptation problem, since traffic flows and densities change constantly. Optimization gives the best possible solution for a given configuration. But since in real traffic the configuration is constantly changing, it seems that we would do better with an adaptive mechanism than a mechanism which is optimal some times, and some times creates havoc (and it is too expensive to try to find all possible optimal solutions, since the configuration space is too huge and uncertain...). NOTES: ------ + Only q's are quite adaptive, but do not generate "excessive" synchronization... what occurs is that "convoys" are formed, which can pass much faster at intersections, and in turn leave space for other convoys... but resetting T.L. does not create much difference... + By mistake, Working with "wrong" parameters (non integer pg's): it switches traffic light ONLY when "tolerance" is reached. Light changes only by "request", but no actual internal clock... In any case, through stigmergy, cars self-organize... It actually seems to perform better: +It turns out that when the lights change by themselves, the algorithm is not as good... (changes when noone needs it) +Then only one parameter to deal with: tolerance + Adjusment of pg's (metatolerance > 0) decreases the performance of self-org... (too many attempts to self-org can cause noise... similar to overfitting in ANN's???) + different "tolerance" & p good for different densities? (shape the size of "convoys") + std deviations of speed & waiting cars increase probability of traffic jam... self-org strategies have much less std. devs... + for medium traffic density (100 cars) and several streets (9x9), sotl-request works better (this should be chosen if too much noise will affect the return of cars... since real cities are not toroidal, probably this would be a better option for implementation...). Also to reduce the tolerance improves performance (e.g. 18 cars*ts). For higher density (200 cars) both sotl request and phase similar... For very high density (300 cars), phase better than request. If tolerance is higher, then request better... Long platoons (convoys) can promote traffic jams... good to have them, but not too long... High traffic density will give long platoons no matter what, but sotl-request seems to be better at keeping them short. For few streets (3x3) sotl-phase seems to be best. For higher densities request needs higher tolerance in order to work properly, but sotl-phase works fine with different densities and same tolerance... + With very high traffic density, sotl-phase behaves almost as marching, which is ok to avoid traffic jams... Higher tolerance or mingreen might be better for this method in high density... (Marching is best strategy to avoid deadlocks for very high traffic density (>300,400,600 cars in 5x5)). For these densities, more waiting times and stopped cars give more average speed, because of reaction times. + self-org platoons observed of 3<=cars<=15, for tolerance=41, p=43, cars=74, 5x4, 81x81 patches. It depends on distance between intersections and tolerance + %vertical seems not to affect much the avgs. of static strategies, but sotl improve, performance slightly, especially sotl-request, and this increases with the extremity of %vertical + optim is "designed" for optimizing south+eastbound traffic. The difference of all traffic goind SE vs. all going NW is less than 0.1 ptch/ts avg. +sotl-phase also reaches full synch in 4-dir+torus +sotl-platoon better at low densities -> more robust full synch, but gets more quickly into traffic jams... +main idea: should keep platoons nor too short nor too long... and as stable as possible... TODO's: ------- -prioritary vehicles: add weights to cars in sotl methods for kappas, override in other methods... -make proper non-homo streets... cloc! -could do different strategies per intersection, to compare the effect of one self-org in a meching system, or a marhcing in a s-o.s.... (how much noise would this last case propagate? Similar to faulty intersection...) -something really nasty goes on with metatolerance>0... -do "forgetting" of lambdas and kappas (~forgetting) -try to reach some general adaptive synchronization: this seems to be required in order to avoid traffic jams when traffic is dense... well, the "request" model does that... -bug when 2dirs are created BEFORE a setup of 4dirs is run. Crappy temporal solution: do a setup of 4dirs, then play with 2dirs CHANGELOG: ---------- 1.04 2005-12-06 Added lookahead to sotl-platoon... works a bit, but traffic jams still occur when cars stop blocking other streets... 1.03 2005-08-24 Fixed maxspeed bug... 1.02 2005-08-24 Maxgreen try (didn't work) 1.01 2005-02-22 non-homo streets (beta), sotl still rule, full synch & everything... 1.00 2005-02-02 completed Information on how to use it.... 0.23 2005-01-24 tested with faulty interesections, no big difference for any method... 0.22 2005-01-19 added cut-off method (so so...) 0.21 2004-12-10 added cut-platoon slider... sotl-platoon not good for high densities... 0.20 2004-11-28 improved sotl-platoon method, now better for high densities... 0.19 2004-11-28 added sotl-platoon method, get more robust full synch... 0.18 2004-11-24 added no-corr method 0.17 2004-11-22 added avgCars in graph 0.16 2004-11-17 changed to 10x10 grid 0.15 2004-10-13 implemented turns implemented plots? switch 0.14 2004-10-12 fixed initial %'s 0.13 2004-10-12 implemented 4 dirs. sotl rules! 0.12 2004-10-12 adjusted non-torus to include %vertical 0.11 2004-10-11 non-torus implemented. sotl strategies still better 0.10 2004-10-11 moved interesections a bit, begining to implement non-torus 0.09 2004-10-07 Did first stats, found full synch, fixed bug of yellow lights in ResetTL 0.08 2004-06-16 ??? 0.07 2004-06-15 Added "optim" strategy: it sucks! it's crap! worse than march Fixed sotl-request (sotl-phase with mingreen works bit better) 0.06 2004-06-08 Added switch for different control strategies (now marching, sotl-request, sotl-phase (last better)) Added mingreen, not to have constant changes of lights, seems to work good. 0.05 2004-06-04 Added means to plot, shows more clearly that SOTL work better than half on, half off.... need to compare with real control techniques 0.04 2004-03-30 fixed some bugs... it wasn't working properly (previous bugs turned out to be features...) 0.03 2004-03-29 added lambdas and adjustment of pg's fixed yellow-light bug (no change of q when yellow-light?) 0.02 2004-03-26 added yellow lights added %vertical for different traffic densities 0.01 2004-03-22 included pg1 and pg2 for different lights added kappas and adjustment of q already does better than "all on or off" 0.00 2004-03-22 just removed Hubnet functions HOW TO USE IT ------------- QUICKSTART INSTRUCTIONS: ------------------------ Run "Setup" before starting simulation. Then start and stop with "Go". Some parameters, such as grid-sizes and four-dirs? will be applied only after pressing "Setup". Tip: you can "freeze" the display (on top of the "city" display) and/or switch off the plots to accelerate simulations. For model details, consult the paper "Self-Organizing Traffic Lights" http://uk.arxiv.org/abs/nlin.AO/0411066 BUTTONS: -------- "Setup"- Initializes simulation "Re-run"- "soft" and quick "Setup" (just clears variables, doesn't change street topology) "Reset-TL"- Turns phases of adaptive control methods ("sotl"'s and "cut-off") to zero, so that they need to adapt again (to check robustness) "Go"- Start and stop simulation CHOOSERS: -------- -control- select control method for traffic lights +when changing methods during the same run, resetTL. (If one was yellow, can cause problems...) SLIDERS: -------- "grid-size-x"- number of vertical streets "grid-size-y"- number of horizontal streets "number"- initial number of cars for "Setup" and "Re-run", maximum number of cars when torus? is off %vertical- percentage of cars flowing in vertical roads (%horizontal= 100-%vertical) %southbound- percentage of cars flowing in southbound roads (%northbound= 100-%southbound) %eastbound- percentage of cars flowing in eastbound roads (%westbound= 100-%eastbound) prob-turn- probability of turning at an intersection simulation-speed- regulates processing speed speed-limit- maximum speed of cars p- phase period for cyclic control methods ("marching", "optim", and "no-corr") mingreen- minimum green phase for "sotl-phase" and "sotl-platoon" controls keep-platoon- "omega" distance at which carsh are checked from green light in "sotl-platoon" control cut-platoon- "miu" cars approaching a green light at which platoons can be cut in "sotl-platoon" control queue-cut- lambda queue length for "cut-off" control tolerance- "theta" threshold for all "sotl" control methods metatolerance- attempt of metaadaptive regime. Doesn't work, keep set to zero... SWITCHES: --------- torus?- switches cyclic boundaries on and off four-dirs?- toggle between two and four directions (needs "Setup") homo?- toggle between homogeneous and heterogeneous street distances (needs "Setup") -works nicely for 8x8 power?- makes traffic lights work yellow?- include yellow phase (1 timestep) between green and red phases crash?- monitor crashes at intersections plots?- switches plotting (off increases simulation speed) CREDITS AND REFERENCES OF ORIGINAL "GRIDLOCK" ---------------------- This activity and associated models and materials was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and INTEGRATED SIMULATION AND MODELING ENVIRONMENT. These projects gratefully acknowledge the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Copyright 2002 by Uri Wilensky & Walter Stroup. All rights reserved. Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed: a) this copyright notice is included. b) this model will not be redistributed for profit without permission from the copyright holders. Contact the copyright holders for appropriate licenses for redistribution for profit. To refer to this model in academic publications, please use: Wilensky, U. & Stroup, W. (2002). NetLogo HubNet Gridlock model. http://ccl.northwestern.edu/netlogo/models/HubNetGridlock. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 2002 by Uri Wilensky and Walter Stroup. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/HubNetGridlock for terms of use. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 car true 15 Circle -1 false true 185 55 60 Circle -1 false true 183 186 61 Polygon -1 true true 214 52 214 22 182 26 162 38 144 74 138 102 100 120 99 161 102 201 118 246 152 267 190 275 210 251 187 240 178 200 204 182 215 181 214 118 193 112 182 98 181 72 198 52 @#$#@#$#@ NetLogo 3.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@