Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenericRouteImpl cannot be cast to ExperimentalTransitRoute #3

Closed
gregmacfarlane opened this issue Aug 28, 2018 · 7 comments
Closed

Comments

@gregmacfarlane
Copy link
Contributor

I am running a scenario with public transit using the RAPTOR router. I get the following error for random individuals or at random replanning steps:

2018-08-23 14:55:11,771 ERROR ParallelPersonAlgorithmUtils$ExceptionHandler:164 Thread PersonPrepareForSim.4 died with exception while handling events.
java.lang.ClassCastException: org.matsim.core.population.routes.GenericRouteImpl cannot be cast to org.matsim.pt.routes.ExperimentalTransitRoute
	at org.matsim.core.router.TransitRouterWrapper.fillWithActivities(TransitRouterWrapper.java:113)
	at org.matsim.core.router.TransitRouterWrapper.calcRoute(TransitRouterWrapper.java:93)
	at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:217)
	at org.matsim.core.router.PlanRouter.run(PlanRouter.java:87)
	at org.matsim.core.population.algorithms.PersonPrepareForSim.run(PersonPrepareForSim.java:141)
	at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils$PersonAlgoThread.run(ParallelPersonAlgorithmUtils.java:145)

This error traces back to this line of code in TransitRouterWrapper.fillWithActivities():

Facility firstToFacility;
if (baseTrip.size() > 1) { // at least one pt leg available
  ExperimentalTransitRoute tRoute = (ExperimentalTransitRoute) baseTrip.get(1).getRoute();
  firstToFacility = this.transitSchedule.getFacilities().get(tRoute.getAccessStopId());
} else {
  firstToFacility = toFacility;
}
// (*)
Route route = createWalkRoute(fromFacility, departureTime, person, leg.getTravelTime(), firstToFacility);
leg.setRoute(route);

In one case I've been able to isolate, the error gets thrown on a baseTrip with 4 legs:

  1. [mode=transit_walk][depTime=undefined][travTime=00:13:52][arrTime=undefined][route= startLinkId=null endLinkId=pt_f-dqc-wmata_7082 travTime=832.9396361992092 dist=1166.115490678893]
  2. [mode=transit_walk][depTime=undefined][travTime=00:01:17][arrTime=undefined][route= startLinkId=pt_f-dqc-wmata_6219 endLinkId=50758_B travTime=77.24313499229577 dist=108.14038898921407]
  3. [mode=pt][depTime=undefined][travTime=00:08:32][arrTime=undefined][route=[ExpTransitRoute: access=f-dqc-wmata_36826.link:50758_B egress=f-dqc-wmata_27810.link:36262_A line=f-dqc-wmata_182_0 route=f-dqc-wmata_182_0 ]]
  4. [mode=transit_walk][depTime=undefined][travTime=00:01:16][arrTime=undefined][route= startLinkId=36262_A endLinkId=null travTime=76.13281330697025 dist=106.58593862975836]

The class of leg 1 is in fact a GenericRouteImpl rather than the ExperimentalTransitRoute the method expects. It seems odd that there would be 2 transit_walk legs before the pt leg in the route RAPTOR generates.

I suppose that my overall question is, is this likely to be caused by a poorly formed highway network / transit schedule, or an improperly configured router, or a legitimate bug? I'm using 10.0

@gregmacfarlane
Copy link
Contributor Author

@gregmacfarlane
Copy link
Contributor Author

Well, I decided to run it without the RAPTOR override, and it revealed a problem with my transit network where some routes have no departures. Not sure how that happened or if this is the source of my error, but I'm going to work with this assumption until proven otherwise.

@mrieser
Copy link
Contributor

mrieser commented Aug 29, 2018

Which version of the SwissRailRaptor are you using? I remember that in early versions, there was a bug that caused such an error message, but that should hopefully have been fixed.
Also, there is a class org.matsim.pt.utils.TransitScheduleValidator which might help to find problems with the transit schedule.

@gregmacfarlane
Copy link
Contributor Author

The raptor algorithm is in org.matsim.contrib.minibus.performance.raptor as outlined in the code examples, version 0.10.0

The schedule I am using had passed the validator.

@mrieser
Copy link
Contributor

mrieser commented Aug 29, 2018

ah, the minibus-raptor. Don't know about that one (there are actually two different raptor implementations currently, the one in minibus and the one at https://github.com/SchweizerischeBundesbahnen/matsim-sbb-extensions). I know I had a similar problem and fixed it in the second one, but have no experience with the minibus-one.

@jfbischoff
Copy link

@vsp-gleich has tried to get the minibus raptor running for Cape Town and did not succeed either.
The Raptor provided by SBB works very stable and will, in one way or the other, may become the Standard Router in MATSim in the next release.

@gregmacfarlane
Copy link
Contributor Author

Calling the SBB raptor resolved my issue. Thanks for all the help gentlemen...

    private void runControler() {

        // Run scenario
        Controler controler = new Controler(sc);

        // Use Swiss Rail RAPTOR transit router
        controler.addOverridingModule(new AbstractModule() {
            @Override
            public void install() {
                install(new SBBQSimModule());
                install(new SwissRailRaptorModule());
            }
        });

        controler.run();

        String dir = config.controler().getOutputDirectory();
        log.info("Output is in " + dir + ".") ;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants