/** Convenience method, to be consistent with earlier syntax. kai, may'16 * @param trip * @param plan * @param mainMode * @param departureTime * @param network * @param tripRouter */ public static boolean relocateFutureTrip(Trip trip, Plan plan, String mainMode, double departureTime, Network network, TripRouter tripRouter) { return replanFutureTrip(trip, plan, mainMode, departureTime, tripRouter ); } public StageActivityTypes getStageActivities() {
public final boolean replanFutureTrip(Trip trip, Plan plan, String routingMode, double departureTime) { return replanFutureTrip(trip, plan, routingMode, departureTime, tripRouter); }
private void replanCurrentTripFromStageActivity(final List<PlanElement> tripElements, int tripElementsIndex, MobsimAgent agent, String mainMode) { // String mainMode = tripRouter.getMainModeIdentifier().identifyMainMode(tripElements) ; // yyyy I wonder what this will do if we are already at the egress stage. kai, oct'17 List<PlanElement> subTripPlanElements = tripElements.subList(tripElementsIndex,tripElements.size()-1) ; Trip subTrip = TripStructureUtils.getTrips(subTripPlanElements, tripRouter.getStageActivityTypes()).get(0) ; final double dpTime = agent.getActivityEndTime() ; this.replanFutureTrip(subTrip, WithinDayAgentUtils.getModifiablePlan(agent), mainMode, dpTime ) ; } // future:
/** * Convenience method that estimates the trip departure time rather than explicitly requesting it. * * @param trip * @param plan * @param mainMode * @return */ public final boolean replanFutureTrip(Trip trip, Plan plan, String mainMode) { double departureTime = PlanRouter.calcEndOfActivity( trip.getOriginActivity(), plan, tripRouter.getConfig() ) ; return replanFutureTrip( trip, plan, mainMode, departureTime ) ; } public final boolean replanFutureTrip(Trip trip, Plan plan, String routingMode, double departureTime) {
@Override public boolean doReplanning(MobsimAgent withinDayAgent) { Plan executedPlan = WithinDayAgentUtils.getModifiablePlan(withinDayAgent); // If we don't have an executed plan if (executedPlan == null) return false; // Get the activity currently performed by the agent as well as the subsequent trip. Activity currentActivity = (Activity) WithinDayAgentUtils.getCurrentPlanElement(withinDayAgent); Trip trip = TripStructureUtils.findTripStartingAtActivity(currentActivity, executedPlan, this.tripRouter.getStageActivityTypes() ); // If there is no trip after the activity. if (trip == null) return false; String mainMode = this.tripRouter.getMainModeIdentifier().identifyMainMode(trip.getTripElements()); double departureTime = TripStructureUtils.getDepartureTime(trip); new EditTrips(this.tripRouter, scenario).replanFutureTrip(trip, executedPlan, mainMode, departureTime); return true; }