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
.
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.
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:
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("Capture.PNG", width=500, height=500)
# 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()
df = df[(df["lane"]==7) & (df["lane_index"]==2)]
df_spat = pd.read_excel('SPAT_.xlsx')
df_spat.head()
# Note that the location corresponts to the location of the stop bar
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,)
Image("Vissim_outputs_zoom.png", width=1500, height=1500)
speed_data = df[df.position>245.].speed
print(speed_data)
ax = speed_data.plot.hist(bins=12, alpha=0.5)
VISSIM adjust CAVs dynamics to ensure arrival on green. However,