@Override public Route createRoute(final Id<Link> startLinkId, final Id<Link> endLinkId) { return new ExperimentalTransitRoute(startLinkId, endLinkId); }
public void testSetRouteDescription_NonPtRoute() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); route.setRouteDescription("23 42 7 21"); assertNull(route.getAccessStopId()); assertNull(route.getLineId()); assertNull(route.getEgressStopId()); assertEquals("23 42 7 21", route.getRouteDescription()); } }
public void testTravelTime() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); assertEquals(Time.UNDEFINED_TIME, route.getTravelTime(), MatsimTestCase.EPSILON); double traveltime = 987.65; route.setTravelTime(traveltime); assertEquals(traveltime, route.getTravelTime(), MatsimTestCase.EPSILON); }
public void testSetRouteDescription_PtRoute() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); route.setRouteDescription("PT1===5===11===1980===1055"); assertEquals("5", route.getAccessStopId().toString()); assertEquals("11", route.getLineId().toString()); assertEquals("1980", route.getRouteId().toString()); assertEquals("1055", route.getEgressStopId().toString()); assertEquals("PT1===5===11===1980===1055", route.getRouteDescription()); }
public void testInitializationStops() { TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitStopFacility stop1 = builder.createTransitStopFacility(Id.create(1, TransitStopFacility.class), new Coord(5, 11), false); TransitStopFacility stop2 = builder.createTransitStopFacility(Id.create(2, TransitStopFacility.class), new Coord(18, 7), false); Link link1 = new FakeLink(Id.create(3, Link.class)); Link link2 = new FakeLink(Id.create(4, Link.class)); stop1.setLinkId(link1.getId()); stop2.setLinkId(link2.getId()); TransitLine line = builder.createTransitLine(Id.create(5, TransitLine.class)); TransitRoute tRoute = builder.createTransitRoute(Id.create(6, TransitRoute.class), null, Collections.<TransitRouteStop>emptyList(), "bus"); ExperimentalTransitRoute route = new ExperimentalTransitRoute(stop1, line, tRoute, stop2); assertEquals(stop1.getId(), route.getAccessStopId()); assertEquals(line.getId(), route.getLineId()); assertEquals(tRoute.getId(), route.getRouteId()); assertEquals(stop2.getId(), route.getEgressStopId()); assertEquals(link1.getId(), route.getStartLinkId()); assertEquals(link2.getId(), route.getEndLinkId()); }
public void testInitializationLinks() { Link link1 = new FakeLink(Id.create(1, Link.class)); Link link2 = new FakeLink(Id.create(2, Link.class)); ExperimentalTransitRoute route = new ExperimentalTransitRoute(link1.getId(), link2.getId()); assertEquals(link1.getId(), route.getStartLinkId()); assertEquals(link2.getId(), route.getEndLinkId()); assertNull(route.getAccessStopId()); assertNull(route.getLineId()); assertNull(route.getEgressStopId()); }
@Override public Trip findTrip(Leg prevLeg, double earliestDepartureTime_s) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) prevLeg.getRoute(); Id accessStopId = route.getAccessStopId(); Id egressStopId = route.getEgressStopId(); Tuple<Double, Double> routeTravelTime = transitPerformance.getRouteTravelTime(route.getLineId(), route.getRouteId(), accessStopId, egressStopId, earliestDepartureTime_s); final double accessTime_s = earliestDepartureTime_s + routeTravelTime.getFirst(); final double egressTime_s = accessTime_s + routeTravelTime.getSecond(); return new Trip(null, accessTime_s, egressTime_s); } }
@Override public Trip findTrip(Leg prevLeg, double earliestDepartureTime_s) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) prevLeg.getRoute(); TransitLine line = this.transitLines.get(route.getLineId()); TransitRoute transitRoute = line.getRoutes().get(route.getRouteId()); final double accessTime_s = earliestDepartureTime_s + this.waitTimes.getRouteStopWaitTime(route.getLineId(), transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s); final double egressTime_s = accessTime_s + this.findTransitTravelTime(route, accessTime_s); return new Trip(null, accessTime_s, egressTime_s); }
public void testLinks() { Link link1 = new FakeLink(Id.create(1, Link.class)); Link link2 = new FakeLink(Id.create(2, Link.class)); Link link3 = new FakeLink(Id.create(3, Link.class)); Link link4 = new FakeLink(Id.create(4, Link.class)); ExperimentalTransitRoute route = new ExperimentalTransitRoute(link1.getId(), link2.getId()); assertEquals(link1.getId(), route.getStartLinkId()); assertEquals(link2.getId(), route.getEndLinkId()); route.setStartLinkId(link3.getId()); route.setEndLinkId(link4.getId()); assertEquals(link3.getId(), route.getStartLinkId()); assertEquals(link4.getId(), route.getEndLinkId()); }
@Override public final boolean getEnterTransitRoute(final TransitLine line, final TransitRoute transitRoute, final List<TransitRouteStop> stopsToCome, TransitVehicle transitVehicle) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) basicAgentDelegate.getCurrentLeg().getRoute(); switch ( boardingAcceptance ) { case checkLineAndStop: return line.getId().equals(route.getLineId()) && containsId(stopsToCome, route.getEgressStopId()); case checkStopOnly: return containsId(stopsToCome, route.getEgressStopId()); default: throw new RuntimeException("not implemented"); } }
@Override public final Id<TransitStopFacility> getDesiredDestinationStopId() { ExperimentalTransitRoute route = (ExperimentalTransitRoute) basicAgentDelegate.getCurrentLeg().getRoute(); return route.getEgressStopId(); } @Override
private Leg createTransitLeg(RouteSegment routeSegment) { Leg leg = PopulationUtils.createLeg(TransportMode.pt); TransitStopFacility accessStop = routeSegment.getFromStop(); TransitStopFacility egressStop = routeSegment.getToStop(); ExperimentalTransitRoute ptRoute = new ExperimentalTransitRoute(accessStop, egressStop, routeSegment.getLineTaken(), routeSegment.getRouteTaken()); ptRoute.setTravelTime(routeSegment.travelTime); leg.setRoute(ptRoute); leg.setTravelTime(routeSegment.getTravelTime()); return leg; }
@Override public Id<TransitStopFacility> getDesiredAccessStopId() { Leg leg = getCurrentLeg(); if (!(leg.getRoute() instanceof ExperimentalTransitRoute)) { log.error("pt-leg has no TransitRoute. Removing agent from simulation. Agent " + getId().toString()); log.info("route: " + leg.getRoute().getClass().getCanonicalName() + " " + leg.getRoute().getRouteDescription()); return null; } else { ExperimentalTransitRoute route = (ExperimentalTransitRoute) leg.getRoute(); return route.getAccessStopId(); } }
@Override public Route getRoute(String mode) { Route route; Id<Link> startLinkId = Id.createLinkId(startLinkIdString); Id<Link> endLinkId = Id.createLinkId(endLinkIdString); if (mode.equals(TransportMode.pt) && isUseTransit) { route = new ExperimentalTransitRouteFactory().createRoute(startLinkId, endLinkId); } else { route = RouteUtils.createGenericRouteImpl(startLinkId, endLinkId); } route.setDistance(distance); route.setTravelTime(travelTime); route.setStartLinkId(startLinkId); route.setEndLinkId(endLinkId); route.setRouteDescription(routeDescription); return route; }
public RouteFactories() { this.setRouteFactory(NetworkRoute.class, new LinkNetworkRouteFactory()); this.setRouteFactory(ExperimentalTransitRoute.class, new ExperimentalTransitRouteFactory()); }
public void testSetRouteDescription_PtRouteWithDescription() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); route.setRouteDescription("PT1===5===11===1980===1055===this is a===valid route"); assertEquals("5", route.getAccessStopId().toString()); assertEquals("11", route.getLineId().toString()); assertEquals("1980", route.getRouteId().toString()); assertEquals("1055", route.getEgressStopId().toString()); assertEquals("PT1===5===11===1980===1055===this is a===valid route", route.getRouteDescription()); }
@Override public Id<TransitStopFacility> getDesiredDestinationStopId() { Leg leg = getCurrentLeg(); if (!(leg.getRoute() instanceof ExperimentalTransitRoute)) { log.error("pt-leg has no TransitRoute. Removing agent from simulation. Agent " + getId().toString()); log.info("route: " + leg.getRoute().getClass().getCanonicalName() + " " + leg.getRoute().getRouteDescription()); return null; } else { ExperimentalTransitRoute route = (ExperimentalTransitRoute) leg.getRoute(); return route.getEgressStopId(); } }
/** * Creates a new fake Agent. If enterStop or exitStop are <code>null</code>, * the leg will have no route. * * @param enterStop may be <code>null</code> * @param exitStop may be <code>null</code> */ public FakeAgent(final TransitStopFacility enterStop, final TransitStopFacility exitStop) { this.exitStop = exitStop; this.dummyLeg = PopulationUtils.createLeg(TransportMode.pt); if ((enterStop != null) && (exitStop != null)) { Route route = new ExperimentalTransitRoute(enterStop, null, null, exitStop); route.setStartLinkId(enterStop.getLinkId()); route.setEndLinkId(exitStop.getLinkId()); route.setRouteDescription("PT1 " + enterStop.getId().toString() + " T1 " + exitStop.getId().toString()); this.dummyLeg.setRoute(route); } }
@Override public final boolean getExitAtStop(final TransitStopFacility stop) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) basicAgentDelegate.getCurrentLeg().getRoute(); return route.getEgressStopId().equals(stop.getId()); }
@Override public boolean getExitAtStop(final TransitStopFacility stop) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) getCurrentLeg().getRoute(); return route.getEgressStopId().equals(stop.getId()); }