Realistic single-lane traffic flow

Realistic single-lane traffic flow preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Me Ian Heath (Author)

Tags

car following 

Tagged by Ian Heath over 9 years ago

maximum flow 

Tagged by Ian Heath over 9 years ago

speed limit 

Tagged by Ian Heath over 9 years ago

traffic 

Tagged by Ian Heath over 9 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.2 • Viewed 1021 times • Downloaded 111 times • Run 0 times
Download the 'Realistic single-lane traffic flow' 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 models the flow of traffic on a single-carriageway. It is different from other models in that the "car following" rules are simple, realistic and could mirror actual driving practices. Acceleration/deceleration is smooth and within comfortably achievable bounds for the average car. Each car adjusts its headway-secs (i.e. the number of seconds it is behind the car-ahead when passing a fixed point) towards its desired tailgate-secs (i.e. the target headway-secs that that an individual driver prefers). A realistically achievable hard braking is applied whenever there is a chance of shunting the car-ahead.

The road is effectively a continuous loop, as the world wraps. The model demonstrates how wave-like traffic congestion forms, even without any accidents or road works.

HOW TO USE IT

Set traffic-density to the desired %occupancy of the total road space.

Click setup to create randomly distributed stationary cars with heterogoneous tailgate-secs (between 1 and 2 seconds, in line with the general actual driving practices in European countries, despite the recommended "two second rule").

Click go-forever to drive the cars.

Experiment with safe-headway (the minimum seconds it is safe to follow at) and brake-factor (the factor by which the normal deceleration limit is multiplied by in order to brake hard when avoiding the chance of shunting the car ahead) to see how the "Red Car speed" plot varies, and what are the threshold values for avoiding shunts (which raise an error mssage and stop the run). The default values of these parameters are the minimum ones that have been experimentally found to avoid shunting in all circumstances.

The car following rules have been kept simple enough to be intuitively approximate-able by humans. Cars accelerate/decelerate by a factor based on headway-secs - tailgate-secs. Thus a car accelerates when headway-secs > tailgate-secs and decelerates when headway-secs < tailgate-secs. This factor is bounded by the range -1 to +1 and multiplied by max-accel to give the acceleration at each tick, where max-accel is a realistic limit for normal acceleration and deceleration. The factor is reset to - brake-factor when there is a possibility that the car could-shunt the car-ahead. This causes the car to brake hard to avoid the possible shunt. The could-shunt test is basically a simple comparison of distance-to-car-ahead verses closing-speed * safe-headway, something which a human driver could feasibly approximate in his head.

Optimum speed limits for the fastest constant flow of traffic at each traffic-density, can be determined as follows:

Click optimise-speed-limit to incrementally reduce the speed-limit from its current value until all cars can consistently reach this speed-limit after an initial settling down period. Thereafter all cars continue to travel at this constant speed and optimum throughput is achieved for the current density (the values of which are logged to the output area).

Click optimise-speed-limits to run optimise-speed-limit as the traffic-density is incrementally increased from its current value. So, as this proceeds the traffic-density increases and the speed-limit decreases. It terminates when the minimum-speed-limit is reached.

THINGS TO NOTICE

Cars that are clustered together move slowly, causing cars behind them to slow down also. As this effect ripples back a traffic jam forms. Even though all of the cars are moving forward, the traffic jams often move backwards. This behavior is common in wave phenomena: the behavior of the group is often very different from the behavior of the individuals that make up the group. An example random car is painted red and highlighted for easy watching. Its speed plot eventually settles down either to periodic oscillations, or to the speed limit.

EXTENDING THE MODEL

Try other realistic car following rules in follow-car.

RELATED MODELS

This is an improvement of "Traffic Basic" which is patch-based, only looks one-patch ahead and decelerates impossibly jerkily in just one step to slower than the car-ahead. In contrast this model looks as far ahead as the next car and accelerates / decelerates smoothly and realistically.

COPYRIGHT AND LICENSE

Creative Commons Licence
by Ian J Heath is licensed under a Creative Commons Attribution 4.0 International License http://creativecommons.org/licenses/by/4.0/

Comments and Questions

Default-person

a a

question (Question)

please,can i get any reference or paper about this model to understand the problem

Posted over 8 years ago

In answer to a a

This is original work and there are no other papers or references beyond the references made in the "Info" of this model. I would be interested if you have any comments on this model though once you have played (sorry, experimented) with it.

Posted over 8 years ago

Click to Run Model

globals  [ticks-per-sec patches-per-tick-per-kph patches-per-km world-width-km
  number-of-cars min-speed-limit min-distance red-car max-accel speed-limit-ok-count]
breed    [cars car]
cars-own [speed tailgate-secs]

