Model Predictive Control: Basic Concepts - SYSMA@IMT Lucca

15 downloads 0 Views 9MB Size Report
2009 by A. Bemporad. Controllo di Processo e dei Sistemi di Produzione ‐ A.a. 2008/09. Model Predictive Control Toolbox. 12. • MPC Toolbox 3.0 (Bemporad, ...
Model
Predictive
Control:
Basic
Concepts

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

1 /94

Model
Predictive
Control
(MPC) model‐based
 optimizer reference

r(t)

process input

output

u(t)

y(t)

measurements

A
model
of
the
process
is
used
to
predict
the
future
evolution
 of
the
process
to
optimize
the
control
signal


©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

2 /94

Receding
horizon
philosophy •
At
time t:
solve
an
optimal
control
 



problem
over
a
finite
future
horizon
 



of N steps:

yt+k

r(t)

Predicted
outputs Manipulated Inputs

t+N

t t+1

t+1

ut+k

t+2

t+N+1

•
Only
apply
the
first
optimal
move •
At
time
t+1:
Get
new
measurements,
repeat
the
optimization.
And
so
on
…
 



 
Advantage
of
repeated
on‐line
optimization:
FEEDBACK! ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

3 /94

Receding
Horizon
‐
Examples •
MPC
is
like
playing
chess
!

•
“Rolling
horizon”
policies
are 


also
used
frequently
in
finance


©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

4 /94

Receding
Horizon
‐
Examples ‐
prediction
model

how
vehicle
moves
on
the
map

‐
constraints

drive
on
roads,
respect
one‐way
roads,
etc.

‐
disturbances

mainly
driver’s
inattention
!

‐
set
point

desired
location

‐
cost
function

minimum
time,
 minimum
distance,
etc.

‐
receding
horizon
mechanism event‐based
 (optimal
route
re‐planned
when
path
is
lost) ©
2009
by
A.
Bemporad

x
=
GPS
position u
=
navigation
commands

Fastest route Shortest route Avoid motorways Walking route Bicycle route Limited speed

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

5 /94

Good
Models
for
(MPC)
Control Note:
computational
complexity
and
theoretical
properties
(e.g.
 stability)
depend
on
chosen
model/objective/constraints Good
models
for
MPC: •
Descriptive
enough
to
capture
the
most
significant





dynamics
of
the
system

F F O 
 E D A TR •
Simple
enough
for
solving
the
optimization
problem “Make
everything
as
simple
as
possible,
but
not
simpler.” 

—
Albert
Einstein ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

6 /94

MPC
in
Industry •
History:
Computer
control
(“Manual”
MPC)

Fluid
catalytic
cracking (courtesy
of
Shell
/
M.
Morari)

Fluid
catalytic
cracking
(FCC)
is
 the
most
important
conversion
 process
used
in
petroleum
 refineries.
It
is
widely
used
to
 convert
the
high‐boiling
 hydrocarbon
fractions
of
 petroleum
crude
oils
to
more
 valuable
gasoline,
olefinic
gases
 and
other
products (http://en.wikipedia.org/wiki/Catalytic_cracking)

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

7 /94

MPC
in
Industry •
History:
1979
Dynamic
Matrix
Control
(DMC)
by
Shell 



(Motivation:
multivariable,
constrained) •
Present
Industrial
Practice •
linear
impulse/step
response
models •
sum
of
squared
errors
 



objective
function •
executed
in
supervisory
mode

•
Particularly
suited
for
problems
with •
many
inputs
and
outputs •
constraints
on
inputs,
outputs,
states •
varying
objectives
and
limits
on
variables
 


(e.g.
because
of
faults) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

8 /94

MPC
in
Industry Hierarchy
of
control
system
functions:
 Conventional

MPC

(Qin,
Badgewell,
1997) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

9 /94

MPC
in
Industry

(snapshot
survey
conducted
in
mid‐1999)

(Qin,
Badgewell,
2003)

“For
us
multivariable
control
is
predictive
control
” Tariq
Samad,
Honeywell
(IEEE
Control
System
Society,
President)
(1997) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

10 /94

MPC
in
Industry Results
from
a
recent
survey
(November
7,
2005)
about
the
use
of
MPC
techniques
/
 real‐time
optimization
in
a
set
of
US
industries: Do
you
see
your
use
of
MPC
accelerating,
 staying
constant,
or
declining?

Industrial
area
of
respondents
to
the
survey: Pharmaceuticals Machinery

0.7
% 0.7
%

Food
&
Beverage Aerospace Automotive

0.7
% 0.7
% 1.5
%

Decreasing

Constant

1.5
% 2.2
% 2.2
%

Mining Cement
&
Glass Metals

Increasing

2.9
%

Plastics
&
Rubber Electronics Power

0

5.1
% 5.1
%

69.8
%

20

40

60

80

100

Does
your
company
use
MPC
?

5.1
%

Pulp
&
Paper

28.8
%

11.0
%

Other Oil
&
Gas

15.4
%

19.0
%

No

20.6
%

Chemicals Refining

24.3
% 0

5

10

15

20

25

30

35

35.2
%

Routinely

45.8
%

Sometimes courtesy:

©
2009
by
A.
Bemporad

0

10

20

30

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

40

50

60

70

11 /94

Model
Predictive
Control
Toolbox Model
Predictive
Control
Toolbox •
MPC
Toolbox
3.0
(Bemporad,
Ricker,
Morari,
1998‐today): –
Object‐oriented
implementation
(MPC
object) –
MPC
Simulink
Library –
MPC
Graphical
User
Interface –
RTW
extension
(code
generation) 


[xPC
Target,
dSpace,
etc.] –
Linked
to
OPC
Toolbox
v2.0.1

Only
linear
models
are
handled http://www.mathworks.com/products/mpc/ ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

12 /94

MPC
Simulink
Library

•
Single
MPC
and
multiple
swicthed
MPC
blocks
supported •
Reference/disturbance
preview
and
time‐varying
limits
supported ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

13 /94

MPC
Graphical
User
Interface

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

14 /94

MPC
Tuning
Advisor

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

15 /94

Hybrid
Toolbox
for
MATLAB Features:

(Bemporad,
2003‐2009)

•
Hybrid
models:
design,
simulation,
verification •
Control
design
for
linear
systems
w/
constraints
 



and
hybrid
systems
(on‐line
optimization
via
QP/MILP/MIQP) •
Explicit
MPC
control
(via
multi‐parametric
programming) •
C‐code
generation •
Simulink
library

2450+
download
requests since
October
2004

http://www.dii.unisi.it/hybrid/toolbox ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

16 /94

Basics
of
Constrained
Optimization

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

17 /94

Mathematical
Programming

In
general,
problem
is
difficult
to
solve use
software
tools ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

18 /94

Optimization
Software • Taxonomy
of
most
known
solvers,
for
different
classes
of
 optimization
problems: http://www-fp.mcs.anl.gov/otc/Guide/SoftwareGuide/

• Network
Enabled
Optimization
Server
(NEOS)
for
remotely
 solving
optimization
problems: http://neos.mcs.anl.gov/neos/solvers/

• Comparison
on
benchmark
problems: http://plato.la.asu.edu/bench.html

• Good
open‐source
optimization
software http://www.coin-or.org/ ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

19 /94

Convex
sets

Convex
set

©
2009
by
A.
Bemporad

Nonconvex
set

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

20 /94

Convex
function

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

21 /94

Convex
Optimization
Problem f
and
C
convex

• Very
efficient
numerical
algorithms
exist • Global
solution
attained • Extensive
useful
theory • Often
occurring
in
engineering
problems • Tractable
in
theory
and
practice Excellent
reference
textbook:
“Convex
Optimization”
by
S.
Boyd
 http://www.stanford.edu/~boyd/cvxbook/ and
L.
Vandenberghe ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

22 /94

Polyhedra • A
convex
polyhedron
is
the
intersection
of
a
finite 



set
of
halfspaces
of
Rd • A
convex
polytope
is
a
bounded
convex
polyhedron

A

A2

A


 2 b = x 2

1

A A3x=b3


1 x=

A3

b1 


•
Hyperplane
representation:

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

23 /94

Linear
Program George
Dantzig
 (1914
‐
2005)

Standard
form: ‐f

f’x Slack
variables

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

24 /94

Linear
Program trasformation from
max
to
min:

Change
inequality direction:

It
is
always
possible
to
formulate
LP
problems using
“min”
and
“·”
inequalities ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

25 /94

Quadratic
Program

•
Convex
optimization
if
P º 0 •
Hard
problem
if
P ² 0 ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

26 /94

Mixed‐Integer
Linear
Program

•
Some
variables
are
continuous,
some
are
discrete
(0/1) •
In
general,
it
is
a
NP‐hard
problem •
Rich
variety
of
algorithms/solvers
available

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

27 /94

Modeling
languages •
MOSEL,
associated
with
commercial
package
Xpress‐MP •
OPL
(Optimization
Programming
Language),
associated
with 



commercial
package
Ilog‐CPLEX
 •
AMPL
(A
Modeling
Language
for
Mathematical
Programming) 



most
used
modeling
language,
supports
several
solvers •
GAMS
(General
Algebraic
Modeling
System)
is
one
of
the
first 



modeling
languages •
LINGO,
modeling
language
of
Lindo
Systems
Inc. •
GNU
MathProg,
a
subset
of
AMPL
associated
with
the 



free
package
GLPK
(GNU
Linear
Programming
Kit) •
FLOPC++
open
source
modeling
language
(C++
class
library) •
CVX
matlab‐based
modeling
language
(from
Stanford) •
YALMIP
another
matlab‐based
modeling
language ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

28 /94

Linear
MPC

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

29 /94

Unconstrained
Optimal
Control •
Linear
model:

•
Goal:
find








































that
minimize












































































is
the
input
sequence
that
steers
the
 state
to
the
origin
“optimally”

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

/94

[computation
of
cost
function]

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

/94

Unconstrained
Optimal
Control

The
optimum
is
obtained
by
zeroing
the
gradient

batch
least
 squares

and
hence

Alternative
approach:
use
dynamic
programming
to
find
U* (Riccati
iterations) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

/94

Constrained
Optimal
Control •
Linear
model:

•
Constraints:

•
Constrained
optimal
control
problem
(quadratic
performance
index):

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

33 /94

Constrained
Optimal
Control •
Optimization
problem:

(quadratic) (linear) Convex
QUADRATIC
PROGRAM
(QP)

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

34 /94

Linear
MPC
Algorithm past

future Predicted outputs y(t+k|t) Manipulated Inputs u(t+k) t t+1


At
time
t:

t+N

•
Get/estimate
the
current
state
x(t)
 •
Solve
the
QP
problem



and
let
U={u*(0),...,u*(N-1)}
be
the
solution 

(=finite‐horizon
constrained
open‐loop
optimal
control) •
Apply
only




























and
discard
the
remaining
optimal
inputs •
Repeat
optimization
at
time
t+1.
And
so
on
... ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

35 /94

Unconstrained
Linear
MPC •
Assume
no
constraints

r(t)

yt+k

Predicted
outputs

•
Problem
to
solve
on‐line:

Manipulated ut+k Inputs t t+1

t+N

•
Solution:

Unconstrained
linear
MPC
is
nothing
else
than
a
standard
 linear
state‐feedback
law
! ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

36 /94

Double
Integrator
Example •
System: sampling
+

ZOH
 Ts=1
s

•
Constraints:

•
Control
objective:
min

•
Optimization
problem
matrices:

cost: constraints:

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

37 /94

Double
Integrator
Example

go
to
demo

/demos/linear/doubleint.m see
also
mpcdoubleint.m ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

(Hyb‐Tbx) (MPC‐Tbx) 38 /94

Double
Integrator
Example •
Add
a
state
constraint:

•
Optimization
problem
matrices:

cost: constraints: ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

39 /94

Double
Integrator
Example

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

40 /94

Linear
MPC
‐
Tracking •
Objective:
make
the
output
y(t)
track
a
reference
signal
r(t) •
Idea:
parameterize
the
problem
using
input
increments

•
Extended
system:
let
xu(t)=u(t‐1)

Again
a
linear
system
with
states
x(t),
xu(t)
and
input
Δu(t) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

41 /94

Linear
MPC
‐
Tracking •
Optimal
control
problem
(quadratic
performance
index): optimization
 vector:

•
Note: same
formulation
as
before
(W=Cholesky
factor
of
weight
matrix
Q) •
Optimization
problem: Convex
 Quadratic
 Program
(QP) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

42 /94

Linear
MPC
‐
Example •
Plant:

•
Sampling
time:

•
Model:

go
to
demo
linear/example3.m ©
2009
by
A.
Bemporad

(Hyb‐Tbx)

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

43 /94

Linear
MPC
‐
Example •
Performance
index:

•
Closed‐loop
MPC:

go
to
demo
linear/example3.m ©
2009
by
A.
Bemporad

(Hyb‐Tbx)

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

44 /94

Linear
MPC
‐
Example •
Constraint
0.8
·
u(t)
·
1.2
(amplitude)

•
Constraint
‐0.2
·
Δu(t)
·
0.2
(slew‐rate)

©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

45 /94

Anticipative
Action

•
Future
reference
samples
(partially)
 

known
in
advance
(anticipating
action):

go
to
demo

mpcpreview.m ©
2009
by
A.
Bemporad

•
Reference
not
known
in
advance 

(causal):

(MPC‐Tbx)

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

46 /94

Measured
and
Unmeasured
Disturbances Manipulated
Variables

u(k)

Measured
Disturbances

v(k)

nd(k) Disturbance

d(k)

Model

x
(k) d

Plant Model

y(k) Outputs

Unmeasured Disturbances x(k)

Linear
model for
MPC optimization

(nd(k)
=
white
Gaussian
noise,
nd(t+k|t)=0
over
the
prediction
horizon)

more
details
about
disturbance
models
later
on
… ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

47 /94

Soft
Constraints •
To
prevent
QP
infeasibility,
relax
output
constraints:



²
=
“panic”
variable 
Vmin,
Vmax
=
vectors
with
entries
¸0
(the
larger
the
entry,
the 
relatively
softer
the
corresponding
constraint)

•
Infeasibility
can
be
due
to: –
modeling
errors
 –
disturbances –
wrong
MPC
setup
(e.g.,
prediction
horizon
is
too
short) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

48 /94

Delays
–
Method
1 •
Linear
model
w/
delays:

•
Map
delays
to
poles
in
z=0:

•
Apply
MPC
to
the
extended
system ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

49 /94

Delays
–
Method
2 •
Linear
model
w/
delays:

•
Delay‐free
model:

•
Design
MPC
for
delay‐free
model: •
Compute
the
predicted
state

•
Compute
MPC
action
accordingly:

u(t) = fMPC(¯ x(t + τ )) ©
2009
by
A.
Bemporad

For
better
closed‐loop
performance
 one
can
predict
x(t+¿)
with
a
much
 more
complex
model
than
(A,B,C)
!

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

50 /94

MPC
vs.
Conventional
Control 
Single
input/single
output
control
loop
w/
constraints:
 
 

 


equivalent
performance
can
be
obtained
with
other
 


simpler
control
techniques
(e.g.:
PID
+
anti‐windup) HOWEVER 
MPC
allows
(in
principle)


UNIFORMITY 
(i.e.
same
technique
for
wide
range
of
problems) –
reduce
training –
reduce
cost –
easier
design
maintenance
 Satisfying
control
specs
and
walking
on
water
is
similar
…
 both
are
not
difficult
if
frozen
! ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

/94

MPC
Features •
Multivariable
constrained
“non‐square”
systems
 


(i.e.
#inputs
and
#outputs
are
different) •
Delay
compensation •
Anticipative
action
for
future
reference
changes •
“Integral
action”,
i.e.
no
offset
for
step‐like
inputs

Price
to
pay: •
Substantial
on‐line
computation •
For
simple
small/fast
systems
other
techniques
dominate
 



(e.g.
PID
+
anti‐windup) •
New
possibilities
for
MPC:
explicit
piecewise
linear
forms ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

52 /94

MPC
Theory •
Historical
Goal:
Explain
the
success
of
DMC •
Present
Goal:
Improve,
simplify,
and
extend
industrial
algorithms •
Areas: •
Linear
MPC:




linear
model •
Nonlinear
MPC:
nonlinear
model •
Robust
MPC:



uncertain
(linear)
model •
Hybrid
MPC:




model
integrating
logic,
dynamics,
 






















and
constraints •
Issues: –
Feasibility –
Stability
(Convergence) –
Computations (Mayne,
Rawlings,
Rao,
Scokaert,
2000) ©
2009
by
A.
Bemporad

Controllo
di
Processo
e
dei
Sistemi
di
Produzione
‐
A.a.
2008/09

53 /94

Feasibility QUADRATIC
 PROGRAM
(QP)

•
Feasibility:
Guarantee
that
the
QP
problem
is
feasible
at
all
sampling
times
t •
Input
constraints
only:
no
feasibility
issues
! •
Hard
output
constraints: •
When
N