User Interface for Modeling and Control Synthesis for MPT 3.0
=============================================================
The proposed user interface (UI) aims to fix the design flaws of the
old MPT 2.6.x interface. The main points behind the new UI are:
* consistency with respect to working with various prediction models
(LTI, PWA, MLD, compositions of various subsystems)
* consistency of mathematical formulation between on-line and explicit
controllers
* easy extensibility without the need to maintain a single monolithic
implementation
* ability to seamlessly import MPT 2.6.x formulations
* promotion of the "correct" workflow where tuning is done on on-line
controllers first, only converting them to the explicit form when the
tuning is complete (avoiding frequent re-computation of the explicit
solution)
The UI consists of three primary layers, described in more details below.
1) Classes representing prediction models
2) Classes representing controllers
3) Class representing a generic closed-loop system
1. Representation of prediction models
--------------------------------------
The UI allows to define four basic types of prediction models:
1) Linear Time Invariant (LTI) models
2) Piecewise Affine (PWA) models
3) Mixed-Logical Dynamical (MLD) models
4) Compositions consisting of several interconnected LTI/PWA/MLD
models
1.1 LTI models
--------------
LTI models describe linear (in fact, affine) time-invariant systems
of the form
x^+ = A x + B u + f
y = C x + D u + g
Such models, represented by the @LTISystem class, can be constructed
in three ways:
1) By providing the matrices:
lti = LTISystem('A', A, 'B', B, 'C', C, 'D', D, 'f', f, 'g', g)
The 'f' and 'g' parameters can be omitted.
2) By importing from state-space models of the Control Toolbox:
ss = ss(A, B, C, D, Ts)
lti = LTISystem(ss)
Note that only discrete-time state-space objects can be imported.
3) By importing from MPT2 sysStruct:
lti = LTISystem(sysStruct)
The returned object contains:
1) matrices A, B, C, D, f, g of the state-update and output equations
(read-only)
2) dimensions nx, nu, ny (read-only)
3) sampling time Ts (read-only)
4) signals representing states (lti.x), inputs (lti.u) and outputs
(lti.y) of the system (read/write)
5) domain of the system in the state-input space (can be set using the
setDomain method)
Properties of these signals (e.g. constraints and penalties) can be
defined as described in Section 1.4.
The class implements following methods:
* initialize(x0): Sets the current state of the system
* getStates(): Returns the current state of the system
* update(u): Performs the state update using the control action "u"
* output(u): Computes the output (note that providing the control
action is only needed if the system contains direct feed-through)
* setDomain(type, D): sets the domain of the system either in the state
space (type='x'), input space (type='u') or state-input space (type='xu')
* plot(): to visualize the optimized open-loop profiles of states,
inputs and outputs (requires prior call to an optimization routine,
explained in Section 2.x)
The object remembers the value of its state and updates it whenever
update() is called. This means that evolution of the system can be
obtained in the following way:
lti.initialize(x0)
lti.update(u0)
lti.update(u1)
lti.update(u2)
lti.getStates()
See mpt3_lti_demo1.m, mpt3_lti_demo2.m, mpt3_lti_demo3.m,
mpt3_lti_demo4.m, mpt3_lti_demo5.m for examples.
1.2 PWA models
--------------
PWA models encode the PWA dynamics
x^+ = A_i*x + B_i*u + f_i IF [x; u] \in Dom_i
y = C_i*x + D_i*u + g_i IF [x; u] \in Dom_i
PWA models can be created in three ways:
1) By providing an array of LTI systems, each of which represents one mode
of the PWA system:
dyn1 = LTISystem(...)
dyn1.setDomain('x', Polyhedron(...)) % Region of validity
dyn2 = LTISystem(...)
dyn2.setDomain('x', Polyhedron(...)) % Region of validity
pwa = PWASystem([dyn1, dyn2])
2) By converting an MLD description to a PWA form:
mld = MLDSystem(...)
pwa = PWASystem(mld)
3) By importing from MPT2's sysStruct:
opt_sincos
pwa = PWASystem(sysStruct)
Internally, PWA models are represented by the @PWASystem class, which
contains following fields (all read-only):
* A, B, C, D, f, g: cell arrays of matrices
* domain: array of polyhedra denoting region of validity of corresponding
local affine models
* nx, nu, ny, ndyn: number of states, inputs, outputs and dynamics
* Ts: sampling time
* x, u, y, d: signals representing states, inputs, outputs and binary
mode selectors
Properties of signals 'x', 'u', 'y', 'd' (e.g. constraints and penalties)
can be defined as described in Section 1.5.
The class implements the same methods as in the LTI case (Section 1.1).
1.3 MLD models
--------------
MLD models are represented by the @MLDSystem class and can be imported
from a HYSDEL source file by calling
mld = MLDSystem('filename.hys')
If the source file contains symbolic parameters, their values can be
provided as a structure in the second input argument:
mld = MLDSystem('filename.hys', struct('param1', value1))
MLD models can be converted to a PWA form using the toPWA() method:
pwa = mld.toPWA();
The class implements the same methods as in the LTI case (Section 1.1).
1.4 Signals
-----------
As mentioned in Section 1.1-1.3, each prediction model contains
"signals", which represent the state, input and output variables of
the model.
A "signal", represented by the @SystemSignal class, is a basic
primitive which does two things:
1) it represents the prediction of a given quantity over a prediction
horizon as a YALMIP variable
2) allows to define basic properties of the quantity
A "signal" is created by calling the s=SystemSignal(n)
constructor where "n" is the dimension of the signal.
(NOTE: the user never has to create signals manually.)
Once the signal is created, following basic properties can be set by
the user:
* lower bound (s.min = [...])
* upper bound (s.max = [...])
* penalty function (s.penalty = ...)
As a specific example, consider the following LTI model of a double
integrator:
Ts = 1
s = c2d(ss(tf(1, [1 0 0])), Ts)
lti = LTISystem(s)
Then the "lti" object contains following signals:
* lti.x: the 2x1 state vector
* lti.u: the 1x1 input
* lti.y: the 2x1 output vector
To set the lower/upper bound on the input, one would call
lti.u.min = -1;
lti.u.max = 1;
To set a quadratic state penalty of the form x'*Q*x on the state with
Q=eye(2), call
lti.x.penalty = Penalty(eye(2), 2)
NOTE: Definition of penalties is described in Section 1.5.
Besides the minimal set of properties described above, arbitrary
additional properties can be added on-the-fly by the concept of custom
properties, called "filters". Examples include polyhedral constraints, soft
constraints, or move blocking. These custom properties are described by
separate methods of the SystemSignal class, prefixed by "filter_" (see
"methods SystemSignal").
Examples:
* polyhedral set constraint (for states, inputs, outputs):
lti.x.with('setConstraint') % enable the property
lti.x.setConstraint = Polyhedron(...); % specification of the property
* marking variables as binary (for states, inputs, outputs):
lti.u.with('binary')
lti.u.binary = true;
* move-blocking constraint u(1)=u(2)=u(3):
lti.u.with('block')
lti.u.block.from = 1
lti.u.block.to = 3
* soft constraints (for states, inputs, outputs):
lti.x.with('softMin') % soft lower bound
lti.x.with('softMax') % soft upper bound
* penalty on the final predicted state:
lti.x.with('terminalPenalty')
lti.x.terminalPenalty = Penalty(...)
* polyhedral constraints on the final predicted state:
lti.x.with('terminalSet')
lti.x.terminalSet = Polyhedron(...)
* adding a reference trajectory for MPC (for
评论0