biogeme.expressions.conditional_sum module

Arithmetic expressions accepted by Biogeme: ConditionalSum

Michel Bierlaire Sat Sep 9 15:29:36 2023

class biogeme.expressions.conditional_sum.ConditionalSum(list_of_terms)[source]

Bases: Expression

This expression returns the sum of a selected list of expressions. An expression is considered in the sum only if the corresponding key is True (that is, return a non-zero value).

Parameters:

list_of_terms (Iterable[ConditionalTermTuple])

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 is transformed into the currently selected expression. The flat part is irrelevant for this expression.

Return type:

ConditionalSum

get_value()[source]

Evaluates the value of the expression

Returns:

value of the expression

Return type:

float

recursive_construct_jax_function(numerically_safe)[source]

Generates recursively a function to be used by PyMc. Must be overloaded by each expression :rtype: Callable[[Array, Array, Array, Array], array] :return: the expression in TensorVariable format, suitable for PyMc

Parameters:

numerically_safe (bool)

Return type:

Callable[[Array, Array, Array, Array], array]

recursive_construct_pymc_model_builder()[source]

Generates recursively a function to be used by PyMc. Must be overloaded by each expression :rtype: PymcModelBuilderType :return: the expression in TensorVariable format, suitable for PyMc

Return type:

PymcModelBuilderType

class biogeme.expressions.conditional_sum.ConditionalTermTuple(condition, term)[source]

Bases: NamedTuple

Parameters:
condition: Expression | float | int | bool

Alias for field number 0

term: Expression | float | int | bool

Alias for field number 1