0
votes

I have a network that has to be divided into a grid of square cells (200 X 200 m). each cell includes sub-segments of the edges.

I have generated the simulation data output and used sumolib to extract edge-based output. I have to calculate the average traffic volume in each cell (not edge) measured in (vehicles/second).

this is part of the script I have written:

  1. extract edge-based density and speed values:

     for interval in sumolib.output.parse('cairo.edgeDataOutput.xml','interval'):
         for edge in interval.edge:
             edgeDataOutput[edge.id]= (edge.density,edge.speed)
    
  2. after saving density and speed into edgeDataOutput, I have to aggregate into cells and calculate avg.traffic volume in each cell:

    for cellID in ids:
        density=0 
        speed=0
        n=0   #avg.traffic vol
        for edgeID in cell_edgeMap[cellID].keys():
            if edgeID in edgeDataOutput.keys():
                density+= float(edgeDataOutput[edgeID][1])
                speed+= float(edgeDataOutput[edgeID][2])
                n += (float(edgeDataOutput[edgeID][1])/1000) * float(edgeDataOutput[edgeID][2])  #traffic vol = (density/1000)*speed 
    
        densities.append(int((density / len(cell_edgeMap[cellID].keys()))+0.5))
        speeds.append(int((speed / len(cell_edgeMap[cellID].keys()))+0.5))
        numOfVehicles.append(int(n/len(cell_edgeMap[cellID].keys())))
    

as you can see from the code, I sum up the density, speed values of each edge that is in the cell then divide by the number of edges inside the cell to get the mean value.

density at cell(veh/Km) = sum(density at each edge inside cell)/num of edges inside cell.

speed at cell(m/s) = sum(speed at each edge inside cell)/num of edges in cell.

and I am using the following formula to calculate the traffic volume at each cell:

avg.traffic volume at cell(veh/s) = sum(avg.traffic volume at each edge inside cell)/num of edges inside cell.

avg.traffic volume at edge(veh/s) = density at edge(veh/Km) * speed at edge(m/s) / 1000.

I just want to make sure that I am using the write formula.

1

1 Answers

0
votes

It is not easy to answer whether you do the right thing because averaging over both time and space is always hard. Furthermore it is not clear what you are trying to measure. The traffic volume usually denotes the total (or average) number of vehicles and is measured without unit (so only number of vehicles). The traffic flow is measured in vehicles per time unit but is usually applied only to a cross section not to an area. If you want the average number of cars in the cell it should suffice to divide the sum of the number of sampleSeconds by the length of the interval. The second value needs a more in depth discussion but I would probably at least multiply it with the edge length when summing up.