public Map<String, ActivityParams> getActivityParamsPerType() { final Map<String, ActivityParams> map = new LinkedHashMap<>(); for (ActivityParams pars : getActivityParams()) { map.put(pars.getActivityType(), pars); } return map; }
@Override protected void checkParameterSet(final ConfigGroup module) { switch (module.getName()) { case ActivityParams.SET_TYPE: if (!(module instanceof ActivityParams)) { throw new RuntimeException("wrong class for " + module); } final String t = ((ActivityParams) module).getActivityType(); if (getActivityParams(t) != null) { throw new IllegalStateException("already a parameter set for activity type " + t); } break; case ModeParams.SET_TYPE: if (!(module instanceof ModeParams)) { throw new RuntimeException("wrong class for " + module); } final String m = ((ModeParams) module).getMode(); if (getModes().get(m) != null) { throw new IllegalStateException("already a parameter set for mode " + m); } break; default: throw new IllegalArgumentException(module.getName()); } }
public void addActivityParams(final ActivityParams params) { final ActivityParams previous = this.getActivityParams(params.getActivityType()); if (previous != null) { if (previous.getActivityType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) { log.error("ERROR: Activity parameters for activity type " + previous.getActivityType() + " were just overwritten. This happens most " + "likely because you defined them in the config file and the Controler overwrites them. Or the other way " + "round. pt interaction has problems, but doing what you are doing here will just cause " + "other (less visible) problem. Please take the effort to discuss with the core team " + "what needs to be done. kai, nov'12"); } else { log.info("activity parameters for activity type " + previous.getActivityType() + " were just overwritten."); } final boolean removed = removeParameterSet(previous); if (!removed) throw new RuntimeException("problem replacing activity params "); } super.addParameterSet(params); }
if ( PtConstants.TRANSIT_ACTIVITY_TYPE.equals( params.getActivityType() ) ) { case uniform: log.log( lvl, "found `typicalDurationScoreComputation == uniform' for activity type " + params.getActivityType() + "; vsp should use `relative'. ") ; break; default:
final ActivityParams inputSettings = inputConfigGroup.getActivityParams( initialSettings.getActivityType() ); Assert.assertEquals( "wrong type "+msg, initialSettings.getActivityType(), inputSettings.getActivityType() ); Assert.assertEquals( "wrong closingTime "+msg,
comparisonPSet = ((ScoringParameterSet) comparisonModule).getOrCreateModeParams(((ModeParams) pSet).getMode()); } else if ( pSet instanceof ActivityParams ) { comparisonPSet = ((ScoringParameterSet) comparisonModule).getOrCreateActivityParams(((ActivityParams) pSet).getActivityType()); } else if ( pSet instanceof ModeRoutingParams ) { comparisonPSet = ((PlansCalcRouteConfigGroup) comparisonModule).getOrCreateModeRoutingParams(((ModeRoutingParams) pSet).getMode()) ;
for (ActivityParams params : scoringParameterSet.getActivityParams()) { ActivityUtilityParameters.Builder factory = new ActivityUtilityParameters.Builder(params) ; utilParams.put(params.getActivityType(), factory ) ;
throw new RuntimeException("In activity type=" + params.getActivityType() + ", the typical duration is undefined. This will lead to errors that are difficult to debug, " + "so rather aborting here.");
throw new RuntimeException("Scoring " + ptAct.getActivityType() + " is not allowed because it breaks pt scoring." + " If you need this anyway (for backwards compatibility reasons), you can allow this by a parameter in VspExperimentalConfigGroup.") ;
int ca = 0; for ( ActivityParams settings : initialGroup.getActivityParams() ) { final String suffix = r.nextBoolean() ? ""+ca++ : settings.getActivityType(); if ( !suffix.equals( settings.getActivityType() ) ) { module.addParam( "activityType_"+suffix , ""+settings.getActivityType() );
private static boolean sameType(ConfigGroup pSet, ConfigGroup cg) { if ( ! ( pSet.getName().equals( cg.getName() ) ) ) { return false; } if ( pSet instanceof ModeRoutingParams ) { // (these are the "teleportedRouteParameters" in config.xml) if ( ((ModeRoutingParams)pSet).getMode().equals( ((ModeRoutingParams)cg).getMode() ) ) { return true ; } } if ( pSet instanceof ScoringParameterSet ) { return true ; } if ( pSet instanceof ModeParams ) { if ( ((ModeParams)pSet).getMode().equals( ((ModeParams)cg).getMode() ) ) { return true ; } } if ( pSet instanceof ActivityParams ) { if ( ((ActivityParams)pSet).getActivityType().equals( ((ActivityParams)cg).getActivityType() ) ) { return true ; } } if ( pSet instanceof StrategySettings ) { return true ; // yy this will not work since there is no corresponding default entry! kai, may'18 } return false ; }
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()); } } } }
/** * 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 }