final Leg getCurrentLeg() { return basicAgentDelegate.getCurrentLeg() ; } @Override
@Override public final Id<Link> getDestinationLinkId() { return this.getCurrentLeg().getRoute().getEndLinkId() ; } @Override
@Override public final Id<TransitStopFacility> getDesiredDestinationStopId() { ExperimentalTransitRoute route = (ExperimentalTransitRoute) basicAgentDelegate.getCurrentLeg().getRoute(); return route.getEgressStopId(); } @Override
@Override public final Id<TransitStopFacility> getDesiredAccessStopId() { Leg leg = basicAgentDelegate.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(); Id<TransitStopFacility> accessStopId = route.getAccessStopId(); return accessStopId; } }
@Override public final boolean getExitAtStop(final TransitStopFacility stop) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) basicAgentDelegate.getCurrentLeg().getRoute(); return route.getEgressStopId().equals(stop.getId()); }
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) ;
@Override public final boolean isWantingToArriveOnCurrentLink( ) { if ( ! ( this.basicPlanAgentDelegate.getCurrentLeg().getRoute() instanceof NetworkRoute ) ) { final List<Id<Link>> routeLinkIds = ((NetworkRoute) this.basicPlanAgentDelegate.getCurrentLeg().getRoute()).getLinkIds(); final int routeLinkIdsSize = routeLinkIds.size();
@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"); } }
if ( ! ( this.basicPlanAgentDelegate.getCurrentLeg().getRoute() instanceof NetworkRoute ) ) { return null ; List<Id<Link>> routeLinkIds = ((NetworkRoute) this.basicPlanAgentDelegate.getCurrentLeg().getRoute()).getLinkIds();
@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
@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 ; }