BML Model with rerouting

BML Model with rerouting preview image

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

1 collaborator

Default-person Jorge Laval (Author)

Tags

pedestrians 

Tagged by Jorge Laval about 1 year ago

traffic flow/ 

Tagged by Jorge Laval about 1 year ago

urban congestion 

Tagged by Jorge Laval about 1 year ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 645 times • Downloaded 42 times • Run 0 times
Download the 'BML Model with rerouting' 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?

The Biham–Middleton–Levine traffic model is a self-organizing cellular automaton traffic flow model. It consists of a number of cars represented by points on a lattice with a random starting position, where each car may be one of two types: those that only move downwards (shown as blue in this article), and those that only move towards the right (shown as red in this article). The two types of cars take turns to move. During each turn, all the cars for the corresponding type advance by one step if they are not blocked by another car. It may be considered the two-dimensional analogue of the simpler Rule 184 model. It is possibly the simplest system exhibiting phase transitions and self-organization.[1]

I have added the probability of rerouting, which gives a whole new set of features to be explored. If an agent cannot advance, it will change directions with this probability.

CREDITS AND REFERENCES

[1]: O. Biham, A. A. Middleton, and D. Levine, Phys. Rev. A 46, R6124 s1992d. https://journals.aps.org/pra/abstract/10.1103/PhysRevA.46.R6124

HOW IT WORKS

Wikipedia: https://en.wikipedia.org/wiki/Biham%E2%80%93Middleton%E2%80%93Levine_traffic_model

HOW TO USE IT

Set the density and the probability of rerouting. Click setup and go!

THINGS TO NOTICE

In the original model (rerouting probability = 0) there is a critical point around density = 0.4 for this grid size (100x100), displaying interesting emerging behavior with phase coexistence. For larger densities, the model invariably tends to a completed gridlock, which is unrealistic.

THINGS TO TRY

  • Try different values of the rerouting probability to see how gridlock is "dissolved"

  • Try rerouting probability = 1 and density > 0.4. Amazing!

EXTENDING THE MODEL

  • adding parks/obstructions/incidents to observe the decrease in capacity
  • different traffic light settings, currently the model simulates even split between directions and fixed timing

NETLOGO FEATURES

An important difference with ALL Netlogo models related to traffic that I've seen out there, is that the the position updates need to be in parallel, and not random-sequential. This is why we need to do it in two stages, as commented in the code.

RELATED MODELS

BML model with sequential updates: https://sites.google.com/view/bmlv2/home

Comments and Questions

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

Click to Run Model

globals [
  average-speed   ; average speed of all cars
  actual-density
  prop-orange
]

turtles-own [
  move-flag       ; auxiliary variable to track if a car should move
  speed           ; speed of the car
]

to setup
  clear-all
  set-default-shape turtles "default"  ; use the default arrow shape
  ;ask patches [  set pcolor gray]

  ; Set up the plot
  ;set-current-plot "Average Speed"
  ;set-plot-x-range 0 100  ; Adjust x-axis range as needed
  ;set-plot-y-range 0 1   ; Adjust y-axis range as needed

  ; Place cars randomly on the grid and assign a speed
  ask patches [
    if random-float 1 < density [ ; approximately 30% of the cells will have cars
      sprout 1 [
        ifelse random-float 1 < 0.5 [
          set heading 90   ; East (right)
          set color cyan
        ] [
          set heading 180  ; South (down)
          set color orange
        ]
        set speed 1  ; Speed can be adjusted if needed
        set move-flag false
      ]
    ]
  ]

  ; Initialize global variables
  set average-speed 1
  set actual-density count turtles / count patches
  set prop-orange 100 * count turtles with [ color = orange ] / count turtles

  reset-ticks
end 

to go
  ;; 180 Move Stage 1: Identify which cars should move
  ask turtles with [ heading = 180] [
    let next-patch patch-ahead 1  ; Get the patch directly ahead based on heading
    ifelse not any? turtles-on next-patch [  set move-flag true    ] [
      set move-flag false
      set speed 0  ; Cars that cannot move have their speed set to 0
    ]
  ]
  ;; Move Stage 2: Perform the moves based on `move-flag`
  ask turtles with [move-flag and heading = 180] [
    set speed 1  ; Cars that can move have their speed set to 1
    move-to patch-ahead 1
  ]
 ;; Re-route
  if prob_reroute > 0 [
    ask turtles with [not move-flag and heading = 180] [
      if random-float 1 < prob_reroute [
        set heading 90
        set color cyan
      ]
    ]
  ]

  ;; 90 Move Stage 1: Identify which cars should move
  ask turtles with [ heading = 90] [
    let next-patch patch-ahead 1  ; Get the patch directly ahead based on heading
    ifelse not any? turtles-on next-patch [  set move-flag true    ] [
      set move-flag false
      set speed 0  ; Cars that cannot move have their speed set to 0
    ]
  ]
  ;; Move Stage 2: Perform the moves based on `move-flag`
  ask turtles with [move-flag  and heading = 90] [
    set speed 1  ; Cars that can move have their speed set to 1
    move-to patch-ahead 1
  ]
 ;; Re-route
  if prob_reroute > 0 [
   ask turtles with [not move-flag and heading = 90] [
    if random-float 1 < prob_reroute [
      set heading 180
      set color orange
    ]
  ]]

  ; Calculate the average speed
  set average-speed mean [speed] of turtles
  ;if average-speed = 0 [ stop ]
  set prop-orange 100 * count turtles with [ color = orange ] / count turtles

  ; Clear the auxiliary variable for the next iteration
  ;ask turtles [ set move-flag false ]

  tick
end 

; Public Domain:
; To the extent possible under law, Jorge Laval has waived all
; copyright and related or neighboring rights to this code.

There is only one version of this model, created about 1 year ago by Jorge Laval.

Attached files

File Type Description Last updated
BML Model with rerouting.png preview Preview for 'BML Model with rerouting' about 1 year ago, by Jorge Laval Download

This model does not have any ancestors.

This model does not have any descendants.