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. If the ReplanningAnnealer is used, it will also be switched off." ) ;
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;
void setExternalExeConfigTemplate(final String externalExeConfigTemplate)
static final String MODULE_SUBPOPULATION
static final String MODULE_PROBABILITY
void checkConsistency(Config config)
static final String MODULE_EXE_PATH
String getSubpopulation()
String getValue(final String key)
static final String GROUP_NAME
void setPlanSelectorForRemoval(String planSelectorForRemoval)
String getPlanSelectorForRemoval()
static Random getRandom()
String TimeAllocationMutator_ReRoute
void addParameterSet(final ConfigGroup set)
String getExternalExeTmpFileRootDir()
long getExternalExeTimeOut()
String ChangeSingleTripMode
final Collection<? extends ConfigGroup > clearParameterSetsForType(final String type)
double getFractionOfIterationsToDisableInnovation()
void setMaxAgentPlanMemorySize(final int maxAgentPlanMemorySize)
void setFractionOfIterationsToDisableInnovation(double fraction)
void addParam(final String key, final String value)
int getMaxAgentPlanMemorySize()
StrategySettings setStrategyName(final String name)
StrategySettings setSubpopulation(final String subpopulation)
StrategySettings setExePath(final String exePath)
void checkParameterSet(final ConfigGroup set)
void setExternalExeTmpFileRootDir(String externalExeTmpFileRootDir)
Id< StrategySettings > getId()
String SelectPathSizeLogit
int getMaxAgentPlanMemorySize()
String getPlanSelectorForRemoval()
final void clearStrategySettings()
static< T > Id< T > create(final long key, final Class< T > type)
StrategySettings setWeight(final double probability)
final Map< String, String > getParams()
void checkConsistency(Config config)
void setMaxAgentPlanMemorySize(int maxAgentPlanMemorySize)
ConfigGroup createParameterSet(final String type)
String getExternalExeConfigTemplate()
static final String MODULE_DISABLE_AFTER_ITERATION
final Map< String, String > getComments()
final String getValue(final String param_name)
long getExternalExeTimeOut()
Collection< StrategySettings > getStrategySettings()
final Map< String, ? extends Collection<? extends ConfigGroup > > getParameterSets()
void setExternalExeTimeOut(long externalExeTimeOut)
Id< StrategySettings > id
final void addParam(final String param_name, final String value)
double getFractionOfIterationsToDisableInnovation()
void setExternalExeTmpFileRootDir(final String externalExeTmpFileRootDir)
StrategySettings setDisableAfter(final int disableAfter)
final ReflectiveDelegate delegate
String getExternalExeConfigTemplate()
void setExternalExeConfigTemplate(String externalExeConfigTemplate)
void setExternalExeTimeOut(final long externalExeTimeOut)
final Map< String, String > getParams()
String getExternalExeTmpFileRootDir()
static final String SET_NAME
void addStrategySettings(final StrategySettings stratSets)
String TimeAllocationMutator
void setPlanSelectorForRemoval(String planSelectorForRemoval)
static final String MODULE
StrategySettings getStrategySettings(final Id< StrategySettings > index, final boolean createIfMissing)
StrategySettings(final Id< StrategySettings > id)
void setFractionOfIterationsToDisableInnovation(double fraction)
final Map< String, String > getComments()