matsim-org / matsim-libs

Multi-Agent Transport Simulation
www.matsim.org
478 stars 441 forks source link

Bug report: Carsharing crashes when only some agents have a CS membership #1419

Closed ouassimm closed 3 years ago

ouassimm commented 3 years ago

Carsharing crashes when only a portion of the total population has a CS membership. The error is due to the 2nd condition in the if statement : https://github.com/matsim-org/matsim-libs/blob/825c67e807d73191775eca765dbcb7c7b294f918/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/replanning/CarsharingSubTourPermissableModesCalculator.java#L54

A simple fix can be:

if (Boolean.parseBoolean(scenario.getConfig().getModule("TwoWayCarsharing").getParams().get("useTwoWayCarsharing")) && this.memberships.getPerPersonMemberships().keySet().contains(personId)) { if (this.memberships.getPerPersonMemberships().get(personId).getMembershipsPerCSType().containsKey("twoway")) { l.add("twoway"); } }

balacmi commented 3 years ago

Thank you Ouassim for reporting this.