/** * In rare cases, Dijkstra may choose to go along two walk links to get from one location to another. * Test, that still only one walk leg with the correct start and end points/links is returned. */ @Test public void testDoubleWalk() { WalkFixture f = new WalkFixture(); f.routerConfig.setMarginalUtilityOfTravelTimePt_utl_s(-1.0 / 3600.0 - 6.0/3600.0); f.routerConfig.setUtilityOfLineSwitch_utl(0.2); // must be relatively low in this example, otherwise it's cheaper to walk the whole distance... TransitRouter router = createTransitRouter(f.schedule, f.routerConfig, routerType); List<Leg> legs = router.calcRoute(new FakeFacility(f.coord1), new FakeFacility(f.coord7), 990, null); assertEquals(5, legs.size()); assertEquals(TransportMode.transit_walk, legs.get(0).getMode()); assertEquals(TransportMode.pt, legs.get(1).getMode()); assertEquals(f.stop1.getId(), ((ExperimentalTransitRoute) legs.get(1).getRoute()).getAccessStopId()); assertEquals(f.stop2.getId(), ((ExperimentalTransitRoute) legs.get(1).getRoute()).getEgressStopId()); assertEquals(f.stop1.getLinkId(), legs.get(1).getRoute().getStartLinkId()); assertEquals(f.stop2.getLinkId(), legs.get(1).getRoute().getEndLinkId()); assertEquals(TransportMode.transit_walk, legs.get(2).getMode()); assertEquals(TransportMode.pt, legs.get(3).getMode()); assertEquals(f.stop2.getLinkId(), legs.get(2).getRoute().getStartLinkId()); assertEquals(f.stop6.getLinkId(), legs.get(2).getRoute().getEndLinkId()); assertEquals(f.stop6.getId(), ((ExperimentalTransitRoute) legs.get(3).getRoute()).getAccessStopId()); assertEquals(f.stop7.getId(), ((ExperimentalTransitRoute) legs.get(3).getRoute()).getEgressStopId()); assertEquals(f.stop6.getLinkId(), legs.get(3).getRoute().getStartLinkId()); assertEquals(f.stop7.getLinkId(), legs.get(3).getRoute().getEndLinkId()); assertEquals(TransportMode.transit_walk, legs.get(4).getMode()); }
public void testTravelCostLineSwitch() { Fixture f = new Fixture(); f.init(); TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule) ; TransitRouterNetwork routerNet = router.getTransitRouterNetwork(); // find the link connecting C and D on the blue line TransitRouterNetworkLink testLink = null; for (TransitRouterNetworkLink link : routerNet.getLinks().values()) { if ((link.getLine() == null) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("C"))) { testLink = link; } } double oldCost = - conf.getUtilityOfLineSwitch_utl(); double cost1 = tc.getLinkTravelDisutility(testLink, 7.0*3600, null, null, null); conf.setUtilityOfLineSwitch_utl(0.0); double cost2 = tc.getLinkTravelDisutility(testLink, 6.0*3600, null, null, null); // use different time because of internal caching effects assertEquals(oldCost, cost1 - cost2, MatsimTestCase.EPSILON); conf.setUtilityOfLineSwitch_utl(-40.125); double cost3 = tc.getLinkTravelDisutility(testLink, 5.0*3600, null, null, null); assertEquals(40.125, cost3 - cost2, MatsimTestCase.EPSILON); }
public void testTravelCostLineSwitch() { Fixture f = new Fixture(); f.init(); TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule); TransitRouterNetwork routerNet = router.getTransitRouterNetwork(); // find the link connecting C and D on the blue line TransitRouterNetworkLink testLink = null; for (TransitRouterNetworkLink link : routerNet.getLinks().values()) { if ((link.getLine() == null) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("C"))) { testLink = link; } } double oldCost = - conf.getUtilityOfLineSwitch_utl(); double cost1 = tc.getLinkTravelDisutility(testLink, 7.0*3600, null, null, null); conf.setUtilityOfLineSwitch_utl(0.0); double cost2 = tc.getLinkTravelDisutility(testLink, 6.0*3600, null, null, null); // use different time because of internal caching effects assertEquals(oldCost, cost1 - cost2, MatsimTestCase.EPSILON); conf.setUtilityOfLineSwitch_utl(-40.125); double cost3 = tc.getLinkTravelDisutility(testLink, 5.0*3600, null, null, null); assertEquals(40.125, cost3 - cost2, MatsimTestCase.EPSILON); }
f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); trConfig.setUtilityOfLineSwitch_utl(0); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); List<Leg> legs = router.calcRoute(new FakeFacility(new Coord((double) 11900, (double) 5100)), new FakeFacility(new Coord((double) 24100, (double) 4950)), 6.0*3600 - 5.0*60, null); assertEquals(TransportMode.transit_walk, legs.get(4).getMode()); trConfig.setUtilityOfLineSwitch_utl(300.0 * trConfig.getMarginalUtilityOfTravelTimePt_utl_s()); // corresponds to 5 minutes transit travel time legs = router.calcRoute(new FakeFacility(new Coord((double) 11900, (double) 5100)), new FakeFacility(new Coord((double) 24100, (double) 4950)), 6.0*3600 - 5.0*60, null); assertEquals(3, legs.size());
f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); trConfig.setUtilityOfLineSwitch_utl(0); assertEquals(0, trConfig.getAdditionalTransferTime(), 1e-8); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType);
conf.setUtilityOfLineSwitch_utl(0.0); double cost2 = tc.getLinkTravelDisutility(testLink, 6.0*3600, null, null, null); // use different time because of internal caching effects assertEquals(oldCost, cost1 - cost2, MatsimTestCase.EPSILON);
conf.setUtilityOfLineSwitch_utl(0.0); double cost2 = tc.getLinkTravelDisutility(testLink, 6.0*3600, null, null, null); // use different time because of internal caching effects assertEquals(oldCost, cost1 - cost2, MatsimTestCase.EPSILON);