@Override public String getType() { return this.delegate.getType() ; }
@Override @Deprecated // preferably use SumScoringFunction. kai, oct'13 public void endActivity(final double time, final Activity act) { assert act != null; assert currentActivity == null || currentActivity.getType().equals(act.getType()); if (this.firstAct) { this.firstActivityEndTime = time; this.firstActivity = act; this.firstAct = false; } else { this.score += calcActScore(this.currentActivityStartTime, time, act); } currentActivity = null; }
@Override public String getType() { return this.delegate.getType(); } @Override
@Override public DynActivity computeInitialActivity(DynAgent adapterAgent) { this.agent = adapterAgent; Activity act = (Activity)planElemIter.next(); return new IdleDynActivity(act.getType(), act.getEndTime()); }
public void addActivity( final Id person , final Activity activity ) { final Map<Id, List<Activity>> activitiesPerPerson = MapUtils.getMap( activity.getType(), map ); final List<Activity> activities = MapUtils.getList( person, activitiesPerPerson ); activities.add( activity ); }
private void getFlexibleActs(Plan plan, List<Activity> flexibleActivities) { for (int i = 0; i < plan.getPlanElements().size(); i = i + 2) { Activity act = (Activity)plan.getPlanElements().get(i); if (this.flexibleTypes.contains(this.converter.convertType(act.getType()))) { flexibleActivities.add(act); } } }
@Override public void handleFirstActivity(Activity act) { if ( blackList.isStageActivity( act.getType() ) ) return; delegate.handleFirstActivity( act); }
@Override public void handleActivity(Activity act) { if ( blackList.isStageActivity( act.getType() ) ) return; delegate.handleActivity( act); }
@Override public void handleLastActivity(Activity act) { if ( blackList.isStageActivity( act.getType() ) ) return; delegate.handleLastActivity( act); }
public static Trip findTripStartingAtActivity( final Activity activity, final Plan plan, StageActivityTypes stageActivities ) { Gbl.assertIf( ! stageActivities.isStageActivity( activity.getType()) ) ; List<Trip> trips = getTrips( plan, stageActivities ) ; for ( Trip trip : trips ) { if ( trip.getOriginActivity().equals( activity ) ) { return trip ; } } return null ; }
private void checkIfNotStageActivity(Activity origAct) { if( this.tripRouter.getStageActivityTypes().isStageActivity(origAct.getType()) ){ throw new ReplanningException("trying to replace a helper activity (stage activity) by a real activity; this is not possible") ; } } private static boolean checkIfTripHasAlreadyStarted(MobsimAgent agent, final List<PlanElement> currentTripElements) {
@Override public DynAction computeNextAction(DynAction oldAction, double now) { PlanElement planElem = planElemIter.next(); if (planElem instanceof Activity) { Activity act = (Activity)planElem; return new IdleDynActivity(act.getType(), act.getEndTime()); } // only the 'car' mode supported right now Leg leg = (Leg)planElem; return new StaticDriverDynLeg(leg.getMode(), (NetworkRoute)leg.getRoute()); } }
public static Trip findTripEndingAtActivity(Activity activity, Plan plan, StageActivityTypes stageActivities ) { Gbl.assertIf( ! stageActivities.isStageActivity( activity.getType()) ) ; List<Trip> trips = getTrips(plan.getPlanElements(), stageActivities ) ; for ( Trip trip : trips ) { if ( activity.equals( trip.getDestinationActivity() ) ) { return trip; } } return null ; } public static Trip findTripStartingAtActivity( final Activity activity, final Plan plan, StageActivityTypes stageActivities ) {
public static Activity createActivity(Activity act) { Activity newAct = getFactory().createActivityFromLinkId(act.getType(), act.getLinkId()) ; copyFromTo(act, newAct); // (this ends up setting type and linkId again) return newAct ; }
public ActivitySerializable(Activity act) { coord = new CoordSerializable(act.getCoord()); endTime = act.getEndTime(); facIdString = act.getFacilityId() == null ? null : act.getFacilityId().toString(); linkIdString = act.getLinkId() == null ? null : act.getLinkId().toString(); maximumDuration = act.getMaximumDuration(); startTime = act.getStartTime(); type = act.getType(); }
private void setNewLocationForAct(Activity act, int length) { ActivityFacilityImpl facility = this.facilitiesOfType.get(act.getType())[super.random.nextInt(length)]; act.setFacilityId(facility.getId()); act.setLinkId(NetworkUtils.getNearestLink(((Network) this.scenario.getNetwork()), facility.getCoord()).getId()); act.setCoord(facility.getCoord()); } }
@Override public final void endActivityAndComputeNextState(final double now) { Activity act = (Activity) this.getCurrentPlanElement() ; this.getEvents().processEvent( new ActivityEndEvent(now, this.getPerson().getId(), this.currentLinkId, act.getFacilityId(), act.getType())); // 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); } @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 void processEvent() { Event event; // schedule ActEndEvent event = new ActivityEndEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), vehicle .getPreviousActivity().getFacilityId(), vehicle.getPreviousActivity().getType()); eventsManager.processEvent(event); // schedule AgentDepartureEvent event = new PersonDepartureEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), vehicle.getCurrentLeg().getMode()); eventsManager.processEvent(event); }
public static void copyFromTo(Activity act, Activity newAct) { Coord coord = act.getCoord() == null ? null : new Coord(act.getCoord().getX(), act.getCoord().getY()); // (we don't want to copy the coord ref, but rather the contents!) newAct.setCoord(coord); newAct.setType( act.getType() ); newAct.setLinkId(act.getLinkId()); newAct.setStartTime(act.getStartTime()); newAct.setEndTime(act.getEndTime()); newAct.setMaximumDuration(act.getMaximumDuration()); newAct.setFacilityId(act.getFacilityId()); AttributesUtils.copyAttributesFromTo( act , newAct ); }