Open vsgo222 opened 3 years ago
The log contains additional information, especially these lines:
Caused by: java.lang.NullPointerException
at ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorData.calculateRouteStopTransfers(SwissRailRaptorData.java:256) ~[classes/:?]
at ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorData.create(SwissRailRaptorData.java:186) ~[classes/:?]
at ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorFactory.prepareData(SwissRailRaptorFactory.java:77) ~[classes/:?]
In SwissRailRaptorData.java
, lines 254-245 are the following:
for (Map.Entry<TransitStopFacility, List<TransitStopFacility>> e : stopToStopsTransfers.entrySet()) {
TransitStopFacility fromStop = e.getKey();
Coord fromCoord = fromStop.getCoord();
So it looks as if fromStop
is null, and the fromStop is coming from stopToStopTransfers
.
Does you schedule use "minimal transfer times"? If so, please make sure that all listed transit stop ids are actually valid. My current guess is, that there is a minimalTransferTime for a stop that does not exist in the schedule.
The log contains additional information, especially these lines:
Caused by: java.lang.NullPointerException at ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorData.calculateRouteStopTransfers(SwissRailRaptorData.java:256) ~[classes/:?] at ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorData.create(SwissRailRaptorData.java:186) ~[classes/:?] at ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorFactory.prepareData(SwissRailRaptorFactory.java:77) ~[classes/:?]
In
SwissRailRaptorData.java
, lines 254-245 are the following:for (Map.Entry<TransitStopFacility, List<TransitStopFacility>> e : stopToStopsTransfers.entrySet()) { TransitStopFacility fromStop = e.getKey(); Coord fromCoord = fromStop.getCoord();
So it looks as if
fromStop
is null, and the fromStop is coming fromstopToStopTransfers
.Does you schedule use "minimal transfer times"? If so, please make sure that all listed transit stop ids are actually valid. My current guess is, that there is a minimalTransferTime for a stop that does not exist in the schedule.
You are absolutely right. It did had some missing transitStops. I modified my code to handle it. However, it now creates altogether a different issue.
For e.g.
ERROR BasicPlanAgentImpl:107 The agent 13121011900_2015000687560_853696_1 has destination link 863210156_F, but arrived on link 863210156_F_busonly. Setting agent state to ABORT
Both link 863210156_F_busonly and link 863210156_F are exactly the same (first is a clone of a latter) and are overlaid one above other. the busonly link has only modes="bus,walk" in it while the original link has mode="bus,walk,car,tram". I tried different combination a) removing bus from the original link mode along "bus,walk" or b) removing "bus" from original link and only keeping "bus" in the busonly link. None worked.
What should be the best approach to handle this scenario? Changing agents plans file to search and replace these linkIds would be extremely cumbersome (we have ~1.8 million agents).
output_HighPTRdrshp_BusLane_v8.zip
13121011900_2015000687560_853696_1.zip
How do you generate your plans? Usually, if one only provides x/y coordinate values, MATSim will automatically assign the nearest link and calculate routes so that everything matches.
If you get this error message The agent xyz has destination link abc, but arrived on link def
then it usually means that the input (e.g. plans, network, schedule) don't match. So you either have to fix the input plans (yes, replacing is one way to do, but I wouldn't do it from hand but with a short Java code), or remove the route-information completely from the plans file (again, don't do it by hand for 1.8m agents) and let MATSim recalculate the necessary routes.
How do you generate your plans? Usually, if one only provides x/y coordinate values, MATSim will automatically assign the nearest link and calculate routes so that everything matches.
If you get this error message
The agent xyz has destination link abc, but arrived on link def
then it usually means that the input (e.g. plans, network, schedule) don't match. So you either have to fix the input plans (yes, replacing is one way to do, but I wouldn't do it from hand but with a short Java code), or remove the route-information completely from the plans file (again, don't do it by hand for 1.8m agents) and let MATSim recalculate the necessary routes.
Dr. Rieser, The data was received as a input to us from the citycast service. Do you have any code which I can refer so that I can tailor it for the current usage? I think the "pt interaction" leg where start and end destination are been specifically mentioned is triggering such aborts
Below is some example code to modify the link of activities. The code also deletes the routes before and after changed activities to force the routes to be newly calculated. I'm not sure if this is really necessary in your case, but I thought it's better to include it. I didn't run the code, but I think it should work this way... (*fingers crossed*)
Id<Link> oldLinkId = Id.create("123", Link.class);
Id<Link> newLinkId = Id.create("abc", Link.class);
Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
new PopulationReader(scenario).readFile("/path/to/population.xml.gz");
for (Person person : scenario.getPopulation().getPersons().values()) {
for (Plan plan : person.getPlans()) {
Leg prevLeg = null;
boolean lastActivityChanged = false;
for (PlanElement pe : plan.getPlanElements()) {
if (pe instanceof Activity) {
Activity act = (Activity) pe;
if (oldLinkId.equals(act.getLinkId())) {
act.setLinkId(newLinkId);
if (prevLeg != null) {
prevLeg.setRoute(null); // force re-calculation of route
}
lastActivityChanged = true;
}
}
if (pe instanceof Leg) {
Leg leg = (Leg) pe;
if (lastActivityChanged) {
leg.setRoute(null); // force re-calculation of route
lastActivityChanged = false;
}
prevLeg = leg;
}
}
}
}
new PopulationWriter(scenario.getPopulation()).write("/path/to/newPopulation.xml.gz");
Hello all, This is my extension to my previously closed post : https://github.com/matsim-org/matsim-code-examples/issues/515#issue-792991933. I modified the network and transitSchedule.xml to introduce exclusive bus lane on some of the pre-identified routes. But I am now getting null pointer exception.
I looked into the lines where the code triggers i.e. (SwissRailRaptorRoutingModuleProvider.java:28). Unfortunately, the line corresponds to a comment. So, I am guessing that the "error" is in the public class constructor file which is attempted to initialized. there are few functions
Not sure, I am digging things in the right direction.
Any help, direction on resolving this issue would be very much appreciated. output_HighPTRdrshp_BusLane_v5.zip
Thank you Vedant