Status-quo parking

Status-quo parking preview image

1 collaborator

Default-person zhibin chen (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.2.0 • Viewed 234 times • Downloaded 13 times • Run 0 times
Download the 'Status-quo parking' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

Globals [ticks1 ticks2 ticks3 z1 z2 z3 w1 w2 w3 t1 t2 t3 walk avgwalk num]
turtles-own [parktimer distparked diststart disttraveled parked]
;;parked is a boolean indicating whether a car is parked or not
;;parktimer is a counter that counts down to when a parked car departs
;;ticks2 is a counter that resets every time a new car is created
 
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to setup
  clear-all
  setup-patches
  setup-turtles
  reset-ticks
  set w1 list "null" "Walking Distance"
  set t1 list "null" "Walking Distance"
  set w2 list "null" "Walking Distance"
  set t2 list "null" "Walking Distance"
  set w3 list "null" "Walking Distance"
  set t3 list "null" "Walking Distance"
  set z1 round(random-exponential arrival_headway1)
  set z2 round(random-exponential arrival_headway2)
  set z3 round(random-exponential arrival_headway3)
  set num 0
end 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to setup-patches
  ask patch 0 1 [ set pcolor 75]
  ask patches with [ pycor = -1]
  [
    set pcolor green
      if (pxcor mod 2 = 0)
      [ 
        set pcolor green + 2
      ]
  ]
  ask patches with [pycor = 0]
    [
      set pcolor gray
    ]
end 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to setup-turtles 
  ask n-of 1 patches with [pycor = -1] 
  [                    
    sprout 1 [set parktimer round((random-exponential depart_headway))]
  ]        
  
  ;print max [count turtles-here] of patches
  ask turtles with [who > 0]
  [
    set color blue
    set shape "car"
    set heading 90
    set pcolor red
  ]

  Ask turtle 0 
  [
    set color orange
    set shape "car"
    set heading 90
    set xcor (- startposition1)                                           ;;This xcor indicates the spot where someone will start searching
    set ycor 0                                                           ;;ycor of 0 indicates this car is on the road
    set diststart abs(xcor)
    set parked false
  ]
end 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to advance
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ifelse ticks = 0 []                                                   ;; I change this function to reset z only when ticks2 has reached to z;indicates an exponential arrival rate with mean lambda set by the user) ;; it is a float point
  [                                                                     ;;This is the arrival rate/creation of new cars searching for parking
   ifelse (ticks1 >= z1 and (not any? turtles-on patches with [(pycor = 0) and (pxcor = (- startposition1))])) 
   [  
    create-turtles 1 
    [    
          set color orange - 2
          set shape "car"
          set heading 90
          set xcor (- startposition1)
          set diststart  xcor
          set parked false
          set parktimer round(random-exponential depart_headway)
    ]
    set ticks1 0
    set z1 round(random-exponential arrival_headway1)
   ]
   [                                   
    set ticks1 ticks1 + 1
   ]
  ]
  
  
   ask turtles with [ (color = orange) and (ycor = 0)] 
   [
     ifelse( any? turtles-on patch-at 0 -1)
     [
       forward 1
     ]
     [
       right 90
       forward 1
       set pcolor red
       set distparked abs(xcor)
       set disttraveled (xcor + startposition1)                   ;cruise distance
       set w1 lput (abs(distparked)) w1
       set t1 lput (disttraveled) t1
       set parked true
       set num num + 1
       set walk walk + (abs(distparked))
       set avgwalk (walk / num)
      ]
   ]

   ask turtles with [ (color = orange - 2) and (ycor = 0)]
   [
     set color orange
   ]
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ifelse ticks = 0 []                                                   
  [                                                                     ;;This is the arrival rate/creation of new cars searching for parking
   ifelse (ticks2 >= z2 and (not any? turtles-on patches with [(pycor = 0) and (pxcor = (- startposition2))])) 
   [  
    create-turtles 1 
    [    
          set color lime - 2
          set shape "car"
          set heading 90
          set xcor (- startposition2)
          set diststart  xcor
          set parked false
          set parktimer round(random-exponential depart_headway)
    ]
    set ticks2 0
    set z2 round(random-exponential arrival_headway2)
   ]
   [                                   
    set ticks2 ticks2 + 1
   ]
  ]
  
   ask turtles with [ (color = lime) and (ycor = 0)] 
   [
     ifelse( any? turtles-on patch-at 0 -1)
     [
       forward 1
     ]
     [
       right 90
       forward 1
       set pcolor red
       set distparked abs(xcor)
       set disttraveled (xcor + startposition2)                   ;cruise distance
       set w2 lput (abs(distparked)) w2
       set t2 lput (disttraveled) t2
       set parked true
       set num num + 1
       set walk walk + (abs(distparked))
       set avgwalk (walk / num)
      ]
   ]

   ask turtles with [ (color = lime - 2) and (ycor = 0)]
   [
     set color lime
   ]  
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
  ifelse ticks = 0 []                                                   
  [                                                                     ;;This is the arrival rate/creation of new cars searching for parking
   ifelse (ticks3 >= z3 and (not any? turtles-on patches with [(pycor = 0) and (pxcor = (- startposition3))])) 
   [  
    create-turtles 1 
    [    
          set color cyan - 2
          set shape "car"
          set heading 90
          set xcor (- startposition3)
          set diststart  xcor
          set parked false
          set parktimer round(random-exponential depart_headway)
    ]
    set ticks3 0
    set z3 round(random-exponential arrival_headway3)
   ]
   [                                   
    set ticks3 ticks3 + 1
   ]
  ]
  
   ask turtles with [ (color = cyan) and (ycor = 0)] 
   [
     ifelse( any? turtles-on patch-at 0 -1)
     [
       forward 1
     ]
     [
       right 90
       forward 1
       set pcolor red
       set distparked abs(xcor)
       set disttraveled (xcor + startposition3)                   ;cruise distance
       set w3 lput (abs(distparked)) w3
       set t3 lput (disttraveled) t3
       set parked true
       set num num + 1
       set walk walk + (abs(distparked))
       set avgwalk (walk / num)
      ]
   ]

   ask turtles with [ (color = cyan - 2) and (ycor = 0)]
   [
     set color cyan
   ]  
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
   ask turtles with [color = yellow] 
   [                               
     forward 1             
   ]
    
    
   ask turtles with [ycor = -1]                                       ;;Departure code-- Cars will depart when their parktimer is 0. Parktimer is set randomly (exponentially) upon creation.  
   [
     ifelse (parktimer <= 0 and (not any? turtles-on patch-at 0 1 ))
     [
       depart
     ]
     [
       set parktimer (parktimer - 1)
     ]
   ]
        
   ask turtles with [ (xcor = max-pxcor) and (color = yellow)] 
   [
     die
   ]   
tick
end 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to depart
  set pcolor blue
         set ycor 0
          set heading 90
          set color yellow
end 

There is only one version of this model, created about 6 years ago by zhibin chen.

Attached files

File Type Description Last updated
Status-quo parking.png preview Preview for 'Status-quo parking' about 6 years ago, by zhibin chen Download

This model does not have any ancestors.

This model does not have any descendants.