if (((TransitRouterNetworkLink) link).getRoute() == null) {
public TransitRouterNetworkLink createLink(final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode, final TransitRoute route, final TransitLine line) { final TransitRouterNetworkLink link = new TransitRouterNetworkLink(Id.create(this.nextLinkId++, Link.class), fromNode, toNode, route, line); this.links.put(link.getId(), link); fromNode.outgoingLinks.put(link.getId(), link); toNode.ingoingLinks.put(link.getId(), link); return link; }
@Override public String toString() { return "[" + this.id.toString() + " (" + this.getFromNode().id + " > " + this.getToNode().id + ")]"; }
if ((link.getLine() == f.blueLine) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("D"))) { testLink = link;
double distance = wrapped.getLength(); double time2 = distance / this.config.getBeelineWalkSpeed() + this.config.getAdditionalTransferTime(); this.cachedTravelTime = time2;
if ((link.getLine() == f.blueLine) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("D"))) {
if ((link.getLine() == null) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("C"))) {
if ((link.getLine() == null) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("C"))) {
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); }
public void testTravelTimeAfterMidnight() { 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() == f.blueLine) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("D"))) { testLink = link; } } // planned departure at 25:00, has to wait until 05:22 = 29:22 assertEquals(22.0*60 + 4.0*3600 + 7.0*60, tc.getLinkTravelTime(testLink, 25.0*3600, null, null), MatsimTestCase.EPSILON); // planned departure at 47:00, has to wait until 05:22 = 53:22 assertEquals(22.0*60 + 6.0*3600 + 7.0*60, tc.getLinkTravelTime(testLink, 47.0*3600, null, null), MatsimTestCase.EPSILON); // planned departure at 49:00, has to wait until 05:22 = 53:22, tests explicitly > 2*MIDNIGHT assertEquals(22.0*60 + 4.0*3600 + 7.0*60, tc.getLinkTravelTime(testLink, 49.0*3600, null, null), MatsimTestCase.EPSILON); }
public void testWaitingTime() { 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() == f.blueLine) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("D"))) { testLink = link; } } assertEquals(2.0*60 + 7.0*60, tc.getLinkTravelTime(testLink, 6.0*3600, null, null), MatsimTestCase.EPSILON); assertEquals(1.0*60 + 7.0*60, tc.getLinkTravelTime(testLink, 6.0*3600 + 60, null, null), MatsimTestCase.EPSILON); assertEquals(0.0*60 + 7.0*60, tc.getLinkTravelTime(testLink, 6.0*3600 + 120, null, null), MatsimTestCase.EPSILON); assertEquals(20.0*60 -1 + 7.0*60, tc.getLinkTravelTime(testLink, 6.0*3600 + 121, null, null), MatsimTestCase.EPSILON); }
public void testTravelTime() { //create the scenario test Fixture f = new Fixture(); f.init(); //create the adapted router 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 G on the red line TransitRouterNetworkLink testLink = null; for (TransitRouterNetworkLink link : routerNet.getLinks().values()) { if ((link.getLine() == f.redLine) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("G"))) { testLink = link; } } //at 6:00 the link travel time = 540 assertEquals(9.0*60, tc.getLinkTravelTime(testLink, 6.0*3600, null, null), MatsimTestCase.EPSILON); }
public void testTravelTime() { 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 G on the red line TransitRouterNetworkLink testLink = null; for (TransitRouterNetworkLink link : routerNet.getLinks().values()) { if ((link.getLine() == f.redLine) && (link.fromNode.stop.getStopFacility().getName().equals("C")) && (link.toNode.stop.getStopFacility().getName().equals("G"))) { testLink = link; } } assertEquals(9.0*60, tc.getLinkTravelTime(testLink, 6.0*3600, null, null), MatsimTestCase.EPSILON); }
public double getVehArrivalTime(final Link link, final double now){ if ((link == this.previousWaitLink) && (now == this.previousWaitTime)) { return this.cachedVehArrivalTime; } this.previousWaitLink = link; this.previousWaitTime = now; //first find out vehicle arrival time to fromStop according to transit schedule TransitRouterNetworkLink wrapped = (TransitRouterNetworkLink) link; if (wrapped.getRoute() == null) { throw new RuntimeException("should not happen") ; } TransitRouteStop fromStop = wrapped.fromNode.stop; double nextDepartureTime = preparedTransitSchedule.getNextDepartureTime(wrapped.getRoute(), fromStop, now); double fromStopArrivalOffset = (fromStop.getArrivalOffset() != Time.UNDEFINED_TIME) ? fromStop.getArrivalOffset() : fromStop.getDepartureOffset(); double vehWaitAtStopTime = fromStop.getDepartureOffset() - fromStopArrivalOffset; //time in which the veh stops at station double vehArrivalTime = nextDepartureTime - vehWaitAtStopTime; cachedVehArrivalTime = vehArrivalTime ; return vehArrivalTime ; }
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) { double cost; if (((TransitRouterNetworkLink) link).getRoute() == null) { // "route" here means "pt route". If no pt route is attached, it means that it is a transfer link. cost = defaultTransferCost(link, time, person, vehicle); } else { double offVehWaitTime = offVehicleWaitTime(link, time); double inVehTime = getLinkTravelTime(link,time, person, vehicle) - offVehWaitTime; cost = - inVehTime * this.config.getMarginalUtilityOfTravelTimePt_utl_s() -offVehWaitTime * this.config.getMarginalUtilityOfWaitingPt_utl_s() -link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); } return cost; }
@Override public double getFreespeed() { return getFreespeed(Time.UNDEFINED_TIME); }
@Override public double getCapacity() { return getCapacity(Time.UNDEFINED_TIME); }
@Override public double getNumberOfLanes() { return getNumberOfLanes(Time.UNDEFINED_TIME); }