biogeme.controller module
Defines controllers for multiple expressions.
- author:
Michel Bierlaire
- date:
Sun Jul 16 15:23:46 2023
- class biogeme.controller.CentralController(expression, maximum_number_of_configurations=None)[source]
Bases:
object
Class controlling the complete multiple expression
- Parameters:
expression (Expression)
maximum_number_of_configurations (int | None)
- 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 modifycurrent_config (
Configuration
) – current configurationstep (
int
) – number of steps to perform
- Return type:
tuple
[Configuration
,int
]- Returns:
ID of the new configuration and number of steps performed.
- get_operator_decreased_controllers(controller_name)[source]
- Return type:
Callable
[[Configuration
,int
],tuple
[Configuration
,int
]]- Parameters:
controller_name (str)
- get_operator_increased_controllers(controller_name)[source]
- Return type:
Callable
[[Configuration
,int
],tuple
[Configuration
,int
]]- Parameters:
controller_name (str)
- get_operator_modify_random_controllers(increase)[source]
- Return type:
Callable
[[Configuration
,int
],tuple
[Configuration
,int
]]- Parameters:
increase (bool)
- get_operator_two_controllers(first_controller_name, second_controller_name, direction)[source]
- Return type:
Callable
[[Configuration
,int
],tuple
[Configuration
,int
]]- Parameters:
first_controller_name (str)
second_controller_name (str)
direction (str)
- 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
- Return type:
tuple
[Configuration
,int
]
- 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 (
Configuration
) – current configurationstep (
int
) – number of steps to perform
- Return type:
tuple
[Configuration
,int
]
- 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.
- Return type:
dict
[str
,Callable
[[Configuration
,int
],tuple
[Configuration
,int
]]]
- set_configuration(configuration)[source]
Apply a configuration to the controllers
- Parameters:
configuration (Configuration) – the configuration to be applied
- Return type:
None
- 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
- Return type:
None
- 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
- Return type:
None
- 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 modifydirection (
str
) – direction based on the compass rose. Must be NE, NW, SE or SWcurrent_config (
Configuration
) – current configurationstep (
int
) – number of steps to perform
- Return type:
tuple
[Configuration
,int
]- Returns:
ID of the new configuration and number of steps performed.
- class biogeme.controller.Controller(controller_name, specification_names)[source]
Bases:
object
Class controlling the specification of the Catalogs
- Parameters:
controller_name (str)
specification_names (Iterable[str])
- all_configurations()[source]
Return the code of all configurations
- Returns:
set of codes
- Return type:
set(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 modification 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
- Return type:
None