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)
- 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 – If True, the indices are increased . If
False, they are decreased. :type increase: bool
- Parameters:
current_config (str) – current configuration
step (int) – number of steps to perform
- 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
- __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
- all_configurations()[source]
Return the code of all configurations
- Returns:
list of codes
- Return type:
list(str)
- 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
- 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