Parking

No preview image

1 collaborator

Default-person david price (Author)

Tags

(This model has yet to be categorized with any tags)
Model group EECS 372-Spring 2011 | Visible to everyone | Changeable by group members (EECS 372-Spring 2011)
Model was written in NetLogo 4.1.3 • Viewed 381 times • Downloaded 34 times • Run 6 times
Download the '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.)


WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

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

Click to Run Model

;; parking model building

globals [
  parking-spaces
  filled
  destin-x2
  time
]
breed [cars car]
breed [stores store]
cars-own [
  home-park-space
  destin
  destin-x
  time-in-store
  parked
  parking-time
]
stores-own [
  popularity
  time-in
  total-dist
  avg-dist
  count-parked
  count-missed
]

to setup
clear-all
setup-cars
setup-parking
setup-stores
end 

to setup-cars
  set-default-shape cars "car"
end  

to setup-parking
  set parking-spaces patches with [pycor = 0 and pxcor > -25] 
  ask parking-spaces [set pcolor yellow]
end 

to setup-stores
  ask patches with [pycor > 0] [set pcolor white]
  create-stores 1 [
    set color red
    setxy (store-1-location - 25) 1
    set time-in time-in-1
  ]
  if addstore2?[
    create-stores 1 [
      set color blue
      setxy (store-2-location - 25) 1
      set time-in time-in-2
    ]
  ]
  
  if addstore3?[
    create-stores 1 [
      set color green
      setxy (store-3-location - 25) 1
      set time-in time-in-3
    ]
  ]
  
  if addstore4?[
    create-stores 1 [
    set color orange
    setxy (store-4-location - 25) 1
    set time-in time-in-4
    ]
  ]
  
  if addstore5?[
    create-stores 1 [
      set color violet
      setxy (store-5-location - 25)  1
      set time-in time-in-5
    ]
  ]
    set-default-shape stores "house"
end  

to go
  decide-to-park
  move-cars
  parked-time
  new-car-parking
  tick
end 

to new-car-parking
  if random 100 < 50 [
    create-cars 1 [
       setxy -25 -1 
       facexy -24 -1 
       set destin one-of stores
       create-link-with destin
       ask destin [set destin-x2 xcor]
       set destin-x destin-x2
       ask destin [set time time-in]
       set time-in-store time
       set parking-time 1
       set parked 0
    ]
  ]
end 

to move-cars
  ask cars [
    if ycor = -1 [
      forward 1
    ]
  ]
end  

to decide-to-park
  ;; need to add parking parameters before the cars reach the x-coordinate of their destination
  ;; need to add the result if people are unable to park
  ;; need to add measures so people will not find a spot occasionally
  ask cars [ 
    if ycor = -1 [
      if patch-at 0 1 != nobody [
        ask patch-at 0 1 [
          ifelse count turtles-here = 0 [
            set filled 0
          ]
          [ set filled 1
          ]
        ]
      ]
      if filled = 0 and xcor >= destin-x and patch-at 0 1 != nobody [
        move-to patch-at 0 1
        set parking-time distance destin + time-in-store
        ask destin [
          set count-parked count-parked + 1
          set total-dist total-dist + distance myself
          set avg-dist total-dist / count-parked
          ]
      ]
  ]
  ]
end 

to parked-time
  ask cars [
    if ycor = 0 [
    set parked parked + 1
    if parked >= parking-time [die]
    ]
  ]
end 

  

          

There is only one version of this model, created almost 13 years ago by david price.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.