@Override public void setMaximumDuration(double seconds) { act.setMaximumDuration(seconds); }
private static Activity createInteractionActivity( final Coord interactionCoord, final Id<Link> interactionLink, final String stageActivityType ) { Activity act = PopulationUtils.createActivityFromCoordAndLinkId(stageActivityType, interactionCoord, interactionLink); act.setMaximumDuration(0.0); return act; }
@Override public void setMaximumDuration(double seconds) { this.delegate.setMaximumDuration(seconds); } @Override
private void startAct(final Attributes atts) { if (atts.getValue(ATTR_ACT_LINK) != null) { Id<Link> linkId = Id.create(atts.getValue(ATTR_ACT_LINK), Link.class); final Id<Link> linkId1 = linkId; this.curract = PopulationUtils.createAndAddActivityFromLinkId(this.currplan, atts.getValue(ATTR_ACT_TYPE), linkId1); if ((atts.getValue(ATTR_ACT_X) != null) && (atts.getValue(ATTR_ACT_Y) != null)) { final Coord coord = parseCoord( atts ); this.curract.setCoord(coord); } } else if ((atts.getValue(ATTR_ACT_X) != null) && (atts.getValue(ATTR_ACT_Y) != null)) { final Coord coord = parseCoord( atts ); this.curract = PopulationUtils.createAndAddActivityFromCoord(this.currplan, atts.getValue(ATTR_ACT_TYPE), coord); } else { throw new IllegalArgumentException("In this version of MATSim either the coords or the link must be specified for an Act."); } this.curract.setStartTime(Time.parseTime(atts.getValue(ATTR_ACT_STARTTIME))); this.curract.setMaximumDuration(Time.parseTime(atts.getValue(ATTR_ACT_MAXDUR))); this.curract.setEndTime(Time.parseTime(atts.getValue(ATTR_ACT_ENDTIME))); String fId = atts.getValue(ATTR_ACT_FACILITY); if (fId != null) { this.curract.setFacilityId(Id.create(fId, ActivityFacility.class)); } if (this.routeDescription != null) { finishLastRoute(); } }
private void startAct(final Attributes atts) { if (atts.getValue(ATTR_ACT_LINK) != null) { Id<Link> linkId = Id.create(atts.getValue(ATTR_ACT_LINK), Link.class); final Id<Link> linkId1 = linkId; this.curract = PopulationUtils.createAndAddActivityFromLinkId(this.currplan, atts.getValue(ATTR_ACT_TYPE), linkId1); if ((atts.getValue(ATTR_ACT_X) != null) && (atts.getValue(ATTR_ACT_Y) != null)) { final Coord coord = parseCoord( atts ); this.curract.setCoord(coord); } } else if ((atts.getValue(ATTR_ACT_X) != null) && (atts.getValue(ATTR_ACT_Y) != null)) { final Coord coord = parseCoord( atts ); this.curract = PopulationUtils.createAndAddActivityFromCoord(this.currplan, atts.getValue(ATTR_ACT_TYPE), coord); } else { throw new IllegalArgumentException("In this version of MATSim either the coords or the link must be specified for an Act."); } this.curract.setStartTime(Time.parseTime(atts.getValue(ATTR_ACT_STARTTIME))); this.curract.setMaximumDuration(Time.parseTime(atts.getValue(ATTR_ACT_MAXDUR))); this.curract.setEndTime(Time.parseTime(atts.getValue(ATTR_ACT_ENDTIME))); String fId = atts.getValue(ATTR_ACT_FACILITY); if (fId != null) { this.curract.setFacilityId(Id.create(fId, ActivityFacility.class)); } if (this.routeDescription != null) { finishLastRoute(); } }
private void startAct(final Attributes atts) { if (atts.getValue("zone") != null) { log.info("The attribute 'zone' of <act> will be ignored"); } Activity act; if (atts.getValue("link") != null) { Id<Link> linkId = Id.create(atts.getValue("link"), Link.class); final Id<Link> linkId1 = linkId; act = PopulationUtils.createAndAddActivityFromLinkId(this.currplan, atts.getValue("type"), linkId1); if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act.setCoord(coord); } } else if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act = PopulationUtils.createAndAddActivityFromCoord(this.currplan, atts.getValue("type"), coord); } else { throw new IllegalArgumentException("Either the coords or the link must be specified for an Act."); } act.setStartTime(Time.parseTime(atts.getValue("start_time"))); act.setMaximumDuration(Time.parseTime(atts.getValue("dur"))); act.setEndTime(Time.parseTime(atts.getValue("end_time"))); if (this.routeNodes != null) { this.currroute.setLinkIds(this.prevAct.getLinkId(), NetworkUtils.getLinkIds(RouteUtils.getLinksFromNodes(NetworkUtils.getNodes(this.network, this.routeNodes))), act.getLinkId()); this.routeNodes = null; this.currroute = null; } this.prevAct = act; }
private void startAct(final Attributes atts) { Activity act = null; if (atts.getValue("link") != null) { final Id<Link> linkId = Id.create(atts.getValue("link"), Link.class); act = PopulationUtils.createAndAddActivityFromLinkId(this.currplan, atts.getValue("type"), linkId); if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act.setCoord(coord); } } else if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act = PopulationUtils.createAndAddActivityFromCoord(this.currplan, atts.getValue("type"), coord); } else { throw new IllegalArgumentException("Either the coords or the link must be specified for an Act."); } act.setStartTime(Time.parseTime(atts.getValue("start_time"))); act.setMaximumDuration(Time.parseTime(atts.getValue("dur"))); act.setEndTime(Time.parseTime(atts.getValue("end_time"))); if (this.routeNodes != null) { this.currroute.setLinkIds(this.prevAct.getLinkId(), NetworkUtils.getLinkIds(RouteUtils.getLinksFromNodes(NetworkUtils.getNodes(this.network, this.routeNodes))), act.getLinkId()); this.routeNodes = null; this.currroute = null; } this.prevAct = act; }
public Activity getActivity() { Activity activity = PopulationUtils.createActivityFromCoordAndLinkId(type, coord.getCoord(), linkIdString == null ? null : Id.createLinkId(linkIdString)); activity.setEndTime(endTime); activity.setFacilityId(facIdString == null ? null : Id.create(facIdString, ActivityFacility.class)); activity.setMaximumDuration(maximumDuration); activity.setStartTime(startTime); return activity; } }
((Activity) pe).setMaximumDuration( Time.UNDEFINED_TIME ); ((Activity) pe).setEndTime( now > 0 ? now : 0 ); return;
act.setMaximumDuration( Time.UNDEFINED_TIME ) ; act.setMaximumDuration(Time.UNDEFINED_TIME) ;
private boolean doReplanning(MobsimAgent mobsimAgent, double time, Mobsim mobsim) { PlanAgent planAgent = (PlanAgent) mobsimAgent; Id<Person> agentId = planAgent.getCurrentPlan().getPerson().getId(); PlanElement currentPlanElement = WithinDayAgentUtils.getCurrentPlanElement(mobsimAgent); if (currentPlanElement instanceof Activity) { Activity act = (Activity) currentPlanElement; if (encounteredActivities.contains(act)) { return false; } CarrierDriverAgent driver = carrierAgentTracker.getDriver(agentId); TourActivity plannedActivity = (TourActivity) driver.getPlannedTourElement(WithinDayAgentUtils.getCurrentPlanElementIndex(mobsimAgent)); if (plannedActivity instanceof Start){ encounteredActivities.add(act); return false; } else { double newEndTime = Math.max(time, plannedActivity.getTimeWindow().getStart()) + plannedActivity.getDuration(); // logger.info("[agentId="+ agentId + "][currentTime="+Time.writeTime(time)+"][actDuration="+plannedActivity.getDuration()+ // "[timeWindow="+ plannedActivity.getTimeWindow() + "][plannedActEnd="+ Time.writeTime(act.getEndTime()) + "][newActEnd="+Time.writeTime(newEndTime)+"]"); act.setMaximumDuration(Time.UNDEFINED_TIME); act.setEndTime(newEndTime); // WithinDayAgentUtils.calculateAndSetDepartureTime(mobsimAgent, act); WithinDayAgentUtils.resetCaches( mobsimAgent ); WithinDayAgentUtils.rescheduleActivityEnd(mobsimAgent,mobsim); encounteredActivities.add(act); return true ; } } return true; } }
firstAct.setMaximumDuration( 0 ); driverTrip.add( firstAct ); secondAct.setMaximumDuration( 0 ); driverTrip.add( secondAct );
switch ( setting ) { case MUTATE_DUR: ((Activity) a).setMaximumDuration( mutateTime( a.getMaximumDuration() ) ); break; case MUTATE_END:
act.setMaximumDuration(act.getEndTime()); } else if (cnt == max) { double time = leg.getDepartureTime() + leg.getTravelTime(); act.setMaximumDuration(time - act.getStartTime());
@Override public void run(final Plan plan) { for ( Activity act : TripStructureUtils.getActivities( plan , blackList ) ) { // this is deliberately simplistic. Cleanup up of the time information should be done somewhere else. if ( !Time.isUndefinedTime( act.getEndTime() ) ) { act.setEndTime(mutateTime(act.getEndTime())); } if ( affectingDuration ) { if ( !Time.isUndefinedTime( act.getMaximumDuration() ) ) { act.setMaximumDuration(mutateTime(act.getMaximumDuration())); } } } // the legs are not doing anything. kai, jun'12 }
private static void copyPlanFieldsToFrom1(Plan planTarget, Plan planTemplate) { planTarget.setScore(planTemplate.getScore()); int actLegIndex = 0; for (PlanElement pe : planTarget.getPlanElements()) { if (pe instanceof Activity) { Activity actTemplate = ((Activity) planTemplate.getPlanElements().get(actLegIndex)); ((Activity) pe).setEndTime(actTemplate.getEndTime()); ((Activity) pe).setCoord(actTemplate.getCoord()); ((Activity) pe).setFacilityId(actTemplate.getFacilityId()); ((Activity) pe).setLinkId(actTemplate.getLinkId()); ((Activity) pe).setMaximumDuration(actTemplate.getMaximumDuration()); ((Activity) pe).setStartTime(actTemplate.getStartTime()); ((Activity) pe).setType(actTemplate.getType()); } else if (pe instanceof Leg) { Leg legTemplate = ((Leg)planTemplate.getPlanElements().get(actLegIndex)); Leg r = ((Leg) pe); r.setTravelTime( legTemplate.getDepartureTime() + legTemplate.getTravelTime() - r.getDepartureTime() ); ((Leg) pe).setDepartureTime(legTemplate.getDepartureTime()); ((Leg) pe).setMode(legTemplate.getMode()); ((Leg) pe).setRoute(legTemplate.getRoute()); ((Leg) pe).setTravelTime(legTemplate.getTravelTime()); } else throw new RuntimeException("Unexpected PlanElement type was found: " + pe.getClass().toString() + ". Aborting!"); actLegIndex++; } }
private static void copyPlanFieldsToFrom(Plan planTarget, LCPlan planTemplate) { planTarget.setScore(planTemplate.getScore()); int actLegIndex = 0; for (PlanElement pe : planTarget.getPlanElements()) { if (pe instanceof Activity) { LCActivity actTemplate = ((LCActivity) planTemplate.getPlanElements().get(actLegIndex)); ((Activity) pe).setEndTime(actTemplate.getEndTime()); ((Activity) pe).setCoord(actTemplate.getCoord()); ((Activity) pe).setFacilityId(actTemplate.getFacilityId()); ((Activity) pe).setLinkId(actTemplate.getLinkId()); ((Activity) pe).setMaximumDuration(actTemplate.getMaximumDuration()); ((Activity) pe).setStartTime(actTemplate.getStartTime()); ((Activity) pe).setType(actTemplate.getType()); } else if (pe instanceof Leg) { LCLeg legTemplate = ((LCLeg) planTemplate.getPlanElements().get(actLegIndex)); Leg r = ((Leg) pe); r.setTravelTime( legTemplate.getArrivalTime() - r.getDepartureTime() ); ((Leg) pe).setDepartureTime(legTemplate.getDepartureTime()); ((Leg) pe).setMode(legTemplate.getMode()); ((Leg) pe).setRoute(legTemplate.getRoute()); ((Leg) pe).setTravelTime(legTemplate.getTravelTime()); } else throw new RuntimeException("Unexpected PlanElement type was found: " + pe.getClass().toString() + ". Aborting!"); actLegIndex++; } }
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 ); }
act2.setMaximumDuration(8*60*60); plan.addActivity(act2);
PopulationUtils.createAndAddLeg( plan, TransportMode.transit_walk ); Activity ptAct1 = PopulationUtils.createAndAddActivityFromCoord(plan, PtConstants.TRANSIT_ACTIVITY_TYPE, new Coord((double) 0, (double) 100)); ptAct1.setMaximumDuration(0); PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); Activity ptAct2 = PopulationUtils.createAndAddActivityFromCoord(plan, PtConstants.TRANSIT_ACTIVITY_TYPE, new Coord((double) 0, (double) 100)); ptAct2.setMaximumDuration(0); PopulationUtils.createAndAddLeg( plan, TransportMode.transit_walk ); act = PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 500)); PopulationUtils.createAndAddLeg( plan, TransportMode.transit_walk ); Activity ptAct3 = PopulationUtils.createAndAddActivityFromCoord(plan, PtConstants.TRANSIT_ACTIVITY_TYPE, new Coord((double) 0, (double) 100)); ptAct3.setMaximumDuration(0); PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); Activity ptAct4 = PopulationUtils.createAndAddActivityFromCoord(plan, PtConstants.TRANSIT_ACTIVITY_TYPE, new Coord((double) 0, (double) 100)); ptAct4.setMaximumDuration(0); PopulationUtils.createAndAddLeg( plan, TransportMode.transit_walk ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 500));