biogeme.expressions.collectors module

Function collecting recursively information about expressions

Michel Bierlaire Thu May 01 2025, 18:50:24

class biogeme.expressions.collectors.ExpressionCollector[source]

Bases: object

Walks the tree and collects handler return values.

register(expr_type)[source]

Register a handler function for a specific expression type. The handler must return a list of results.

Parameters:

expr_type (type[Expression]) – the type of Expression for which the handler should be used

Returns:

decorator that registers the handler

walk(expr, context=None)[source]

Traverse the expression tree and apply handlers to matching types.

Parameters:
  • expr (Expression) – the root expression to walk

  • context (Any) – optional context object passed to handlers

Return type:

list[Any]

Returns:

list of collected results from the handlers

biogeme.expressions.collectors.collect_init_values(expression)[source]
Return type:

dict[str, float]

Parameters:

expression (Expression)

biogeme.expressions.collectors.list_of_all_betas_in_expression(the_expression)[source]
Return type:

list[Beta]

Parameters:

the_expression (Expression)

biogeme.expressions.collectors.list_of_draws_in_expression(the_expression)[source]
Return type:

list[Draws]

Parameters:

the_expression (Expression)

biogeme.expressions.collectors.list_of_fixed_betas_in_expression(the_expression)[source]
Return type:

list[Beta]

Parameters:

the_expression (Expression)

biogeme.expressions.collectors.list_of_free_betas_in_expression(the_expression)[source]
Return type:

list[Beta]

Parameters:

the_expression (Expression)

biogeme.expressions.collectors.list_of_random_variables_in_expression(the_expression)[source]
Return type:

list[RandomVariable]

Parameters:

the_expression (Expression)

biogeme.expressions.collectors.list_of_variables_in_expression(the_expression)[source]
Return type:

list[Variable]

Parameters:

the_expression (Expression)