public void addModeParams(final ModeParams params) { final ModeParams previous = this.getModes().get(params.getMode()); if (previous != null) { final boolean removed = removeParameterSet(previous); if (!removed) throw new RuntimeException("problem replacing mode params "); log.info("mode parameters for mode " + previous.getMode() + " were just overwritten."); } super.addParameterSet(params); }
@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 Map<String, ModeParams> getModes() { @SuppressWarnings("unchecked") final Collection<ModeParams> modes = (Collection<ModeParams>) getParameterSets(ModeParams.SET_TYPE); final Map<String, ModeParams> map = new LinkedHashMap<>(); for (ModeParams pars : modes) { if (this.isLocked()) { pars.setLocked(); } map.put(pars.getMode(), pars); } if (this.isLocked()) { return Collections.unmodifiableMap(map); } else { return map; } }
problem = true ; System.out.flush() ; log.error("found monetary distance rate for mode " + params.getMode() + " > 0. You probably want a value < 0 here.\n" ) ; log.error("found monetary distance rate for mode " + params.getMode() + " < -0.01. -0.01 per meter means -10 per km. You probably want to divide your value by 1000." ) ;
final String mode = initialSettings.getMode(); final ModeParams inputSettings = inputConfigGroup.getModes().get( mode ); Assert.assertEquals(
comparisonPSet = ((PlanCalcScoreConfigGroup) comparisonModule).getOrCreateScoringParameters(((ScoringParameterSet) pSet).getSubpopulation()); } else if ( pSet instanceof ModeParams ) { comparisonPSet = ((ScoringParameterSet) comparisonModule).getOrCreateModeParams(((ModeParams) pSet).getMode()); } else if ( pSet instanceof ActivityParams ) { comparisonPSet = ((ScoringParameterSet) comparisonModule).getOrCreateActivityParams(((ActivityParams) pSet).getActivityType());
final String mode = settings.getMode(); module.addParam( "constant_"+mode , ""+settings.getConstant() ); module.addParam( "marginalUtlOfDistance_"+mode , ""+settings.getMarginalUtilityOfDistance() );
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 ; }