biogeme.expressions_registry module

Combine several arithmetic expressions and a database to obtain formulas

author:

Michel Bierlaire

date:

Sat Jul 30 12:36:40 2022

class biogeme.expressions_registry.ElementsTuple(expressions, indices, names)[source]

Bases: Generic[T], NamedTuple

Data structure for elementary expressions.

Parameters:
  • expressions (dict[str, T] | None)

  • indices (dict[str, int] | None)

  • names (list[str])

expressions: dict[str, TypeVar(T, bound= Elementary)] | None

Alias for field number 0

indices: dict[str, int] | None

Alias for field number 1

names: list[str]

Alias for field number 2

class biogeme.expressions_registry.ExpressionRegistry(expressions, database)[source]

Bases: object

Class combining managing the ids of an arithmetic expression.

Parameters:
property bounds: list[tuple[float, float]]
broadcast()[source]

Broadcast the ids to the expressions

Return type:

None

complete_dict_of_free_beta_values(the_betas)[source]

Build a list of values for the beta parameters, some of them provided by the user. The others are the initial values.

Parameters:

the_betas (dict[str, float]) – user provided values

Return type:

dict[str, float]

Returns:

A list with parameter values.

draw_types()[source]

Retrieve the type of draw for each draw expression

Return type:

dict[str, str]

property draws: list[Draws]
property draws_indices: dict[str, int]
property draws_names: list[str]
property expressions: list[Expression]
property fixed_betas: list[Beta]
property fixed_betas_indices: dict[str, int]
property fixed_betas_values: dict[str, float]

Retrieve the initial values of all fixed beta parameters.

Returns:

A dictionary mapping parameter names to their fixed values.

property free_betas: list[Beta]
property free_betas_indices: dict[str, int]
property free_betas_init_values: dict[str, float]

Retrieve the initial values of all free beta parameters.

Returns:

A dictionary mapping parameter names to their initial values.

property free_betas_names: list[str]
get_betas_array(betas_dict)[source]
Return type:

ndarray

Parameters:

betas_dict (dict[str, float])

get_complete_betas_array(betas_dict)[source]
Return type:

ndarray

Parameters:

betas_dict (dict[str, float])

get_named_betas_values(values)[source]
Return type:

dict[str, float]

Parameters:

values (ndarray)

property list_of_free_betas_init_values: list[float]

Retrieve the initial values of all free beta parameters as a list.

Returns:

A list with parameter initial values.

property number_of_free_betas: int
property number_of_random_variables: int
property random_variables: list[RandomVariable]
property random_variables_indices: dict[str, int]
property requires_draws: bool
property variables: list[Variable]
property variables_indices: dict[str, int]
biogeme.expressions_registry.expressions_names_indices(dict_of_elements)[source]

Assigns consecutive indices to expressions

Parameters:

dict_of_elements (dict[str, type[TypeVar(T, bound= Elementary)]]) – dictionary of expressions. The keys are the names.

Returns:

a tuple with the original dictionary, the indices, and the sorted names.

Return type:

ElementsTuple