Package org.matsim.core.config

The configuration can be used to change the behavior of MATSim in some well-defined places. Users may know best the configuration-files for MATSim, XML-files in which several parameters and corresponding values can be entered. The config-package is responsible to store these parameters in memory during runs.
Each parameter is part of exactly one config-group. Such a group collects similar parameters, or different parameters for one specific part of MATSim. The config-groups defined in the subpackage org.matsim.core.config.groups are considered "core" config-groups, which should change only if really needed. Often it is better to add additional config-paramters for new functionality as a new config-group (see Custom Config-Parameters below).

Custom Config-Parameters

One can add custom parameters any time to a configuration file, but they have to be in an additional "group" (in the XML representation, a "group" is specified as module. This may change in the future to have consistent names). As an example, you could add the following code to your configuration file:
   <module name="my-settings">
     <param name="my-value1" value="1" />
     <param name="my-value2" value="2.3" />
     <param name="my-value3" value="foo-bar" />
   </module>
 
These settings are then stored in an instance of ConfigGroup, which just stores all the parameters in a map. You could access such parameters with:
 Config config;
 // ... init/read config
 String val1 = config.getModule("my-settings).getParam("my-value1");
 
This works out-of-the-box, but it has the downside of only providing String-values. In some cases, when this string value must be converted into an int or double many times, this can be very inefficient. In such cases, it may be of advantage to offer a custom config-group to store the parameters with their native types.
To write a custom config-group, extend ConfigGroup. This allows you to convert the parsed values from the configuration file only once and then store the parameters in their native type. Just provide the corresponding getters and setters for your parameters, and overwrite the following methods: The custom config-group must be added to the Config-object before the configuration is read from file, because otherwise a generic ConfigGroup will be created for these settings. The controler-documenation has an example of how to use custom config-groups with additional functionality provided by ControlerListeners in the "Best Practices" section.
Author:
mrieser