biogeme.expressions.multiple_expressions module¶
Defines the interface for a catalog of expressions that may be considered in a specification
Michel Bierlaire 13.04.2025 17:02
- class biogeme.expressions.multiple_expressions.CatalogItem(catalog_name, item_index, item_name)[source]¶
Bases:
NamedTuple
- Parameters:
catalog_name (str)
item_index (int)
item_name (str)
-
catalog_name:
str
¶ Alias for field number 0
-
item_index:
int
¶ Alias for field number 1
-
item_name:
str
¶ Alias for field number 2
- class biogeme.expressions.multiple_expressions.MultipleExpression(the_name)[source]¶
Bases:
Expression
Interface for catalog of expressions that are interchangeable. Only one of them defines the specification. They are designed to be modified algorithmically.
- Parameters:
the_name (str)
- add_suffix_to_all_variables(*args, **kwargs)¶
- final catalog_size()[source]¶
Provide the size of the catalog
- Returns:
number of expressions in the catalog
- Return type:
int
- change_init_values(*args, **kwargs)¶
Modifies the initial values of the Beta parameters.
The fact that the parameters are fixed or free is irrelevant here.
- Parameters:
betas (dict(string:float)) – dictionary where the keys are the names of the parameters, and the values are the new value for parameters, and the values are the new value for the parameters.
- deep_flat_copy()[source]¶
Provides a copy of the expression. It is deep in the sense that it generates copies of the children. It is flat in the sense that any MultipleExpression such as this one is transformed into the currently selected expression. The flat part is irrelevant for this expression.
- Return type:
- get_elementary_expression(*args, **kwargs)¶
Return: an elementary expression from its name if it appears in the expression.
- Parameters:
name (string) – name of the elementary expression.
- Returns:
the expression if it exists. None otherwise.
- Return type:
biogeme.expressions.Expression
- abstractmethod get_iterator()[source]¶
Returns an iterator on NamedExpression
- Return type:
Iterator
[NamedExpression
]
- get_value(*args, **kwargs)¶
Calculates the value of the expression if it is simple
- logit_choice_avail(*args, **kwargs)¶
Extract a dict with all elementary expressions of a specific type
- Returns:
returns a dict with the variables appearing in the expression the keys being their names.
- Return type:
dict(string:biogeme.expressions.Expression)
- recursive_construct_jax_function(*args, **kwargs)¶
Generates recursively a function to be used by biogeme_jax. Must be overloaded by each expression :return: the function takes two parameters: the parameters, and one row of the database.
- rename_elementary(*args, **kwargs)¶
- requires_draws(*args, **kwargs)¶
- abstractmethod selected()[source]¶
Return the selected expression and its name
- Returns:
the name and the selected expression
- Return type:
tuple(str, biogeme.expressions.Expression)
- final selected_expression()[source]¶
Obtain the selected expression
- Returns:
the selected expression
- Return type:
biogeme.expressions.Expression
- final selected_name()[source]¶
Obtain the name of the selection
- Returns:
the name of the selected expression
- Return type:
str
- set_maximum_number_of_observations_per_individual(*args, **kwargs)¶
- set_specific_id(*args, **kwargs)¶
The elementary IDs identify the position of each element in the corresponding datab
- class biogeme.expressions.multiple_expressions.NamedExpression(name, expression)[source]¶
Bases:
NamedTuple
- Parameters:
name (str)
expression (Expression)
-
expression:
Expression
¶ Alias for field number 1
-
name:
str
¶ Alias for field number 0
- biogeme.expressions.multiple_expressions.delegate_to_selected(method_name)[source]¶
Create a method that delegates its call to self.selected()[1].<method_name>(…).
This is useful for classes that wrap or dispatch to another Expression object, avoiding code duplication for common method overrides.
- Parameters:
method_name (
str
) – The name of the method to delegate. It must be a valid method name on the Expression returned by self.selected()[1].- Returns:
A method that can be assigned to a class and will delegate the call.