agentlib_mpc.optimization_backends package
- pydantic model agentlib_mpc.optimization_backends.BackendImport[source]
Bases:
BaseModel
Data-Class to import a given python file from
import_path
and load the givenclass_name
- Fields:
- field class_name: str [Required]
- field import_path: str [Required]
Subpackages
- agentlib_mpc.optimization_backends.casadi_ package
- Subpackages
- Submodules
- agentlib_mpc.optimization_backends.casadi_.admm module
ADMMCollocation
ADMMMultipleShooting
CasADiADMMBackend
CasADiADMMBackend.cost_function
CasADiADMMBackend.coupling_grid
CasADiADMMBackend.discretization
CasADiADMMBackend.discretization_types
CasADiADMMBackend.it
CasADiADMMBackend.model
CasADiADMMBackend.now
CasADiADMMBackend.result_stats
CasADiADMMBackend.results
CasADiADMMBackend.save_result_df()
CasADiADMMBackend.system
CasADiADMMBackend.system_type
CasADiADMMBackend.var_ref
CasadiADMMSystem
CasadiADMMSystem.algebraics
CasadiADMMSystem.controls
CasadiADMMSystem.cost_function
CasadiADMMSystem.exchange_diff
CasadiADMMSystem.exchange_multipliers
CasadiADMMSystem.global_couplings
CasadiADMMSystem.initial_state
CasadiADMMSystem.initialize()
CasadiADMMSystem.last_control
CasadiADMMSystem.local_couplings
CasadiADMMSystem.local_exchange
CasadiADMMSystem.model_constraints
CasadiADMMSystem.model_parameters
CasadiADMMSystem.multipliers
CasadiADMMSystem.non_controlled_inputs
CasadiADMMSystem.ode
CasadiADMMSystem.outputs
CasadiADMMSystem.penalty_factor
CasadiADMMSystem.r_del_u
CasadiADMMSystem.states
- agentlib_mpc.optimization_backends.casadi_.basic module
- agentlib_mpc.optimization_backends.casadi_.casadi_admm_ml module
- agentlib_mpc.optimization_backends.casadi_.casadi_ml module
- agentlib_mpc.optimization_backends.casadi_.full module
CasADiFullBackend
DirectCollocation
FullSystem
FullSystem.algebraics
FullSystem.controls
FullSystem.cost_function
FullSystem.initial_state
FullSystem.initialize()
FullSystem.last_control
FullSystem.model_constraints
FullSystem.model_parameters
FullSystem.non_controlled_inputs
FullSystem.ode
FullSystem.outputs
FullSystem.r_del_u
FullSystem.states
MultipleShooting
- agentlib_mpc.optimization_backends.casadi_.mhe module
- agentlib_mpc.optimization_backends.casadi_.minlp module
CasADiMINLPBackend
CasadiMINLPSystem
CasadiMINLPSystem.algebraics
CasadiMINLPSystem.binary_controls
CasadiMINLPSystem.controls
CasadiMINLPSystem.cost_function
CasadiMINLPSystem.initial_state
CasadiMINLPSystem.initialize()
CasadiMINLPSystem.model_constraints
CasadiMINLPSystem.model_parameters
CasadiMINLPSystem.non_controlled_inputs
CasadiMINLPSystem.ode
CasadiMINLPSystem.outputs
CasadiMINLPSystem.states
DirectCollocation
- agentlib_mpc.optimization_backends.casadi_.minlp_cia module
Submodules
agentlib_mpc.optimization_backends.backend module
- class agentlib_mpc.optimization_backends.backend.ADMMBackend(config: dict)[source]
Bases:
OptimizationBackend
Base class for implementations of optimization backends for ADMM algorithms.
- abstract property coupling_grid: list[float]
Returns the grid on which the coupling variables are discretized.
- pydantic model agentlib_mpc.optimization_backends.backend.BackendConfig[source]
Bases:
BaseModel
- Config:
extra: str = forbid
- Fields:
- Validators:
- field discretization_options: DiscretizationOptions [Required]
- field model: dict [Required]
- field name: str | None = None
- field overwrite_result_file: bool | None = False
- Validated by:
- field save_results: bool | None = None
- Validated by:
- validator check_csv » results_file[source]
- validator check_overwrite » overwrite_result_file[source]
Checks, whether the overwrite results sttings are valid, and deletes existing result files if applicable.
- validator disable_results_if_no_file » save_results[source]
- class agentlib_mpc.optimization_backends.backend.OptimizationBackend(config: dict)[source]
Bases:
ABC
Base class for all optimization backends. OptimizationBackends are a plugin for the ‘mpc’ module. They provide means to setup and solve the underlying optimization problem of the MPC. They also can save data of the solutions.
- config_type
alias of
BackendConfig
- cost_function: Callable | None
- get_lags_per_variable() dict[str, float] [source]
Returns the name of variables which include lags and their lag in seconds. The MPC module can use this information to save relevant past data of lagged variables
- model: ModelT
- mpc_backend_parameters = ('time_step', 'prediction_horizon')
- results_file_exists() bool [source]
Checks if the results file already exists, and if not, creates it with headers.
- abstract setup_optimization(var_ref: VariableReference)[source]
Performs all necessary steps to make the
solve
method usable.- Parameters:
var_ref – Variable Reference that specifies the role of each model variable in the mpc
- abstract solve(now: float | datetime, current_vars: Dict[str, AgentVariable]) Results [source]
Solves the optimization problem given the current values of the corresponding AgentVariables and system time. The standardization of return values is a work in progress.
- Parameters:
now – Current time used for interpolation of input trajectories.
current_vars – Dict of AgentVariables holding the values relevant to the optimization problem. Keys are the names
- Returns:
A dataframe with all optimization variables over their respective grids. Depending on discretization, can include many nan’s, so care should be taken when using this, e.g. always use dropna() after accessing a column.
- Example:
variables mDot | T_0 | slack_T
time 0 0.1 | 298 | nan 230 nan | 297 | 3 470 nan | 296 | 2 588 nan | 295 | 1 700 0.05 | 294 | nan 930 nan | 294 | 0.1
- update_discretization_options(opts: dict)[source]
Updates the discretization options with the new dict.
- update_model_variables(current_vars: Dict[str, AgentVariable])[source]
Internal method to write current data_broker to model variables. Only update values, not other module_types.
- var_ref: VariableReference | None