@Override public Id<ActivityFacility> getFacilityId() { return act.getFacilityId(); }
@Override public Id<ActivityFacility> getFacilityId() { return this.delegate.getFacilityId() ; } @Override
@Override public Id<ActivityFacility> getId() { return this.wrapped.getFacilityId(); }
private Id<? extends BasicLocation> getLocationId(Activity activity) { return activity.getFacilityId()!=null ? activity.getFacilityId() : activity.getLinkId(); }
@Override public Id<ActivityFacility> getFacilityId() { return this.delegate.getFacilityId(); } public EqualsActivity(final String type, final Id<Link> link) {
private boolean atSameLocation(Activity firstLegUsingMode, Activity lastLegUsingMode) { return firstLegUsingMode.getFacilityId()!=null ? firstLegUsingMode.getFacilityId().equals( lastLegUsingMode.getFacilityId() ) : firstLegUsingMode.getLinkId().equals( lastLegUsingMode.getLinkId() ); }
public BasicFacility( final Activity act) { this.coord = act.getCoord(); this.id = act.getFacilityId(); this.link = act.getLinkId(); }
private static Facility getFacility(Activity activity, Scenario scenario) { ActivityFacility fac = scenario.getActivityFacilities().getFacilities().get( activity.getFacilityId() ) ; return ( fac != null) ? fac : new ActivityWrapperFacility( activity ); } }
final Coord calcBarycenterCoord( final List<Activity> activitiesToMutate ) { double sumX = 0; double sumY = 0; for ( Activity act : activitiesToMutate ) { final Id facilityId = act.getFacilityId(); if ( facilityId == null ) throw new RuntimeException( "no facility for act "+act ); final ActivityFacility fac = facilities.getFacilities().get( facilityId ); sumX += fac.getCoord().getX(); sumY += fac.getCoord().getY(); } return new Coord(sumX / activitiesToMutate.size(), sumY / activitiesToMutate.size()); }
private Facility toFacility(final Activity act) { if ((act.getLinkId() == null || act.getCoord() == null) && facilities != null && !facilities.getFacilities().isEmpty()) { // use facilities only if the activity does not provides the required fields. return facilities.getFacilities().get( act.getFacilityId() ); } return new ActivityWrapperFacility( act ); }
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(); }
public static Id<Link> decideOnLinkIdForActivity( Activity act, Scenario sc ) { if ( act.getFacilityId() !=null ) { final ActivityFacility facility = sc.getActivityFacilities().getFacilities().get( act.getFacilityId() );; if ( facility==null ) { throw new RuntimeException("facility ID given but not in facilities container") ; } Gbl.assertNotNull( facility.getLinkId() ); return facility.getLinkId(); } Gbl.assertNotNull( act.getLinkId() ); return act.getLinkId() ; } public static Coord decideOnCoordForActivity( Activity act, Scenario sc ) {
public double getDestinationScore(Activity act, double fVar, int activityIndex, Id<Person> personId) { double score = 0.0; if (this.scaleEpsilon.isFlexibleType(act.getType())) { /* * The following will not work if activities are inserted or removed during replanning (e.g. ptInteractionActivities). kai/mz, oct'14 */ int actIndex = 2*activityIndex ; // "2": retrofitting; this used to be the PlanElementIndex. One could probably remove the "2", // but then the test fail because this is equivalent to a different random seed. So more diligent checking would be needed. if (fVar < 0.0) fVar = this.scaleEpsilon.getEpsilonFactor(act.getType()); score += (fVar * this.getEpsilonAlternative(act.getFacilityId(), personId, actIndex)); score += this.getAttributesScore(act.getFacilityId(), personId ); } return score; }
@Override public Facility getDestinationFacility() { PlanElement pe = this.getCurrentPlanElement() ; if ( pe instanceof Leg ) { Activity activity = this.getNextActivity() ; ActivityFacility fac = this.scenario.getActivityFacilities().getFacilities().get( activity.getFacilityId() ) ; return getFacility(activity, scenario); // the above assumes alternating acts/legs. I start having the suspicion that we should revoke our decision to give that up. // If not, one will have to use TripUtils to find the preceeding activity ... but things get more difficult. Preferably, the // factility should then sit in the leg (since there it is used for routing). kai, dec'15 } else if ( pe instanceof Activity ) { return null ; } throw new RuntimeException("unexpected type of PlanElement") ; }
private List<? extends PlanElement> newTripToNewActivity(Activity newAct, String mainMode, double now, MobsimAgent agent, Person person, Scenario scenario) { log.debug("entering newTripToNewActivity") ; Link currentLink = scenario.getNetwork().getLinks().get( agent.getCurrentLinkId() ) ; Facility fromFacility = new LinkWrapperFacility( currentLink ) ; Facility toFacility = scenario.getActivityFacilities().getFacilities().get( newAct.getFacilityId() ) ; if ( toFacility == null ) { toFacility = new ActivityWrapperFacility( newAct ) ; } List<? extends PlanElement> newTrip = tripRouter.calcRoute(mainMode, fromFacility, toFacility, now, person) ; return newTrip; } // replan from stage activity:
@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 assertPlan(Plan plan, String homeFacilityId, String workFacilityId, boolean linkCoordMustBeNull) { Activity home1 = (Activity) plan.getPlanElements().get(0); Activity work = (Activity) plan.getPlanElements().get(2); Activity home2 = (Activity) plan.getPlanElements().get(4); Assert.assertEquals(homeFacilityId, home1.getFacilityId().toString()); Assert.assertEquals(workFacilityId, work.getFacilityId().toString()); Assert.assertEquals(homeFacilityId, home2.getFacilityId().toString()); if (linkCoordMustBeNull) { Assert.assertNull(home1.getLinkId()); Assert.assertNull(home1.getCoord()); Assert.assertNull(work.getLinkId()); Assert.assertNull(work.getCoord()); Assert.assertNull(home2.getLinkId()); Assert.assertNull(home2.getCoord()); } }
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 ); }