@Override public final void setStateToAbort(final double now) { this.setState(MobsimAgent.State.ABORT) ; }
private void initializeLeg(Leg leg) { this.setState(MobsimAgent.State.LEG) ; this.currentLinkIndex = 0 ; if (leg.getRoute() == null) { log.error("The agent " + this.getPerson().getId() + " has no route in its leg. Setting agent state to ABORT."); if ( noRouteWrnCnt < 1 ) { log.info( "(Route is needed inside Leg even if you want teleportation since Route carries the start/endLinkId info.)") ; noRouteWrnCnt++ ; } this.setState(MobsimAgent.State.ABORT) ; // throw new RuntimeException("no route in leg") ; } }
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 (basicPlanAgentDelegate.getCurrentLeg().getRoute() == null) { log.error("The agent " + this.getId() + " has no route in its leg. Setting agent state to abort." ); this.basicPlanAgentDelegate.setState(MobsimAgent.State.ABORT) ;
public BasicPlanAgentImpl(Plan plan2, Scenario scenario, EventsManager events, MobsimTimer simTimer) { this.plan = PopulationUtils.unmodifiablePlan(plan2) ; // yy MZ suggests, and I agree, to always give the agent a full plan, and consume that plan as the agent goes. kai, nov'14 this.scenario = scenario ; this.events = events ; this.simTimer = simTimer ; List<PlanElement> planElements = this.getCurrentPlan().getPlanElements(); if (planElements.size() > 0) { Activity firstAct = (Activity) planElements.get(0); // this.setCurrentLinkId( firstAct.getLinkId() ) ; final Id<Link> linkId = PopulationUtils.computeLinkIdFromActivity(firstAct, scenario.getActivityFacilities(), scenario.getConfig() ); Gbl.assertIf( linkId!=null ); this.setCurrentLinkId( linkId ); this.setState(MobsimAgent.State.ACTIVITY) ; calculateAndSetDepartureTime(firstAct); } }
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 ; }