是否可以使用 SUMO TraCI 获得边缘的密度?

Is it possible to use SUMO TraCI get the density of the edge?

为了监控LOS(Level of Service) of the edge, I need to know the density of the edge/road. I know the SUMO Edge-based Traffic Measure Output contains the attribute density. But I need to get it during the simulation. So, is it possible to use SUMO TraCI得到边缘的密度?否则,输出中的密度是如何计算的?

Ventu 的评论基本上是这样说的:密度是每公里的车辆数量。所以在 Python 你可以使用

num = traci.edge.getLastStepVehicleNumber(edgeID)
density = num / traci.lane.getLength(edgeID + "_0") / 1000.

最后一行有点 hack,因为它只是从边 id 中导出第一条车道的 id,并假设一条边的所有车道都具有相同的长度,但目前这对于 sumo 中的所有网络都是如此。