agentlib_mpc.optimization_backends package
Subpackages
- agentlib_mpc.optimization_backends.casadi_ package
- Subpackages
- Submodules
- agentlib_mpc.optimization_backends.casadi_.admm module
- agentlib_mpc.optimization_backends.casadi_.basic module
- agentlib_mpc.optimization_backends.casadi_.casadi_admm_nn module
- agentlib_mpc.optimization_backends.casadi_.casadi_nn module
- agentlib_mpc.optimization_backends.casadi_.full module
- agentlib_mpc.optimization_backends.casadi_.minlp module
- Module contents
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
- 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
- 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