biogeme.expressions.idmanager 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.idmanager.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.idmanager.IdManager(expressions, database, number_of_draws)[source]
Bases:
object
Class combining managing the ids of an arithmetic expression.
- Parameters:
expressions (Iterable[Expression])
database (Database)
number_of_draws (int)
- audit()[source]
Performs various checks on the expressions.
- Returns:
tuple listOfErrors, listOfWarnings
- Return type:
list(string), list(string)
- draw_types()[source]
Retrieve the type of draw for each draw expression
- Return type:
dict
[str
,str
]
- prepare()[source]
Extract from the formulas the literals (parameters, variables, random variables) and decide a numbering convention.
The numbering is done in the following order: :rtype:
None
free betas,
fixed betas,
random variables for numerical integration,
random variables for Monte-Carlo integration,
variables
The numbering convention will be performed for all expressions together, so that the same elementary expressions in several expressions will have the same index.
- Return type:
None
- setData(sample)[source]
Warning
This function is deprecated. Use
set_data()
instead.- Parameters:
sample (DataFrame)
- setDataMap(sample)[source]
Warning
This function is deprecated. Use
set_data_map()
instead.- Parameters:
sample (DataFrame)
- set_data(sample)[source]
Specify the sample
- Parameters:
sample (pandas.DataFrame) – map of the panel data (see
biogeme.database.Database.buildPanelMap()
)
- set_data_map(sample)[source]
Specify the map of the panel data in the expressions
- Parameters:
sample (pandas.DataFrame) – map of the panel data (see
biogeme.database.Database.buildPanelMap()
)
- biogeme.expressions.idmanager.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: