Parameters

Centralized management of the parameters.

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

__init__()[source]
add_parameter(parameter_tuple)[source]

Add one aprameter

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

generate_document()[source]

Generate the TOML document

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 ommitted.

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

  • section (str) – section containing the parameter

import_document()[source]

Record the values of the parameters in the TOML document

parameters_in_section(section_name)[source]

Returns the names of the parameters in a section

Parameters:

section_name (str) – name of the section

read_file(file_name)[source]

Read TOML file

sections_from_name(name)[source]

Obtain the list of sections containing the given entry

Parameters:

name (str) – name of the parameter

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.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