-
Notifications
You must be signed in to change notification settings - Fork 179
faq 247922732
by Alain Tcheukam on 2018-03-26 13:09:36
How to compute the total vehicle Kilometer of Travel after a simulation in Matsim?
I need to:
Compute for each agent: the total length (km) of the Origin-Destination route really taken by the agent/persond ID after the simulation.
Sum up the travelled distance for all agents/person ID.
Do I need to use the “.experienced_plans.xml” file produced at the end of the simulation in the MATSim output file?
by Marcel Rieser on 2018-03-26 21:24:36
You could use either the experienced_plans.xml or the output_events.xml. I personally would go with the output_events.xml and write an events-handler. Basically, for each LinkEnterEvent, you could look up the length of the link in the network, and collect it for each (driving) agent. Something like the following (didn't try it out, wrote it how I remember the API):
Map<Id<Vehicle>, Double> vkt = new HashMap<>();
public void handleEvent(LinkEnterEvent event) {
double length = this.network.getLinks().get(event.getLinkId()).getLength();
Double value = this.vkt.get(event.getVehicleId());
if (value == null) {
value = 0.0;
}
this.vkt.put(event.getVehicleId(), value + length);
}
by Johan W. Joubert on 2018-03-27 18:56:25
I like Marcel's answer. I followed the other approach - using the plans - a few years ago, and the code is still available here (for the time being) in the southAfrica
playground, but we're cleaning it out bit by bit. Maybe you can look at it as an example... I don't vouch for my code efficiency ;-)
by Alain Tcheukam on 2018-03-27 19:36:33
Dear Marcel,
Dear Johan,
thank you very much for your reply and help.
Alain
You are viewing an archive of the previous MATSim Q&A site. The real site is now at https://matsim.org/faq