@Override public Id<Person> getId() { return this.basicPlanAgentDelegate.getId(); }
@Override public final Id<Person> getId() { return basicAgentDelegate.getId(); } @Override
@Override public Id<Person> getId() { return basicAgentDelegate.getId() ; }
@Override public final Id<Person> getId() { return basicAgentDelegate.getId(); }
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 ; }
@Override public final Id<Vehicle> getPlannedVehicleId() { NetworkRoute route = (NetworkRoute) this.getCurrentLeg().getRoute(); // if casts fail: illegal state. if (route.getVehicleId() != null) { return route.getVehicleId(); } Gbl.assertIf( scenario.getConfig().qsim().getUsePersonIdForMissingVehicleId() ); return Id.create(this.getId(), Vehicle.class); // we still assume the vehicleId is the agentId if no vehicleId is given. } @Override
private void initializeActivity(Activity act, double now) { this.setState(MobsimAgent.State.ACTIVITY) ; this.getEvents().processEvent( new ActivityStartEvent(now, this.getId(), this.getCurrentLinkId(), act.getFacilityId(), act.getType())); calculateAndSetDepartureTime(act); getModifiablePlan(); // this is necessary to make the plan modifiable, so that setting the start time (next line) is actually feasible. kai/mz, oct'16 ((Activity) getCurrentPlanElement()).setStartTime(now); }
@Override public final void endLegAndComputeNextState(final double now) { this.getEvents().processEvent(new PersonArrivalEvent( now, this.getId(), this.getDestinationLinkId(), getCurrentLeg().getMode())); if( (!(this.getCurrentLinkId() == null && this.getDestinationLinkId() == null)) && !this.getCurrentLinkId().equals(this.getDestinationLinkId())) { log.error("The agent " + this.getPerson().getId() + " has destination link " + this.getDestinationLinkId() + ", but arrived on link " + this.getCurrentLinkId() + ". Setting agent state to ABORT."); this.setState(MobsimAgent.State.ABORT) ; } else { // note that when we are here we don't know if next is another leg, or an activity Therefore, we go to a general method: advancePlan(now) ; } this.currentLinkIndex = 0 ; }