/** * Creates a new TimeAllocationMutator with a mutation range as defined in * the configuration (module "TimeAllocationMutator", param "mutationRange"). */ @Deprecated public TimeAllocationMutator(Config config, Provider<TripRouter> tripRouterProvider, final double mutationRange, boolean affectingDuration) { super(config.global()); this.tripRouterProvider = tripRouterProvider; this.affectingDuration = affectingDuration; this.mutationRange = mutationRange; this.activityDurationInterpretation = (config.plans().getActivityDurationInterpretation()); this.personAttributes = null; this.subpopulationAttribute = null; this.subpopulationMutationRanges = null; this.subpopulationAffectingDuration = null; log.warn("deprecated constructor was used - individual time allocation mutator settings for subpopulations is not supported!"); }
@Inject public JDEQSimulation(final JDEQSimConfigGroup config, final Scenario scenario, final EventsManager events) { Road.setConfig(config); Message.setEventsManager(events); this.config = config; this.scenario = scenario; this.events = events; this.activityDurationInterpretation = this.scenario.getConfig().plans().getActivityDurationInterpretation(); }
@Override public boolean handleActivity(MobsimAgent agent) { // We expect all the agents to appear here at the beginning of the simulation (starting their // overnight activity.) That's when we enter them into JDEQSim and never let them out. new Vehicle(scheduler, ((HasPerson) agent).getPerson(), scenario.getConfig().plans().getActivityDurationInterpretation()); numberOfAgents++; return true; }
@Override public void install() { PlansConfigGroup.ActivityDurationInterpretation actDurInterpr = getConfig().plans().getActivityDurationInterpretation() ; if ( actDurInterpr != PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime || getConfig().plans().isRemovingUnneccessaryPlanAttributes() ) { addControlerListenerBinding().to(VspPlansCleaner.class); } } }
/** * Creates a new TimeAllocationMutator with a mutation range as defined in * the configuration (module "TimeAllocationMutator", param "mutationRange"). */ public TripTimeAllocationMutator(Config config, Provider<TripRouter> tripRouterProvider) { super(config.global()); this.tripRouterProvider = tripRouterProvider; this.mutationRange = config.timeAllocationMutator().getMutationRange() ; this.affectingDuration = config.timeAllocationMutator().isAffectingDuration() ; PlansConfigGroup.ActivityDurationInterpretation actDurInterpr = ( config.plans().getActivityDurationInterpretation() ) ; if ( actDurInterpr == PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime ) { useActivityDurations = true ; } else if ( actDurInterpr == PlansConfigGroup.ActivityDurationInterpretation.endTimeOnly ) { useActivityDurations = false ; } else if ( actDurInterpr == PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration ) { throw new UnsupportedOperationException( "need to clarify the correct setting here. Probably not a big deal, but not done yet. kai, aug'10") ; } else { throw new IllegalStateException( "beahvior not defined for this configuration setting") ; } }
public TimeAllocationMutator(Provider<TripRouter> tripRouterProvider, PlansConfigGroup plansConfigGroup, TimeAllocationMutatorConfigGroup timeAllocationMutatorConfigGroup, GlobalConfigGroup globalConfigGroup, final Population population) { super(globalConfigGroup); this.tripRouterProvider = tripRouterProvider; this.activityDurationInterpretation = plansConfigGroup.getActivityDurationInterpretation(); this.mutationRange = timeAllocationMutatorConfigGroup.getMutationRange(); this.affectingDuration = timeAllocationMutatorConfigGroup.isAffectingDuration(); // in case we have subpopulations and individual settings for them if (plansConfigGroup.getSubpopulationAttributeName() != null && timeAllocationMutatorConfigGroup.isUseIndividualSettingsForSubpopulations() && population != null) { this.subpopulationAttribute = plansConfigGroup.getSubpopulationAttributeName(); this.subpopulationMutationRanges = new HashMap<>(); this.subpopulationAffectingDuration = new HashMap<>(); this.personAttributes = population.getPersonAttributes(); Collection<? extends ConfigGroup> settings = timeAllocationMutatorConfigGroup.getParameterSets(TimeAllocationMutatorSubpopulationSettings.SET_NAME); for (ConfigGroup group : settings) { TimeAllocationMutatorSubpopulationSettings subpopulationSettings = (TimeAllocationMutatorSubpopulationSettings) group; String subpopulation = subpopulationSettings.getSubpopulation(); this.subpopulationMutationRanges.put(subpopulation, subpopulationSettings.getMutationRange()); this.subpopulationAffectingDuration.put(subpopulation, subpopulationSettings.isAffectingDuration()); log.info("Found individual time mutator settings for subpopulation: " + subpopulation); } } else { this.personAttributes = null; this.subpopulationAttribute = null; this.subpopulationMutationRanges = null; this.subpopulationAffectingDuration = null; } }
/** * If this method is called to update a changed ActivityEndTime please * ensure that the ActivityEndsList in the {@link QSim} is also updated. */ private final void calculateAndSetDepartureTime(Activity act) { PlansConfigGroup.ActivityDurationInterpretation activityDurationInterpretation = this.getScenario().getConfig().plans().getActivityDurationInterpretation(); double now = this.getSimTimer().getTimeOfDay() ; double departure = ActivityDurationUtils.calculateDepartureTime(act, now, activityDurationInterpretation); if ( this.getCurrentPlanElementIndex() == this.getCurrentPlan().getPlanElements().size()-1 ) { if ( finalActHasDpTimeWrnCnt < 1 && departure!=Double.POSITIVE_INFINITY ) { log.error( "last activity of person driver agent id " + this.getId() + " has end time < infty; setting it to infty") ; log.error( Gbl.ONLYONCE ) ; finalActHasDpTimeWrnCnt++ ; } departure = Double.POSITIVE_INFINITY ; } this.activityEndTime = departure ; }
/** * Computes the (expected or planned) activity end time, depending on the configured time interpretation. */ public static double getActivityEndTime( Activity act, double now, Config config ) { switch ( config.plans().getActivityDurationInterpretation() ) { case endTimeOnly: return act.getEndTime() ; case tryEndTimeThenDuration: if ( act.getEndTime() != Time.UNDEFINED_TIME ) { return act.getEndTime() ; } else if ( act.getMaximumDuration() != Time.UNDEFINED_TIME ) { return now + act.getMaximumDuration() ; } else { return Time.UNDEFINED_TIME ; } case minOfDurationAndEndTime: return Math.min( now + act.getMaximumDuration() , act.getEndTime() ) ; default: break ; } return Time.UNDEFINED_TIME ; }
PlansConfigGroup.ActivityDurationInterpretation actDurInterpr = config.plans().getActivityDurationInterpretation() ; if ( actDurInterpr == PlansConfigGroup.ActivityDurationInterpretation.endTimeOnly ) { problem = true; System.out.flush() ; log.error("You are using " + config.plans().getActivityDurationInterpretation() + " as activityDurationInterpretation in " + "conjunction with the matsim transit module. This is not working at all as pt interaction activities never have an end time and " + "thus will never end!"); problem = true ; System.out.flush() ; log.log( lvl, "You are using ActivityDurationInterpretation " + config.plans().getActivityDurationInterpretation() + " ; vsp default is to use " + PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration + "This means you have to add the following lines into the vspExperimental section of your config file: ") ;
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { PlansConfigGroup.ActivityDurationInterpretation actDurInterp = (plansConfigGroup.getActivityDurationInterpretation() ) ; for ( Person person : population.getPersons().values() ) {
final PlansConfigGroup.ActivityDurationInterpretation actDurInterpr = ( config.plans().getActivityDurationInterpretation() ) ; switch ( actDurInterpr ) { case tryEndTimeThenDuration: default: throw new RuntimeException("activity duration interpretation of " + config.plans().getActivityDurationInterpretation().toString() + " is not supported for locationchoice; aborting ... " + "Use " + PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration.toString() + "instead.") ;