@Override public final Map<String, String> getComments() { Map<String,String> map = super.getComments(); map.put(BEELINE_DISTANCE_FACTOR, "factor with which beeline distances (and therefore times) " + "are multiplied in order to obtain an estimate of the network distances/times. Default is something like 1.3") ; map.put(NETWORK_MODES, "All the modes for which the router is supposed to generate network routes (like car)") ; map.put(RANDOMNESS, "strength of the randomness for the utility of money in routing under toll. " + "Leads to Pareto-optimal route with randomly drawn money-vs-other-attributes tradeoff. " + "Technically the width parameter of a log-normal distribution. 3.0 seems to be a good value. " ) ; return map; }
public URL getDetailedColdEmissionFactorsFileURL(URL context) { return ConfigGroup.getInputFileURL(context, this.detailedColdEmissionFactorsFile); }
@Override protected void checkParameterSet( final ConfigGroup module ) { switch ( module.getName() ) { case ModeRoutingParams.SET_TYPE: if ( !(module instanceof ModeRoutingParams) ) { throw new RuntimeException( "unexpected class for module "+module ); } break; default: throw new IllegalArgumentException( module.getName() ); } }
public void addParameterSet(final ConfigGroup set) { checkParameterSet( set ); Collection<ConfigGroup> parameterSets = parameterSetsPerType.get( set.getName() ); if ( parameterSets == null ) { parameterSets = new ArrayList<>(); parameterSetsPerType.put( set.getName() , parameterSets ); } parameterSets.add( set ); }
@Override public final String toString() { StringBuilder str = new StringBuilder(); for ( Entry<String, String> entry : this.getParams().entrySet() ) { str.append('['); str.append(entry.getKey()); str.append('='); str.append(entry.getValue()); str.append(']'); } return "[name=" + this.getName() + "]" + "[nOfParams=" + this.getParams().size() + "]" + str.toString(); }
@Override void writeModule(final ConfigGroup module, final BufferedWriter out) throws UncheckedIOException { Map<String, String> params = module.getParams(); Map<String, String> comments = module.getComments(); out.write(" name=\"" + module.getName() + "\" >"); out.write(this.newline);
final ConfigGroup module, final ConfigGroup comparisonModule ) { Map<String, String> params = module.getParams(); Map<String, String> comments = module.getComments();
private Config createTestConfig() { final Config c = ConfigUtils.createConfig(); final ConfigGroup module = new ConfigGroup( "thisAintNoFlat" ); module.addParam( "someParam" , "someValue" ); module.addParam( "anotherParam" , "anotherValue" ); final ConfigGroup paramSet1 = module.createParameterSet( "oneType" ); module.addParameterSet( paramSet1 ); paramSet1.addParam( "something" , "gloups" ); final ConfigGroup paramSet2 = module.createParameterSet( "oneType" ); module.addParameterSet( paramSet2 ); paramSet2.addParam( "something" , "gloups" ); paramSet2.addParam( "something_else" , "glips" ); final ConfigGroup paramSet3 = module.createParameterSet( "anotherType" ); module.addParameterSet( paramSet3 ); paramSet3.addParam( "niark" , "niourk" ); c.addModule( module ); return c; } }
private Boolean processParameterSets(BufferedWriter writer, String indent, String moduleTag, String moduleNameAtt, String moduleName, ConfigGroup module, ConfigGroup comparisonModule, Boolean headerHasBeenWritten) throws IOException { for ( Entry<String, ? extends Collection<? extends ConfigGroup>> entry : module.getParameterSets().entrySet() ) { Collection<? extends ConfigGroup> comparisonSets = new ArrayList<>() ; if ( comparisonModule != null ) { comparisonSets = comparisonModule.getParameterSets(entry.getKey()); }; for ( ConfigGroup pSet : entry.getValue() ) { comparisonPSet = new ConfigGroup(pSet.getName()) ;
@Test public void testBehaviorWhenAcceptingUnknownParameters() { final ConfigGroup testee = new ReflectiveConfigGroup( "name" , true ) { @StringSetter( "field" ) public void setStuff(String s) {} @StringGetter( "field" ) public Object getStuff() { return null; } }; final String param = "my unknown param"; final String value = "my val"; testee.addParam( param , value ); Assert.assertEquals( "unexpected stored value", value, testee.getValue( param ) ); }
private ConfigGroup toUnderscoredModule(final StrategyConfigGroup initialGroup) { // yyyy is this method/this execution path still necessary? Maybe we need to be able to read config v1, but certainly // we don't need to WRITE it, do we? kai/mz, nov'15 final ConfigGroup module = new ConfigGroup( initialGroup.getName() ); for ( Map.Entry<String, String> e : initialGroup.getParams().entrySet() ) { log.info( "add param "+e.getKey() ); module.addParam( e.getKey() , e.getValue() ); } for ( StrategySettings settings : initialGroup.getStrategySettings() ) { final Id<StrategySettings> id = settings.getId(); module.addParam( "Module_"+id , settings.getStrategyName() ); module.addParam( "ModuleProbability_"+id , ""+settings.getWeight() ); module.addParam( "ModuleDisableAfterIteration_"+id , ""+settings.getDisableAfter() ); module.addParam( "ModuleExePath_"+id , settings.getExePath() ); module.addParam( "ModuleSubpopulation_"+id , settings.getSubpopulation() ); } return module; }
@Override public final Map<String, String> getParams() { Map<String, String> params = super.getParams(); return params; }
@Override public void addParameterSet(final ConfigGroup set) { if ( set.getName().equals( ModeRoutingParams.SET_TYPE ) && !this.acceptModeParamsWithoutClearing ) { clearParameterSetsForType( set.getName() ); this.acceptModeParamsWithoutClearing = true; } ModeRoutingParams pars = (ModeRoutingParams) set ; // for the time being pushing the "global" factor into the local ones if they are not initialized by // themselves. Necessary for some tests; maybe we should eventually disable them. kai, feb'15 if ( pars.getBeelineDistanceFactor()== null ) { pars.setBeelineDistanceFactor( this.beelineDistanceFactor ); } super.addParameterSet( set ); }
outModule.getParams(), inModule.getParams() ); outModule.getParameterSets().keySet(), inModule.getParameterSets().keySet() ); for ( String type : outModule.getParameterSets().keySet() ) { final Collection<? extends ConfigGroup> outSets = outModule.getParameterSets( type ); final Collection<? extends ConfigGroup> inSets = inModule.getParameterSets( type );
private void startParameter(final Attributes atts) { moduleStack.getFirst().addParam( atts.getValue( NAME ), atts.getValue( VALUE ) ); }
@Override public void endTag( final String name, final String content, final Stack<String> context) { if ( name.equals( MODULE ) || name.equals( PARAMETER_SET ) ) { final ConfigGroup head = moduleStack.removeFirst(); if ( !moduleStack.isEmpty() ) moduleStack.getFirst().addParameterSet( head ); } } }
/** * Override if parameter sets of a certain type need a special implementation */ @SuppressWarnings("static-method") public ConfigGroup createParameterSet(final String type) { return new ConfigGroup( type ); }
private void startParameterSet(final Attributes atts) { final ConfigGroup m = moduleStack.getFirst().createParameterSet( atts.getValue( TYPE ) ); moduleStack.addFirst( m ); }