Results

In order to create a traffic jam we create a number of cars on the road and allow the simulation to advance for a given number of steps, before slowing one of the cars near the front of the grid for several steps and the allowing it to resume normal behaviour.

This is implemented by:

traffic_jam.peturb_traffic(starting_positions, n_timesteps_before, n_timesteps_slowed, n_timesteps_after, slow_car_num=3)[source]

Allow the simulation to run for a given number of steps before suddenly slowing one car and resuming the simulation.

Parameters:
  • starting_positions – List of starting_position to pass to road.add_multiple_cars
  • n_timesteps_before – How many steps to run before the car is slowed
  • n_timesteps_slowed – How many steps the car goes at a reduced speed
  • n_timesteps_after – How many steps to record after the car has recovered
  • slow_car_num – the index of the car to slow, starting at the front of the road
Returns:

An array containing the positions of all the cars with time.

Once this has produces a history_postion_array this is then passed on to the plotting code for visualisation

Benchmark run

In order to test the plotting, and show that all parts run together we can show cars simply drive after with no disturbance. This shows that a tightly grouped set of cars will spread out into a diffuse group

traffic_jam.simple_run(n_timesteps)[source]

Run the simulation for a given number of timesteps.

Parameters:n_timesteps – number of steps to take in the simulation
Returns:An array containing the positions of all the cars with time.
Return type:history_position_array

Changing the starting distance

We run the simulation, changing the distance between the cars in each run, this is done by using the following function

traffic_jam.start_space_sweep(minimum_space, maximum_space, interval)[source]

Run the simulation for several different starting positions.

Parameters:
  • minimum_space – The smallest starting distance between cars
  • maximum_space – The largest starting distance between the cars
  • interval – The size of the steps to take between these two extremes

This allows us to see two distinct behaviours, when the car_spacing is above a critical distance the cars recover from the jam with only a small decrease in velocity.

[[embed figure]]

However, below this distance, when the first car slows it leads to a much larger delays in the cars behind. Some cars even stop fully, as shown below,