ID manager

Management of the IDs of mathematical expressions

biogeme.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.idmanager.ElementsTuple(expressions, indices, names)

Bases: tuple

expressions

Alias for field number 0

indices

Alias for field number 1

names

Alias for field number 2

class biogeme.idmanager.IdManager(expressions, database, number_of_draws, force_new_ids=False)[source]

Bases: object

Class combining managing the ids of an arithmetic expression.

__eq__(other)[source]

Return self==value.

__init__(expressions, database, number_of_draws, force_new_ids=False)[source]

Ctor

Parameters
  • expressions (list(biogeme.expressions.Expression)) – list of expressions

  • database (biogeme.database.Database) – database with the variables as column names

  • number_of_draws (int) – number of draws for Monte-Carlo integration

  • force_new_ids (bool) – if True, new ids are calculated for all expressions, even if they have already an ID. If False, and some expressions already have an ID, an error is raised.

Raises

biogemeError – if an expression contains a variable and no database is provided.

audit()[source]

Performs various checks on the expressions.

Returns

tuple listOfErrors, listOfWarnings

Return type

list(string), list(string)

changeInitValues(betas)[source]

Modifies the values of the pameters

Parameters

betas (dict(string:float)) – dictionary where the keys are the names of the parameters, and the values are the new value for the parameters.

expressions_names_indices(dict_of_elements)[source]

Assigns consecutive indices to expressions

Parameters

dict_of_elements (dict(str: biogeme.expressions.Expression)) – dictionary of expressions. The keys are the names.

Returns

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

Return type

ElementsTuple

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:

  1. free betas,

  2. fixed betas,

  3. random variables for numerical integration,

  4. random variables for Monte-Carlo integration,

  5. 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.

setData(sample)[source]

Specify the sample

Parameters

sample (pandas.DataFrame) – map of the panel data (see biogeme.database.Database.buildPanelMap())

setDataMap(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())