biogeme.parameters module
Centralized management of the parameters.
Parameters are organized by section. Parameters within the same section must have different names
- author:
Michel Bierlaire
- date:
Fri Dec 2 12:17:38 2022
- class biogeme.parameters.NameSectionTuple(name, section)[source]
Bases:
NamedTuple
- Parameters:
name (str)
section (str)
-
name:
str
Alias for field number 0
-
section:
str
Alias for field number 1
- class biogeme.parameters.Parameters[source]
Bases:
object
Parameters management
- add_parameter(parameter_tuple)[source]
Add one parameter
- Parameters:
parameter_tuple (ParameterTuple) – tuple containing the data associated with the parameter
- static check_parameter_value(the_tuple)[source]
Check if the value of the parameter is valid
- Parameters:
the_tuple (ParameterTuple) – tuple to check
- Returns:
a boolean that is True if the value is valid. If not, diagnostics are provided.
- Return type:
tuple(bool, list(str))
- dump_file(file_name)[source]
Dump the values of the parameters in the TOML file
- Parameters:
file_name (str)
- get_param_tuple(name, section=None)[source]
Obtain a tuple describing the parameter
- Parameters:
name (str) – name of the parameter
section (str) – section where the parameter is relevant
- Returns:
tuple containing the name, section and value of the parameter, or None if not found
- Return type:
- get_value(name, section=None)[source]
Get the value of a parameter. If the parameter appears in only one section, the name of the section can be omitted.
- Parameters:
name (str) – name of the parameter
section (str) – section containing the parameter
- Return type:
bool
|int
|float
|str
- import_document()[source]
Record the values of the parameters in the TOML document
- Return type:
None
- property parameter_names: list[str]
- parameters_in_section(section_name)[source]
Returns the parameters in a section
- Parameters:
section_name (str) – name of the section
- Return type:
list
[ParameterTuple
]
- read_file(file_name)[source]
Read TOML file. If the file name is invalid (typically, an empty string), the default value sof the parameters are used
- Parameters:
file_name (str)
- property sections: list[str]
- biogeme.parameters.format_comment(the_param)[source]
Format the content of the file, in particular the description of the parameter
- Parameters:
the_param (ParameterTuple) – parmeter to format
- Returns:
formatted text
- Return type:
str