Traffic and Alcohol

Traffic and Alcohol preview image

1 collaborator

Tags

alcohol 

Tagged by Diego Díaz Córdova over 1 year ago

traffic 

Tagged by Diego Díaz Córdova over 1 year ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 453 times • Downloaded 22 times • Run 0 times
Download the 'Traffic and Alcohol' 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 model describes the behavior of drivers under the influence of alcohol. Each car follows some very simple rules: if the driver is not intoxicated and observes a car ahead, then they brake; if they do not observe a car ahead, then they accelerate. If the driver is intoxicated and observes a car ahead, then they decelerate and reach a speed lower than that of the car ahead; if they do not observe a car ahead, then they accelerate twice as much as if they were not intoxicated. If the driver is not intoxicated, they do not exceed the maximum and minimum speeds allowed; if they are intoxicated, they may exceed them. This model aims to simulate the risk of accidents when driving under the influence of alcohol.

HOW TO USE IT

Click on the SETUP button to set up the cars.

Set the NUMBER-OF-CARS slider to change the number of cars on the road.

Set the TORTUGAS-ALCOHOLIZADAS to change the numbers of intozicated drivers

Click on GO to start the cars moving. Note that they wrap around the world as they move, so the road is like a continuous loop. The intoxicates drivers are painted in yellow

The ACCELERATION slider controls the rate at which cars accelerate (speed up) when there are no cars ahead.

When a driver is not intoxicated and sees another car right in front, it stops; if a driver is intoxivated it matches that car's speed and then slows down a bit more. How much slower it goes than the car in front of it is controlled by the DECELERATION slider.

THINGS TO NOTICE

Cars starts all at the same slow velocity and they accelerate when there is no car ahead. All the cars are distrbuted randomly in the x axis and all of them go in the right direction (heading 90). In the SETUP button all the cars are separated in order to don't end up with any two cars on the same patch. When there is no intoxicated driver there is no accident at all

The first plot shows two values as the model runs:

  • the mean speed of not intoxicated driver (this doesn't exceed the speed limit!)

  • the mean speed of intoxicated driver (this does exceed the speed limit!)

Even though both ACCELERATION and DECELERATION are very small, the intoxicated drivers can achieve high speeds as these values are added or subtracted at each tick

THINGS TO TRY

When deceleration is the highest possible (0.099) there is almost no accident at all.Look for patterns in when these accidents start to happen. How many intoxicated cars are needed to start with accidents at a fixed deceleration ratio? How accidents are affected by the relation between intoxicated and not intoxicated drivers? How the accidents are affected by the velocity achieved by cars?

EXTENDING THE MODEL

Try changing the start velocity (in code) to a random number, does it affect the amount of accidents?

Try to change the non intoxicated driver's behaviour, setting a very low probability for an accident i.e, non stop when a car is ahead (accidents happens even when there is no intoxicated driver)

Try to change the intoxicated driver's behaviour with some degree of intoxication (some drivers are more intoxicated than others), does it affect the amount of accidents?

RELATED MODELS

  • "Traffic Basic Utility": a version of "Traffic Basic" including a utility function for the cars.

HOW TO CITE

This model was made as a part of a lesson about MBA with students at Universidad de Buenos Aires.

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

COPYRIGHT AND LICENSE

Díaz Córdova et alumni, UBA, 2024

Copyright 1997 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

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

Click to Run Model

globals [
  speed-limit
  speed-min
  choques ; acumula cantidad de choques
]
;; 0.026 descaceleration
;; 0.0045 aceleration
turtles-own [
  speed
  alcohol? ;variable booleana que indica si la tortuga consumió alcohol o no
]

to setup
  clear-all
  clear-output
  set speed-limit 1
  set speed-min 0
  ask patches [ setup-road ]
  setup-cars
  reset-ticks
end 

to setup-road ;; patch procedure
  if pycor < 2 and pycor > -2 [ set pcolor white ]
end 

to setup-cars
  if number-of-cars > world-width [
    user-message (word
      "There are too many cars for the amount of road. "
      "Please decrease the NUMBER-OF-CARS slider to below "
      (world-width + 1) " and press the SETUP button again. "
      "The setup has stopped.")
    stop
  ]

  if tortugasalcoholizadas > number-of-cars [
    user-message (word
      "Hay más autos alcoholizados que autos en el tablero. Baje la cantidad de autos alcoholizados a menor o igual que la cantidad de autos totales"
      )
    stop
  ]


  set-default-shape turtles "car"
  create-turtles number-of-cars [
    set color blue
    set xcor random-xcor
    set heading 90
    ;; set initial speed to be in range 0.1 to 1.0
    set speed 0.01 ;;+ random-float 0.9
    separate-cars
    set label-color red
  ]

  let posiblesalcoholizadas n-of tortugasalcoholizadas turtles
  if count posiblesalcoholizadas > 0
  [
  ask turtles [
     if member? self posiblesalcoholizadas
       [ set alcohol? true
         set color yellow
       ]
    ]
  ]
end 

; this procedure is needed so when we click "Setup" we
; don't end up with any two cars on the same patch

to separate-cars ;; turtle procedure
  if any? other turtles-here [
    fd 1
    separate-cars
  ]
end 

to go
  ;; if there is a car right ahead of you, match its speed then slow down
  ask turtles
  [
    let car-ahead one-of turtles-on patch-ahead 1
    ifelse car-ahead != nobody
      [
        ifelse alcohol? = 0
          [set speed 0]
          [slow-down-car car-ahead]
      ]
      [ speed-up-car ] ;; otherwise, speed up
    ;; don't slow down below speed minimum or speed up beyond speed limit
    ;;si hay un auto delante y no tomó alcohol entonces frena
    ;; que pasa si hay un auto alcoholizado
    ;; si el auto está alcoholizado entonces no respeta ni la velocidad máxima ni la mínima
   if alcohol? = 0
    [
      if speed < speed-min [ set speed speed-min ]
      if speed > speed-limit [ set speed speed-limit ]
    ]
    if speed < 0 [set speed 0]

    ;;choco
    if (count turtles-here > 1)
      [set choques (choques + 1)
       set speed 0
       back 1
      ]

    fd speed

  ]

  tick
end 

to slow-down-car [ car-ahead ] ;; turtle procedure
  ;; slow down so you are driving more slowly than the car ahead of you
  ;; if it is drunk it tries to drive so slowly asn the car ahead of him
  set speed [ speed ] of car-ahead - deceleration
end 

to speed-up-car ;; turtle procedure
  ;; if it is drunk then it speed up at much more acceleration
  ifelse alcohol? = true
  [set speed speed + (acceleration * 2)]
  [set speed speed + acceleration]
end 

; Modifed 2024 Diaz Cordova et alumni UBA
; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created over 1 year ago by Diego Díaz Córdova.

Attached files

File Type Description Last updated
Traffic and Alcohol.png preview Preview for 'Traffic and Alcohol' over 1 year ago, by Diego Díaz Córdova Download

This model does not have any ancestors.

This model does not have any descendants.