biogeme.catalog module

Defines a catalog of expressions that may be considered in a specification

author:

Michel Bierlaire

date:

Fri Mar 31 08:54:07 2023

class biogeme.catalog.Catalog(catalog_name, named_expressions, controlled_by=None)[source]

Bases: MultipleExpression

Catalog of expressions that are interchangeable. Only one of them defines the specification. They are designed to be modified algorithmically by a controller.

Parameters:
catalog_size()[source]

Return the size of the catalog.

Return type:

int

classmethod from_dict(catalog_name, dict_of_expressions, controlled_by=None)[source]

Ctor using a dict instead of a list.

Python does not guarantee the order of elements of a dict, although, in practice, it is always preserved. If the order is critical, it is better to use the main constructor. If not, this constructor provides a more readable code.

Parameters:
  • catalog_name (str) – name of the catalog

  • dict_of_expressions (dict(str:biogeme.expressions.Expression)) – dict associating the name of an expression and the expression itself.

  • controlled_by (Controller) – Object controlling the selection of the specifications.

get_all_controllers()[source]
Provides all controllers controlling the specifications of

a multiple expression

Returns:

a set of controllers

Return type:

set(Controller)

get_iterator()[source]

Obtain an iterator on the named expressions

Return type:

Iterator[NamedExpression]

selected()[source]

Return the selected expression and its name

Returns:

the name and the selected expression

Return type:

NamedExpression

selected_name()[source]

Return the name of the selected expression

Returns:

the name of the selected expression

Return type:

str

class biogeme.catalog.SegmentedParameters(beta_parameters, alternatives)[source]

Bases: object

Class managing the names of segmented and alternative specific parameters

Parameters:
  • beta_parameters (list[Beta])

  • alternatives (tuple[str, ...])

get_beta(beta_index, alternative)[source]

Return the Beta parameters for the given index and given alternative

Parameters:
  • beta_index (int) – index of the Beta in the generic list

  • alternative (str or None) – name of the alternative, or None for the generic parameter

get_index(beta_index, alternative)[source]
Returns the index in the list of the Beta parameter with

the given index specific to the given alternative

Parameters:
  • beta_index (int) – index of the Beta in the generic list

  • alternative (str or None) – name of the alternative, or None for the generic parameter

biogeme.catalog.generic_alt_specific_catalogs(generic_name, beta_parameters, alternatives, potential_segmentations=None, maximum_number=5)[source]

Generate catalogs selecting generic or alternative specific coefficients

Parameters:
  • generic_name (str) – name associated with all the parameters in the catalog

  • beta_parameters (list(biogeme.expressions.Beta)) – coefficients of interest

  • alternatives (tuple(str)) – names of the alternatives

  • potential_segmentations (tuple(DiscreteSegmentationTuple)) – tuple of potential segmentations, or None

  • maximum_number (int) – maximum number of segmentations to consider

Returns:

a list of catalogs for each alternative

Return type:

list(dict(str: biogeme.catalog.Catalog))

biogeme.catalog.segmentation_catalogs(generic_name, beta_parameters, potential_segmentations, maximum_number)[source]

Generate catalogs for potential segmentations of a parameter

Parameters:
  • generic_name (str) – name used for the definition of the group of catalogs

  • beta_parameters (list[Beta]) – list of parameters to be segmented

  • potential_segmentations (tuple[DiscreteSegmentationTuple, ...]) – tuple of potential segmentations

  • maximum_number (int) – maximum number of segmentations to consider