arup-group / elara

Command line utility for processing MATSim events output files.
MIT License
13 stars 4 forks source link

fix speed averaging #185

Closed Theodore-Chatziioannou closed 2 years ago

Theodore-Chatziioannou commented 2 years ago

Addresses issue #184 :

While analysing a Londinium test, I found that delays calculated with the vehicle log were not matching the delays calculated using the link speeds handler.

The reason is that the link speeds handler is not averaging the vehicle speeds correctly. The elara handler is calculating: speed = Σ(speed_i) / n , while the correct formula for averaging speeds is : speed = (total distance travelled) / (total time travelled) = (n*d) / (Σ(t_i)) = (n*d) / (Σ(d/speed_i)) = n / Σ(1 / speed_i) , where d = distance, t=travel time, i denotes a vehicle, and n = number of vehicles.

Theodore-Chatziioannou commented 2 years ago

agree that the speed handler code was difficult to follow, so I implemented a relatively more extensive refactoring. Hopefully now it is more clear.

andkay commented 2 years ago

Thanks, Theo! Really appreciate the additional clarity!