Controller

Defines controllers for multiple expressions

biogeme.controller module

Defines controllers for multiple expressions.

author:

Michel Bierlaire

date:

Sun Jul 16 15:23:46 2023

class biogeme.controller.CentralController(expression)[source]

Bases: object

Class controlling the complete multiple expression

__init__(expression)[source]

Constructor

Parameters:
  • controllers (tuple(controllers)) – all controllers of the expression

  • expression (biogeme.expressions.Expression) – controllers expression

decreased_controller(controller_name, current_config, step)[source]

Decrease the selection of one controller by “step”

Parameters:
  • controller_name (str) – name of the controller to modify

  • current_config (str) – current configuration

  • step (int) – number of steps to perform

Returns:

ID of the new configuration and number of steps performed.

Return type:

tuple(str, int)

get_configuration()[source]

Obtain the current configuration of the controllers

increased_controller(controller_name, current_config, step)[source]

Increase the selection of one controller by “step”

Parameters:
  • controller_name (str) – name of the controller to modify

  • current_config (str) – current configuration

  • step (int) – number of steps to perform

modify_random_controllers(increase, current_config, step)[source]

Increase the selection of “step” controllers by 1

Parameters:
  • increase (bool) – If True, the indices are increased . If False, they are decreased.

  • current_config (str) – current configuration

  • step (int) – number of steps to perform

number_of_configurations()[source]

Total number of configurations

prepare_operators()[source]

Operators are functions that take a configuration and a size as arguments, and return a new configuration, and the actual number of modifications that have been implemented.

set_configuration(configuration)[source]

Apply a configuration to the controllers

Parameters:

configuration (Configuration) – the configuration to be applied

set_configuration_from_id(configuration_id)[source]

Apply a configuration to the controllers

Parameters:

configuration_id (str) – the ID of the configuration to be applied

set_controller(controller_name, index)[source]

Set the given controller to the specified index

Parameters:
  • controller_name (string) – name of the controller

  • index (int) – index of the selection

two_controllers(first_controller_name, second_controller_name, direction, current_config, step)[source]

Modification of two controllers. Meaning of direction:

  • NE (North-East): first controller increased by “step”, second

    controller increased by “step”

  • NW (North-West): first controller decreased by “step”, second

    controller increased by “step”

  • SE (South-East): first controller increased by “step”, second

    controller decreased by “step”

  • SW (South-West): first controller decreased by “step”, second

    controller decreased by “step”

Parameters:
  • first_controller_name (str) – name of the first_controller to modify

  • second_controller_name (str) – name of the second_controller to modify

  • direction (str) – direction based on the compass rose. Must be NE, NW, SE or SW

  • current_config (str) – current configuration

  • step (int) – number of steps to perform

Returns:

ID of the new configuration and number of steps performed.

Return type:

tuple(str, int)

class biogeme.controller.Controller(controller_name, specification_names)[source]

Bases: object

Class controlling the specification of the Catalogs

__eq__(other)[source]

Return self==value.

__init__(controller_name, specification_names)[source]

Constructor

Parameters:
  • controller_name (str) – name of the controller

  • specification_names (list(str) or tuple(str)) – list or tuple of the names of the specification controlled by the controller

__lt__(other)[source]

Return self<value.

all_configurations()[source]

Return the code of all configurations

Returns:

list of codes

Return type:

list(str)

controller_size()[source]

Number of specifications managed by this controller

current_name()[source]

Name of the currently selected expression

modify_controller(step, circular)[source]

Modify the specification of the controller

Parameters:
  • step (int) – increment of the modifications. Can be negative.

  • circular (bool) – If True, the modificiation is always made. If the selection needs to move past the last one, it comes back to the first one. For instance, if the catalog is currently at its last value, and the step is 1, it is set to its first value. If circular is False, and the selection needs to move past the last one, the selection is set to the last one. It works symmetrically if the step is negative

Returns:

number of actual modifications

Return type:

int

reset_selection()[source]

Select the first specification

set_index(index)[source]

Set the index of the controller, and update the controlled catalogs

Parameters:

index (int) – value of the index

Raises:

BiogemeError – if index is out of range

set_name(name)[source]

Set the index of the controller based on the name of the specification

Parameters:

name (str) – name of the specification