private void readPrefs() { String prefsFileName = this.dccg.getPrefsFile(); if (prefsFileName != null) { ObjectAttributesXmlReader prefsReader = new ObjectAttributesXmlReader(this.prefsAttributes); try { prefsReader.readFile(prefsFileName); log.info("reading prefs attributes from: \n"+ prefsFileName); } catch (UncheckedIOException e) { // reading was not successful log.error("unsuccessful prefs reading from files!\n" + prefsFileName); } } else { log.warn("prefs are taken from the config and if available from the desires as there is no preferences file specified \n"); for (ActivityParams activityParams : this.scenario.getConfig().planCalcScore().getActivityParams()) { for (Person p : this.scenario.getPopulation().getPersons().values()) { prefsAttributes.putAttribute(p.getId().toString(), "typicalDuration_" + activityParams.getActivityType(), activityParams.getTypicalDuration()); prefsAttributes.putAttribute(p.getId().toString(), "latestStartTime_" + activityParams.getActivityType(), activityParams.getLatestStartTime()); prefsAttributes.putAttribute(p.getId().toString(), "earliestEndTime_" + activityParams.getActivityType(), activityParams.getEarliestEndTime()); prefsAttributes.putAttribute(p.getId().toString(), "minimalDuration_" + activityParams.getActivityType(), activityParams.getMinimalDuration()); } } } }
if (params.isScoringThisActivityAtAll() && Time.isUndefinedTime(params.getTypicalDuration())) { throw new RuntimeException("In activity type=" + params.getActivityType() + ", the typical duration is undefined. This will lead to errors that are difficult to debug, "
public static double getTypicalDuration( final Scenario scenario, final Person person, final String type ) { final Double typicalDuration = (Double) scenario.getPopulation().getPersonAttributes().getAttribute( person.getId().toString(), "typicalDuration_"+type ); if ( typicalDuration != null ) return typicalDuration.doubleValue(); final ActivityParams params = scenario.getConfig().planCalcScore().getActivityParams( type ); if ( params == null ) { //throw new RuntimeException( "could not find typical duration for Person "+person.getId()+" for type "+type ); // not that nice, but needed for agents that might not have a preference. BeingTogetherScoring knows how to handle that return Double.NEGATIVE_INFINITY; } return params.getTypicalDuration(); }
Assert.assertEquals( "wrong typicalDuration "+msg, initialSettings.getTypicalDuration(), inputSettings.getTypicalDuration(), 1e-7 );
double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration() ; double priority = 1. ;
double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration() ; double priority = 1. ;
double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration() ; double priority = 1. ;
double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration() ; double priority = 1. ;
final double typicalDuration_work_sec = wParams.getTypicalDuration(); final double zeroUtilityDuration_work_sec = 3600. * getZeroUtilDuration_hrs(typicalDuration_work_sec/3600., 1. ); double slope_work_at_zero_utility_h = perf_hrs * typicalDuration_work_sec / zeroUtilityDuration_work_sec ;
module.addParam( "activityOpeningTime_"+suffix , ""+settings.getOpeningTime() ); module.addParam( "activityPriority_"+suffix , ""+settings.getPriority() ); module.addParam( "activityTypicalDuration_"+suffix , ""+settings.getTypicalDuration() );
/** * Convenience constructor for main use case */ public Builder(ActivityParams ppp ) { this.type = ppp.getActivityType() ; this.priority = ppp.getPriority() ; this.typicalDuration_s = ppp.getTypicalDuration() ; this.closingTime = ppp.getClosingTime() ; this.earliestEndTime = ppp.getEarliestEndTime() ; this.latestStartTime = ppp.getLatestStartTime() ; this.minimalDuration = ppp.getMinimalDuration() ; this.openingTime = ppp.getOpeningTime() ; this.scoreAtAll = ppp.isScoringThisActivityAtAll() ; switch( ppp.getTypicalDurationScoreComputation() ) { case relative: this.zeroUtilityComputation = new SameRelativeScore() ; break; case uniform: this.zeroUtilityComputation = new SameAbsoluteScore() ; break; default: throw new RuntimeException("not defined"); } // seems to be somewhat overkill to set a computation method that is only used in the builder ... but the builder has a method to // (re)set the }
/** * {@value TYPICAL_DURATION_CMT} */ @StringGetter(TYPICAL_DURATION) private String getTypicalDurationString() { return Time.writeTime(getTypicalDuration()); }