21 package org.matsim.core.config.groups;
33 import java.util.Collection;
51 private static final String
MODULE =
"Module_";
66 public static final String
SET_NAME =
"strategysettings";
88 Map<String,String> map = super.getComments();
93 StringBuilder sels =
new StringBuilder() ;
106 StringBuilder strats =
new StringBuilder() ;
119 map.put(
"strategyName",
120 "strategyName of strategy. Possible default names: " + sels +
" (selectors), " + strats +
" (innovative strategies)." );
122 "weight of a strategy: for each agent, a strategy will be selected with a probability proportional to its weight");
123 map.put(
"disableAfterIteration",
124 "iteration after which strategy will be disabled. most useful for ``innovative'' strategies (new routes, new times, ...). " 125 +
"Normally, better use fractionOfIterationsToDisableInnovation");
126 map.put(
"executionPath",
127 "path to external executable (if applicable)" ) ;
128 map.put(
"subpopulation",
129 "subpopulation to which the strategy applies. \"null\" refers to the default population, that is, the set of persons for which no explicit subpopulation is defined (ie no subpopulation attribute)" ) ;
136 super.checkConsistency(config);
214 if ( key.startsWith(
MODULE)
219 throw new IllegalArgumentException(
"getting underscored parameter "+key+
" is not allowed anymore. The supported way to get those parameters is via parameter sets." );
226 public void addParam(
final String key,
final String value) {
228 if (key != null && key.startsWith(
MODULE)) {
230 settings.
addParam(
"strategyName" , value);
234 settings.
addParam(
"weight" , value );
239 settings.
addParam(
"disableAfterIteration" , value );
243 settings.
addParam(
"executionPath" , value );
247 settings.
addParam(
"subpopulation" , value );
260 if ( !s.getId().equals( index ) )
continue;
261 if ( settings != null )
throw new IllegalStateException(
"several settings with id "+index );
265 if (settings == null && createIfMissing) {
277 Map<String,String> map = super.getComments();
278 map.put(
ReflectiveDelegate.ITERATION_FRACTION_TO_DISABLE_INNOVATION,
"fraction of iterations where innovative strategies are switched off. Something like 0.8 should be good. E.g. if you run from iteration 400 to iteration 500, innovation is switched off at iteration 480" ) ;
279 map.put(
ReflectiveDelegate.MAX_AGENT_PLAN_MEMORY_SIZE,
"maximum number of plans per agent. ``0'' means ``infinity''. Currently (2010), ``5'' is a good number");
281 StringBuilder strb =
new StringBuilder() ;
283 strb.append(
name.toString() +
" " ) ;
285 map.put(
ReflectiveDelegate.PLAN_SELECTOR_FOR_REMOVAL,
"strategyName of PlanSelector for plans removal. " 286 +
"Possible defaults: " + strb.toString() +
". The current default, WorstPlanSelector is not a good " +
287 "choice from a discrete choice theoretical perspective. Alternatives, however, have not been systematically " +
288 "tested. kai, feb'12") ;
290 map.put(
ReflectiveDelegate.EXTERNAL_EXE_CONFIG_TEMPLATE,
"the external executable will be called with a config file as argument. This is the pathname to a possible " 291 +
"skeleton config, to which additional information will be added. Can be null.");
292 map.put(
ReflectiveDelegate.EXTERNAL_EXE_TMP_FILE_ROOT_DIR,
"root directory for temporary files generated by the external executable. Provided as a service; " 293 +
"I don't think this is used by MATSim.") ;
294 map.put(
ReflectiveDelegate.EXTERNAL_EXE_TIME_OUT,
"time out value (in seconds) after which matsim will consider the external strategy as failed") ;
303 throw new RuntimeException(
set+
" is not an instance of StrategySettings" );
307 throw new IllegalArgumentException(
"unknown set type "+
set.
getName() );
317 throw new IllegalArgumentException(
"unknown set type "+type );
347 super.checkConsistency(config);
387 switch ( planSelectorForRemoval ) {
388 case "SelectExpBeta" :
389 throw new RuntimeException(
"'SelectExpBeta' was replaced by 'SelectExpBetaForRemoval' in the plans removal setting" ) ;
390 case "ChangeExpBeta" :
391 throw new RuntimeException(
"'ChangeExpBeta' was replaced by 'ChangeExpBetaForRemoval' in the plans removal setting" ) ;
392 case "PathSizeLogitSelector" :
393 throw new RuntimeException(
"'PathSizeLogitSelector' was replaced by 'PathSizeLogitSelectorForRemoval' in the plans removal setting" ) ;
413 static final String MAX_AGENT_PLAN_MEMORY_SIZE =
"maxAgentPlanMemorySize";
414 static final String EXTERNAL_EXE_CONFIG_TEMPLATE =
"ExternalExeConfigTemplate";
415 static final String EXTERNAL_EXE_TMP_FILE_ROOT_DIR =
"ExternalExeTmpFileRootDir";
416 static final String EXTERNAL_EXE_TIME_OUT =
"ExternalExeTimeOut";
417 static final String ITERATION_FRACTION_TO_DISABLE_INNOVATION =
"fractionOfIterationsToDisableInnovation" ;
418 static final String PLAN_SELECTOR_FOR_REMOVAL =
"planSelectorForRemoval" ;
420 private int maxAgentPlanMemorySize = 5;
421 private String externalExeConfigTemplate = null;
422 private String externalExeTmpFileRootDir = null;
423 private long externalExeTimeOut = 3600;
425 private String planSelectorForRemoval =
"WorstPlanSelector";
428 private double fraction = Double.POSITIVE_INFINITY ;
438 this.maxAgentPlanMemorySize = maxAgentPlanMemorySize;
443 return this.maxAgentPlanMemorySize;
448 this.externalExeConfigTemplate = externalExeConfigTemplate;
453 return this.externalExeConfigTemplate;
458 this.externalExeTmpFileRootDir = externalExeTmpFileRootDir;
463 return this.externalExeTmpFileRootDir;
468 this.externalExeTimeOut = externalExeTimeOut;
473 return this.externalExeTimeOut;
478 return planSelectorForRemoval;
483 this.planSelectorForRemoval = planSelectorForRemoval;
486 @
StringGetter( ITERATION_FRACTION_TO_DISABLE_INNOVATION )
491 @
StringSetter( ITERATION_FRACTION_TO_DISABLE_INNOVATION )
493 this.fraction = fraction;
double getFractionOfIterationsToDisableInnovation()
int getMaxAgentPlanMemorySize()
String getExternalExeTmpFileRootDir()
static Random getRandom()
static final String SET_NAME
StrategySettings getStrategySettings(final Id< StrategySettings > index, final boolean createIfMissing)
String TimeAllocationMutator_ReRoute
void addParameterSet(final ConfigGroup set)
void addParam(final String key, final String value)
final Map< String, String > getParams()
void checkConsistency(Config config)
String getExternalExeConfigTemplate()
String ChangeSingleTripMode
final Collection<? extends ConfigGroup > clearParameterSetsForType(final String type)
Id< StrategySettings > getId()
StrategySettings setWeight(final double probability)
String getPlanSelectorForRemoval()
void setFractionOfIterationsToDisableInnovation(double fraction)
StrategySettings setDisableAfter(final int disableAfter)
void setExternalExeConfigTemplate(final String externalExeConfigTemplate)
void checkConsistency(Config config)
void setPlanSelectorForRemoval(String planSelectorForRemoval)
void setMaxAgentPlanMemorySize(int maxAgentPlanMemorySize)
void setExternalExeTimeOut(long externalExeTimeOut)
static final String MODULE
String SelectPathSizeLogit
final Map< String, String > getComments()
static final String MODULE_SUBPOPULATION
void setExternalExeConfigTemplate(String externalExeConfigTemplate)
void setExternalExeTmpFileRootDir(String externalExeTmpFileRootDir)
static< T > Id< T > create(final long key, final Class< T > type)
void addStrategySettings(final StrategySettings stratSets)
Id< StrategySettings > id
long getExternalExeTimeOut()
final Map< String, String > getParams()
final void clearStrategySettings()
StrategySettings setStrategyName(final String name)
Collection< StrategySettings > getStrategySettings()
final Map< String, String > getComments()
StrategySettings(final Id< StrategySettings > id)
final ReflectiveDelegate delegate
static final String MODULE_EXE_PATH
String getExternalExeTmpFileRootDir()
int getMaxAgentPlanMemorySize()
ConfigGroup createParameterSet(final String type)
final String getValue(final String param_name)
static final String GROUP_NAME
String getPlanSelectorForRemoval()
StrategySettings setSubpopulation(final String subpopulation)
final Map< String, ? extends Collection<? extends ConfigGroup > > getParameterSets()
long getExternalExeTimeOut()
StrategySettings setExePath(final String exePath)
void checkParameterSet(final ConfigGroup set)
final void addParam(final String param_name, final String value)
String getExternalExeConfigTemplate()
void setPlanSelectorForRemoval(String planSelectorForRemoval)
double getFractionOfIterationsToDisableInnovation()
static final String MODULE_PROBABILITY
String getValue(final String key)
void setFractionOfIterationsToDisableInnovation(double fraction)
void setExternalExeTmpFileRootDir(final String externalExeTmpFileRootDir)
String TimeAllocationMutator
static final String MODULE_DISABLE_AFTER_ITERATION
void setExternalExeTimeOut(final long externalExeTimeOut)
String getSubpopulation()
void setMaxAgentPlanMemorySize(final int maxAgentPlanMemorySize)