final int getCurrentPlanElementIndex() { return basicAgentDelegate.getCurrentPlanElementIndex() ; } @Override
@Override public final String getMode() { if( this.getCurrentPlanElementIndex() >= this.getCurrentPlan().getPlanElements().size() ) { // just having run out of plan elements it not an argument for not being able to answer the "mode?" question, // thus we answer with "null". This will likely result in an "abort". kai, nov'14 return null ; } PlanElement currentPlanElement = this.getCurrentPlanElement(); if (!(currentPlanElement instanceof Leg)) { return null; } return ((Leg) currentPlanElement).getMode() ; } @Override
private void advancePlan(double now) { this.currentPlanElementIndex++ ; // check if plan has run dry: if ( this.getCurrentPlanElementIndex() >= this.getCurrentPlan().getPlanElements().size() ) { log.error("plan of agent with id = " + this.getId() + " has run empty. Setting agent state to ABORT (but continuing the mobsim).") ; this.setState(MobsimAgent.State.ABORT) ; return; } PlanElement pe = this.getCurrentPlanElement() ; if (pe instanceof Activity) { Activity act = (Activity) pe; initializeActivity(act, now); } else if (pe instanceof Leg) { Leg leg = (Leg) pe; initializeLeg(leg); } else { throw new RuntimeException("Unknown PlanElement of type: " + pe.getClass().getName()); } }
/** * If this method is called to update a changed ActivityEndTime please * ensure that the ActivityEndsList in the {@link QSim} is also updated. */ private final void calculateAndSetDepartureTime(Activity act) { PlansConfigGroup.ActivityDurationInterpretation activityDurationInterpretation = this.getScenario().getConfig().plans().getActivityDurationInterpretation(); double now = this.getSimTimer().getTimeOfDay() ; double departure = ActivityDurationUtils.calculateDepartureTime(act, now, activityDurationInterpretation); if ( this.getCurrentPlanElementIndex() == this.getCurrentPlan().getPlanElements().size()-1 ) { if ( finalActHasDpTimeWrnCnt < 1 && departure!=Double.POSITIVE_INFINITY ) { log.error( "last activity of person driver agent id " + this.getId() + " has end time < infty; setting it to infty") ; log.error( Gbl.ONLYONCE ) ; finalActHasDpTimeWrnCnt++ ; } departure = Double.POSITIVE_INFINITY ; } this.activityEndTime = departure ; }