to setup
  clear-all
  set ticks-per-sec 30
  set min-speed-limit 30
  set min-distance .001
  set max-accel  .001 * 3600 / ticks-per-sec                            ;;  accel per tick ~  1m per sec per sec

  let patch-length 5                                                    ;; just big enough for a 5m car
  set patches-per-km 1000 / patch-length
  set world-width-km  world-width * patch-length / 1000
  let km-per-tick-per-kph  1 / 3600 / ticks-per-sec
  set patches-per-tick-per-kph  km-per-tick-per-kph * 1000 / patch-length
  ask patches with [abs pycor < 2] [ set pcolor white ]                 ;; setup-road
  setup-cars
end 

to setup-cars
  clear-turtles
  clear-all-plots
  set-default-shape cars "car"
  set number-of-cars round (world-width * traffic-density / 100)
  foreach sort n-of number-of-cars patches with [pycor = 0] [ ?1 -> ask ?1 [sprout-cars 1 [
    set color blue
    set heading 90
    set speed 0
    set tailgate-secs 1 + random-float 1                                ;; 1-2 secs behind the car ahead
  ]] ]
  set red-car one-of cars
  ask red-car [ set color red ]
  watch red-car
  reset-ticks
end 

to go
  foreach n-values number-of-cars [ ?1 -> number-of-cars - 1 - ?1 ] [ ?1 -> ask car ?1 [follow-car ] ]   ;;  Reduce chance of shunting by always moving the car ahead first (for all except the last car)
  tick
end 

to follow-car       ;; car following:  adjust speed by targeting own tailgate-secs
  let car-ahead car ((who + 1) mod number-of-cars)
  let distance-to-car-ahead ((([xcor] of car-ahead - xcor) mod world-width) - 1) / patches-per-km  ;; bumper-to-bumper distance in km
  if speed > 0 and distance-to-car-ahead < 0 [error word " Shunt !!!   distance-to-car-ahead = " distance-to-car-ahead]  ;; in case safe-headway and brake-factor have not been set to avoid shunts

  let headway-secs max (list 0 (distance-to-car-ahead - min-distance)) / (speed + .000000001) * 3600   ;; Secs to travel headway (- min-distance) at the current speed (+ .000000001 to avoid ZeroDivide)
  let accel-factor max list -1 min list 1 (headway-secs - tailgate-secs)        ;; +ve if headway-secs > tailgate-secs, else -ve (capped at -1 to +1 to avoid excessive acceleration)

  ;; reset accel-factor for hard braking, if closer than safe-headway
  let closing-speed speed - [speed] of car-ahead
  let could-shunt (distance-to-car-ahead - min-distance) < (safe-headway / 3600 * closing-speed)
  if could-shunt [set accel-factor 0 - brake-factor]                            ;; hard brake if could-shunt

  set speed max list 0 min list speed-limit (speed + accel-factor * max-accel ) ;; observe the speeed-limit, and no reversing
  fd speed * patches-per-tick-per-kph
end 

to optimise-speed-limits
  setup
  set traffic-density traffic-density - 1        ;; compensate for incrementing before the first optimise-speed-limit
  while [speed-limit >= min-speed-limit] [
    set traffic-density traffic-density + 1      ;; repeat for traffic-density = 2,3,...
    optimise-speed-limit
  ]
end 

to optimise-speed-limit
  set speed-limit-ok-count 0
  while [speed-limit-ok-count < 300] [
    if speed-limit < min-speed-limit [
      output-print word "Finished optimising speed limits down to min-speed-limit of " min-speed-limit
      stop
    ]
    decrement-speed-limit
  ]
  let cars-per-hr number-of-cars * speed-limit / world-width-km
  output-print (word "For traffic-density " substring (word traffic-density " ") 0 2  "  speed-limit = "  substring (word speed-limit " ") 0 3  "   cars-per-hr = " cars-per-hr)
end 

to decrement-speed-limit
  setup-cars

  let ticks-per-traverse-at-speed-limit  3600 * ticks-per-sec * world-width-km / speed-limit

  repeat 3 * ticks-per-traverse-at-speed-limit [
    go
    if all? cars [speed = speed-limit] [
      set speed-limit-ok-count speed-limit-ok-count + 1
      stop
    ]
  ]

  set speed-limit speed-limit - 1
end 

There are 18 versions of this model.

Uploaded by When Description Download
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago playing with CC code at the end on Info Download this version
Ian Heath about 6 years ago Recover Info tab Download this version
Ian Heath about 6 years ago Reverted to older version Download this version
Ian Heath about 6 years ago Reverted to older version Download this version
Ian Heath about 6 years ago Reverted to older version Download this version
Ian Heath about 6 years ago Changed the CC logo Download this version
Ian Heath over 9 years ago Modify "go" to reduce chance of shunting. Download this version
Ian Heath over 9 years ago Clarify Info further Download this version
Ian Heath over 9 years ago Made Info clearer. Download this version
Ian Heath over 9 years ago polishing the Info tab Download this version
Ian Heath over 9 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Realistic single-lane traffic flow.png preview preview image over 9 years ago, by Ian Heath Download

This model does not have any ancestors.

This model does not have any descendants.