-
Notifications
You must be signed in to change notification settings - Fork 2
Controller
In PARODIS, the controller object handles the MPC optimisation problem. This includes the handling of constraints, the generation of the expression of the cost function that is to be minimied by a solver, and the parameters on which the optimisation problem depends. It also retrieves realised and predicted disturbance values.
The controller is interfaced during the simulation in three ways.
Initially, the simulation will trigger the preparation and compilation of the optimization problem (latter only if the SymbolicController
is used), after an Agent has been fully defined. Then it will call the controller to retrieve the predicted disturbances for the current simulation step. And finally, it will be called to retrieve an optimal input for the system using the getInput
function.
Property | Value type | Description |
---|---|---|
type (readonly) |
string |
The controller type, i.e. 'symbolic' , 'explicit' , 'pareto'
|
config |
struct |
Controller-type specific configurations |
weightSyms |
[] |
symbolic variables for cost function weights |
paramSyms |
struct |
symbolic variables for parameters |
paramConfig |
struct |
source configuration for parameters |
constraints |
[] |
fixed YALMIP constraints |
implicitConstraints |
[] |
Implicitly defined constraints, i.e. those defined using function handles |
boxConstraintsTemp |
cell |
cell array of box constraint descriptions |
deltaConstraintsTemp |
cell |
cell array of delta constraint descriptions |
callbackTempConstraints |
function_handle |
callback to set temporary constraints right before solver call |
callbackManipulateInput |
function_handle |
callback to manipulate input retrieved from solver |
yalmipOptions |
sdpsettings |
YALMIP options object |
predDisturbanceSource |
string /function_handle
|
source for predicted disturbances |
realDisturbanceSource |
string /function_handle
|
source for realised disturbances |
defaultWeights |
[] |
default weights assumed for cost functions |
numScenarios |
integer |
number of scenarios to be considered |
costFunctions |
cell |
list of cost function instances |
costFunctionIndexes |
struct |
mapping for cost function name to the internal index |
costExpression |
sdpvar(1,1) |
YALMIP sdpvar expression of total optimization cost |
costExpressions |
cell |
YALMIP expression for each cost function |
slackVariables |
struct |
slack variables introduced by cost functions |
PARODIS makes use of the YALMIP optimizer
object. Initially, PARODIS will collect all information regarding the optimization problem, meaning it will collect all parameters, constraints, slack variables and cost functions. All these things are symbolic. When an agent is initialised, it will call its controller's compile()
function, which will build all remaining symbolic expressions (i.e. building actual box and delta constraint expression and the symbolic expression for the total cost function) and will generate a optimizer
object from this data. This will pre-compile the optimization problem, which takes some time, but will makes repeated solving of the parameterized optimization problem very efficient.
To retrieve an input (and the value set to the slack variables), the controller's getInput
method is called:
[uPred, slacks, code] = getInput(obj, weights, x0, agent, [additionalConstraints = [] ])
The third output is the YALMIP error code of the solved problem (0 = successfully solved).
If no additional constraint are passed, and the temporary constraint callback isn't set, and the calling agent isn't running in debug mode, this optimizer
object will be passed.
Otherwise, the much slower YALMIP optimize()
function will be used.
Please note, that the getInput
method will replace any symbolic parameters by their assumed numerical value stored in the passed agent's status. This means, that getInput
can only be called after the parameter values and disturbance predictions have been retrieved.
If your model has structurally time variant constraints, that can't be defined statically using parameters, you can make use of the temporary constraints callback.
[constraints] = callbackTempConstraints(agent)
If the callback is defined, it will be called right before the optimisation problem is solved. The callback must return a matrix of valid YALMIP constraints. The constraints will be added to the optimisation problem, which is then solved. Since after the optimizer compilation, no constraints can be added to the optimizer without rebuilding it,** using the temporar constraint callback will always imply the use of YALMIPs slower optimize
function**.
If you want to manipulate the input retrieved by the solver, this can be achieved using the input manipulation callback.
uPred = callbackManipulateInput(controller, uPred, agent)
The callback will be called right after uPred
has been retrieved within getInput
. Note that the manipulated input must have the same dimensions as the original input.
- Prerequisites
- Installing PARODIS
- Creating an Ansatz
- Setting up an Agent
- Setting up a Simulation
- Setting up Figures
Pareto Optimization
Modules
- Simulation
- Agent
- Model
- Controllers
- Cost Functions
- Sources
- Plotting
Other