Evaluating the CAVs simulation considerations in VISSIM 2022

For this evaluation we will use the PTV Vissim version 2022. The example can be found in the tab Help/Examples/Training Material. Then in the folder Autonomous vehicles (AV)/Speed at Signals.

Objective:

We want to visualize the time space diagrams to evaluate how the CAVs behavior is modeled in VISSIM with the existing script Speed at Signals.py. This we help us to draw some conclusions.

Data Extraction:

We simulated the Speed at Signals.ipnx and from the direct output (tab Evaluation/Configuration/Direct Output/Vehicle record) we extracted the following data: From vehicle record:

  • vehID
  • Position
  • Speed
  • Acceleration
  • Lane Everything from signal changes (no more options) The direct output will create two files with extensions .fzp, and .lsa which can be open using VSCode or Notepad. Then two .xlxs were created:
  1. SPAT_.xlsx: signal plan filetered for the lane of interest (lane 7, index 2)
  2. speed_at_signals_test.xlsx: vehicle record of the simulation ## Let's see how Vissim is doing ### Required libraries
In [1]:
import pandas as pd
import os
import matplotlib.pyplot as plt
from matplotlib import colors
from IPython.display import Image
plt.style.use('ggplot')

Image for reference

In [2]:
Image("Capture.PNG", width=500, height=500)
Out[2]:

Data

In [23]:
# import data from excel and transform it to a df
excel_file_name = "speed_at_signals_test"
df = pd.read_excel(excel_file_name + '.xlsx') 
# evaluate data
df.head()
Out[23]:
time vehID position des_speed speed acc lane lane_index
0 6.7 1 0.51 50.0 50.48 -0.14 7 2
1 6.8 1 1.91 50.0 50.43 -0.14 7 2
2 6.9 1 3.31 50.0 50.38 -0.14 7 2
3 7.0 1 4.71 50.0 50.33 -0.14 7 2
4 7.1 1 6.11 48.0 50.28 -0.14 7 2
In [24]:
df = df[(df["lane"]==7) & (df["lane_index"]==2)]
In [25]:
df_spat = pd.read_excel('SPAT_.xlsx') 
df_spat.head()
# Note that the location corresponts to the location of the stop bar
Out[25]:
time location split
0 0 245.37 Red
1 1 245.37 Red
2 2 245.37 Red
3 3 245.37 Red
4 4 245.37 Red

Plot

In [26]:
plot_range = [0, 250]
# plot_range = [50, 150]
width = 15
groups = df.groupby('vehID')
fig, ax = plt.subplots(3, 1)
fig.set_figwidth(width) 
fig.set_figheight(width)
fig.suptitle('CAVs dynamics optimized to arrive on the green split', fontsize=16, y=0.9)
ax[0].set_xlim(plot_range)
ax[0].set_ylabel('Position $(m)$')
ax[1].set_xlim(plot_range)
ax[1].set_ylabel('Speed $(m/s)$')
ax[2].set_xlim(plot_range)
ax[2].set_ylabel('Acceleration $(m/s^2)$')
ax[2].set_xlabel('time $(s)$')

ax[0].scatter(df_spat.time, df_spat.location, c=df_spat.split, marker="s", s=56, 
              cmap=colors.ListedColormap(df_spat.split))



for vehID,group in groups:
    
    ax[0].plot(group.time,group.position, label=vehID)
    ax[1].plot(group.time,group.speed, label=vehID)
    ax[2].plot(group.time,group.acc, label=vehID)
fig.savefig(excel_file_name, dpi=300,)
In [30]:
Image("Vissim_outputs_zoom.png", width=1500, height=1500)
Out[30]:
In [28]:
speed_data = df[df.position>245.].speed
print(speed_data)
ax = speed_data.plot.hist(bins=12, alpha=0.5)
1147      8.21
1150      9.08
1196     23.51
3811     15.32
3931     31.51
5551      7.35
5556      8.14
5625     20.95
5710     28.34
5727     30.97
7397     33.83
7410     34.69
7610     41.40
10316    30.47
10348    25.27
Name: speed, dtype: float64

Notes:

VISSIM adjust CAVs dynamics to ensure arrival on green. However,

  • the existing capabilities of VISSIM do not allow to adjust the SPaT,
  • the arrival speed at the stop bar is not inforced and varies between [7.35 - 40.1]km/h for a desired speed of 50km/h
    • by allowing lower speeds/speed variation we have lost time, in turn we wont be able to fully use the green split
In [ ]: