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)

generate_document()[source]

Generate the TOML document

Return type:

TOMLDocument

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:

ParameterTuple

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]
sections_from_name(name)[source]

Obtain the list of sections containing the given entry

Parameters:

name (str) – name of the parameter

Return type:

set[str]

set_value(name, value, section=None)[source]

Set a value of a parameter. If the parameter appears in only one section, the name of the section can be ommitted.

Parameters:
  • name (str) – name of the parameter

  • value (str) – value of the parameter

  • section (str) – section containing the parameter

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

biogeme.parameters.get_default_value(name, section=None)[source]
Return type:

bool | int | float | str

Parameters:
  • name (str)

  • section (str | None)

biogeme.parameters.parse_boolean(value)[source]

Transforms one of the string representing a boolean into an actual boolean

Parameters:

value (str) – value to be transformed

Returns:

equivalent boolean

Return type:

bool