Anda di halaman 1dari 60

Student Thesis 197

Approximation of the convex cost functions with piecewise


affine cost functions in Model Predictive Control

Student Thesis
Junsheng Su
September 22, 2016

Examiner:
Supervisor:

Prof. Dr.-Ing. Frank Allglower


Dipl.-Ing. Florian Brunner

Institute for Systems Theory and Automatic Control


University of Stuttgart
Prof. Dr.-Ing. Frank Allgwer

Contents
1 Introduction
1.1 Overview . . . . . . . . . . . . . .
1.2 Model Predictive Control . . . .
1.3 Piecewise Linear Approximation
1.4 Convex Polytopes . . . . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

2 Problem Setup and Preliminaries


3 Piecewise Linear Approximation Of Cost Functions
3.1 Brief Introduction . . . . . . . . . . . . . . . . . . .
3.2 Upper Envelope . . . . . . . . . . . . . . . . . . . .
3.3 Convex Piecewise Linear Fitting . . . . . . . . . .
3.4 Comparison Between Two Algorithms . . . . . . .
3.5 Combined Method . . . . . . . . . . . . . . . . . .
3.6 MPC Problem For Piecewise Linear Cost Function

13

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

4 Calculation Of The Terminal Cost Function


5 Parameters
5.1 Local Controller K . . . . . . . . . . . . . . . . . .
5.2 And Pi . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Parameters For Convex Piecewise Linear Fitting .
5.3.1 Comparison Between Two CPLF Results
Different Data Point Sets . . . . . . . . . .
5.3.2 Decomposition Of The Original Function .
5.3.3 Choice Of The Data Point Set . . . . . . . .
5.4 Data Set For Upper Envelope . . . . . . . . . . . .
5.5 Algorithm For Combined Method . . . . . . . . .

15
15
16
18
20
22
23
26

. . . .
. . . .
. . . .
Based
. . . .
. . . .
. . . .
. . . .
. . . .

. . .
. . .
. . .
On
. . .
. . .
. . .
. . .
. . .

6 Algorithm
6.1 Runco . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6
6
7
9
11

30
30
30
33
33
33
35
36
37
40
40
40

Contents
.
.
.
.

41
43
44
47

7 Simulation Studies
7.1 Problem With 1-dimensional State And 1-dimensional Input
And Quadratic Cost Function . . . . . . . . . . . . . . . . . . .
7.2 Problem With 2-dimensional State And 1-dimensional Input .
7.3 Higher Dimensional Problem . . . . . . . . . . . . . . . . . . .
7.4 A Practical Model For Temperature Control . . . . . . . . . . .

50

8 Conclusions and Outlook

56

6.3
6.4
6.5
6.6

Piecewise Linear Approximation


Upper Envelope . . . . . . . . . .
Terminal Region and Its Partition
Calculation of the Terminal Cost

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

50
51
53
54

List of Figures

1.1

Model Predictive Control1 . . . . . . . . . . . . . . . . . . . . .

3.1
3.2
3.3

CPLF . . . . . . . . . . . . . . . . . . . . . .
Upper Envelope Approximation . . . . . .
Comparison between UE Approximation
function in hyperplane x (2) = 5 . . . . . .

. . . . .
. . . . .
and the
. . . . .
.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

. . . . . .
. . . . . .
original
. . . . . .

20
21

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

21

5.1
5.2
5.3
5.4
5.5

spider web structure . . . . . . . . . . . . . .


The influence of on terminal cost function
CPLF results of y = x2 . . . . . . . . . . . . .
Approximation with CPLF . . . . . . . . . . .
Approximation with Combined Method . . .

.
.
.
.
.

31
32
34
38
39

7.1

Temperature control with piecewise affine cost function and


with different quadratic cost function . . . . . . . . . . . . . .

55

List of Tables
5.1

CPLF with different parameters . . . . . . . . . . . . . . . . . .

7.1

Comparison between two methods,1D state, 1D input,quadratic


function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparison between two methods,2D state, 1D input,quadratic
cost function . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparison between two methods,2D state, 1D input,nonquadratic cost function . . . . . . . . . . . . . . . . . . . . . . .
Comparison between two methods,3D state, 2D input,nonquadratic cost function . . . . . . . . . . . . . . . . . . . . . . .

7.2
7.3
7.4

36

51
52
52
53

1 Introduction
1.1 Overview
Optimal control theory was raised by Pontryagin [23] and Bellman [1] to
optimize the process with a cost function as an index. Particularly, the
optimal control theory is aimed to solve the problem with linear dynamic
and quadratic cost function, by applying a simple solution in form of linear
state feedback derived by solving Algebraic Riccati Equation(ARE) [15].
However, the optimal control has difficulty in problems with non-linear
system or system with constraints on state and/or input, i.e. it is in most
cases impossible to get any analytic solution of optimal control problem for
these systems [16], while inputs and states of the most practical systems are
bounded. Thus, Model Predictive Control is designed to find a suboptimal
solution for such systems by calculating the optimal solution in a finite
horizon.
Model Predictive Control(MPC) ,also known as Receding Horizon Control(RHC), is a control method that reformulates a control problem with
infinite or longer time horizon into one with finite or shorter time horizon.
Moreover, it applies the optimal solution of the reformulated problem as
a current input. In regular MPC controller, the cost functions are positive
definite or even quadratic. MPC controller with a non positive definite
cost function is called Economic Model Predictive Control (EMPC). Robust
Model Predictive Control(RMPC) takes model uncertainties and focus on
ensuring the robustness of the system. Distributed Model Predictive Control
has advantages in dealing with large-scale applications, it is solved with
distributed or decentralized control schemes, where local control inputs are
computed using local measurements and reduced-order models of the local
dynamics [8].
There is since long a trade-off in MPC between computational complexity
and performance. In the last years, with the rapid growth of computational
capacity of the computers, MPC can be used to deal with many control
problems and becomes arguably the most widely accepted modern control
theory. However, there are still many control problems that the performance

1.2 Model Predictive Control


and computation can not compromise with MPC controller. A better method,
which fills the gap between computational complexity and performance of
MPC controller, is in need, such as lowered the computational complexity
with little loss of performance or in contrary.
Linear Programming problem refers to the problems involved with linear
constraints, linear cost functions. The problem has a significantly lower computational complexity than nonlinear programming. It is shown in Section
3.2 of [6] that a problem with linear dynamic, affine constraints and convex
piecewise affine cost function can be evaluated by Linear Programming. That
means, there exists the possibility to lower the computational complexity of
problems with non-linear cost function by approximating the original cost
function with convex piecewise linear cost function.
To summarize, the thesis focuses on regular Model Predictive Controller
with affine constraints, linear system dynamics and convex, positive definite
cost functions. The thesis is aimed to design a piecewise affine approximation
of the non-linear cost function for Model Predictive Control in a linear system,
and to evaluate the advantages brought by the approximation brings. The
main purpose of this chapter is to provide an overview of the basic concepts
that are used in this thesis.

1.2 Model Predictive Control


This section explains how MPC works. As shown in Figure 1.1, at each step
it solves a finite horizon open loop optimal control problem with the current
state of the plant as its initial state. As a result it gets a sequence of control
input but only applies to the first one to the plant. An important advantage
of this control method is that it can take the constraints of inputs and states
into consideration. MIn the majority of real control problems, such as these
two examples, the optimal strategy that is designed to drive from A to B,
have their natural limits. These limits include maximal thrust and maximal
speeds. LQR (Linear-Quadratic Regulator) can only provide the optimal
solution for linear system without constraints. Additionally, its optimal
solution is not always feasible for the plant. There are several textbooks for
MPC control: [16], [7] and [25]
To design an MPC controller to stabilize the system
x (k + 1) = f ( x (k),u(k))
1

quote:http://www.intechopen.com/books/advances-in-discrete-time-systems/discrete-timemodel-predictive-control

1 Introduction

Figure 1.1: Model Predictive Control1


x (k) X ; u(k) U
x (0) = x0
to the origin.
Moreover, a MPC problem at each step with terminal cost and constraints
can be described as:
N 1

minimize

J ( x,u) =

`( x (k),u(k)) + F ( x ( N ))

(1.2)

s.t.

x (k + 1) = f ( x (k),u(k)
x (k) X ; u(k) U
x( N ) X f X
x (0) = x0

x and u are the real states and the actual taken inputs. x and u are the
predicted states and strategies, x0 is the initial state at current step. The ` is
called running cost and F is called the terminal cost. The recursive feasibility
and asymptotical stability of the MPC problems should be guaranteed.Recursive feasibility indicates that, if there is a solution for its first step, i.e. there

1.3 Piecewise Linear Approximation


is at least one u that fulfills all constraints, then there is always at least a
solution for its following steps. In order to guarantee the recursive feasibility
and asymptotical stability, construction of terminal constraints and terminal
costs are often required.
Assumption 1 Assume that there exists an auxiliary local control law
u = loc ( x ) s.t.
(A1) O int(X f ) and X f is positively invariant w.r.t. x + = f ( x,u));
(A2) loc ( x ) U , x X f ;
(A3) F ( f ( x, loc ( x ))) F ( x ) + `( x, loc ( x )) 0, x X f , F is a local controlLyapunov-function.
Lemma 1.1. Suppose the original running cost function ` is positive definite,
Assumption 1 is satisfied and the optimization problem is feasible at time t=0.
Then the optimization Problem is recursive feasible and the origin of the closed-loop
system is asymptotically stable [24].
According to [24], the terminal cost function gives an upper bound to the
infinite horizon cost function with the optimal feedback,in an ideal situation,
the terminal cost should be equal to it. However, in most cases it is not
possible to calculate it even with given optimal control law.
In practical implementation, the long computation time is a disadvantage
of MPC controller. Although the computational capacity still grows very
fast, a lower computational complexity is always desired for MPC controller.
There are plenty of works on this topic [30] [26] [21].

1.3 Piecewise Linear Approximation


In many practical tasks, the solution does not need to be optimal and it
is enough to be suboptimal, the computational complexity is also a very
important factor for optimization programming when time cost is also taken
account. Though problem with linear cost function has a significantly lower
computational complexity than nonlinear programming, the cost functions
of most problems in reality are nonlinear. A well known method is to
approximate the nonlinear function with a piecewise affine function [13].
The final solution for approximating problem in most situation is suboptimal.
However, it reduces the computational complexity, and takes much less time.
In this thesis, problems with convex nonlinear cost function and linear
dynamic are considered.

1 Introduction
Definition 1.2. [4]A function f : X R,X R N is convex, if its domain X is
convex and for any R that 0 1 , x,y X , there is
f (x + (1 )y) f ( x ) + (1 ) f (y)
There has been much researches for fitting problems. The purpose of
fitting problems is to describe (fit) a point set X : ( x,y),x Rn ,y R with
a given group of functions f F : Rn R as precisely as possible. Generally speaking, there are two types of fitting: interpolation and smoothing.
Interpolation is one fitting method, which requires y = f ( x ),( x,y) X,
smoothing is more flexible, so that it could keep a higher degree of freedom.
The references for piecewise affine approximation is vast. In 1969 Bellman
and Roth [2] fit the curves by segmented straight lines. E. Sontag [27] began
to approximate non-linear systems with piecewise linear systems. Milsener
and Floudas [22] provided a literature review until 2010 in this field and
introduced a method of piecewise linear approximation that applies to 2and 3-dimensional non-linear functions. Azuma et al. [14] developed a
method called Lebesgue Piecewise Affine Approximation of Non-linear Systems. Chow et al. [18] proposed a procedure for obtaining piecewise affine
autoregressive exogenous (PWARX) models of non-linear systems. However
many of them are only applied to 1 or 2 dimensional situations. For example,
the piecewise affine interpolation mentioned in [10] is only valid for 2 dimensional functions. Most of the approximation methods are to solve fitting
problems that are dependent on the chosen points. This introduces a bias
and makes the quality of approximation strongly dependent on the points
we choose. Given a cost function f : Rn R and an ordered set of points
X = ( x1 ,x2 ,...,xm ) X ... X ,X Rn , define Data Point Set should be
an ordered set of points, that is, (X, f (X)) := {( x1 ,y1 ),( x2 ,y2 ),...,( xm ,ym )},
the piecewise affine approximating problem can be described as
minimize k F f k
Li ,li

s.t.

(1.3)

F Fp
F p = {h : Rn R| Li R1n ,li R,i N[1,p] :

x Rn ,h( x ) = max{ Li x + li |i N[1,p] }


Where k k means norm of a vector. If it is a interpolation problem, then
there should be one more constraint: yi = F ( xi ) i N[1,m] .It is slightly
reformulated from the problem for convex piecewise linear fitting in [29].

10

1.4 Convex Polytopes


Where F defines a set of piecewise affine functions over X . Generally the
result k F f k can not be obtained directly because there are infinite many
points in domain, this necessitates the need for an indicator to measure it.
Theoretically, if the number of affine functions r L , i.e the row length of L, is
equal to the number of data points, F ( xi ) = f ( xi ) can be achieved, therefore
for interpolation problems, we can choose some larger, homogeneously
distributed point set ( x k ,y k ), y k = f ( x k ), k N[1,m1 ] in X , and calculate
m
k=1 1 k F ( x k ) f ( x k )k2 to estimate the accuracy of the approximation, while
for smoothing problems, the Data Point Set itself can be used to do the
estimation.

1.4 Convex Polytopes


The concept " convex polytope " is repeatedly used in the thesis.A convex
polytope is a bounded convex set of some dimension bounded by hyperplanes [19]. In following context, polytope always means convex polytope.
Mathematically it can be described by finite linear equalities and inequalities:
P = { x Rn | a Tj x b j ,j = 1,...m,c Tj x = d j j = 1,...,p}

(1.4)

Simplexes are a special family of polytopes. A n-dimensional simplex is


built by n+1 affinely independent points v0 ,...,vn , i.e. vn v0 ,...,v1 v0 are
linearly independent [4].A simplex determined by them is given by
S = convh{v0 ,...,vn }

(1.5)

Notation:For natural numbers a,b N,with a b,the set { a,a + 1,...,b}


is denoted by N[ a,b] .
Convex hull of a set X Rn is denoted by convh(X)
Row length of a matrix M is denoted as rM , column length cM
The i-th column and j-th row of matrix M is denoted as in Matlab in this
thesis:M(: ,i ) and M( j, :). The last element of a column, a row or a vector is
denoted as M(: ,end), M(end, :) and x (end).

11

1 Introduction
max(v) = max vi , i f v = (v1 , . . . ,vn )>
i N[1,n]

lmn ,l Z means a matrix of dimension m n that only contains l,for


example 1mn only contains ones.
Denote A B the Kronecker product of A and B. Denote Amn := 1mn
A, where A is a matrix.
0 in matrix means a zero matrix of appropriate dimensions.
For matrices A,B Rnm and vectors a,b Rn , inequalities of the form
A B and a b are to be interpreted element-wise.

12

2 Problem Setup and Preliminaries


Consider a linear system,
x (k + 1) = Ax (k) + Bu(k)
x (k) X Rn ,u(k) U Rm

X and U are polytopes with origin in their interiors, denote f ( x,u) :=


Ax + Bu.
An original MPC controller is given to stabilize it to the origin while
constraints of the system are taken into consideration. A proper, i.e. in its
domain convex, bounded, positive definite running cost function at each
step ` : Rn+m R,( x (k),u(k)) y,x (k) Rn ,u(k) Rm , and a proper
terminal cost function F ( x ( N )) are given. If the running cost function is
not quadratic, then the terminal cost function F ( x ( N )) is calculated as [6]
introduced. The accordingly MPC problem can be described as (1.3).
As mentioned in Chapter 1, to be designed is a MPC controller with linear
system, piecewise affine cost function, the constraints and stability of the
original controller should be guaranteed and the sub-optimality should be
controlled in a comparable level. Additionally, it is necessary to find an
affine local feedback, including a terminal region in form of polytope, a
piecewise affine running cost function and piecewise affine terminal cost
function.
The terminal region and affine local controller can be calculated as discussed in [12]:
: X f U : ( x ) = Kx.
so that satisfies Assumption 1.
The closed-loop system under the local controller is defined by
x + = f ( x, ( x ))

= ( A + BK ) x := Ak x i f x X f

13

2 Problem Setup and Preliminaries


Then solve the problem (1.3) and construct a positive definite, convex, piecewise affine running cost function

  


x
L( x,u) = max Li
+ li i N[1,pL ]
(2.1)
u
and define an appropriate piecewise affine terminal cost function

n
o

F ( x ) = max Vk x + vk k = N[1,pV ]
so that the origin is asymptotically stable for the close-loop system.
With this two approximating functions, the problem (1.2) can be reformulated as a MPC problem with piecewise affine cost function:
N 1

minimize

J ( x,u) =

L( x (k), u(k)) + F ( x ( N ))

(2.2)

k =0

s.t.
x (k + 1) = Ax (k) + Bu(k)
x (k) X ; u(k) U
x( N ) X f X
x (0) = x0
The terminal cost function F : Rn R : max(Vk x + vk ) is calculated with
method introduced in [6]. In this thesis, the main focus is on the piecewise
affine approximation of the original cost function `.

14

3 Piecewise Linear Approximation Of Cost


Functions
3.1 Brief Introduction
In [6] with a stabilizing controller and a convex running cost function, a
piecewise affine terminal cost satisfying Assumption 1 can be constructed.
To define a MPC problem that can be solved with linear programming, a
piecewise affine approximation for the running cost function is still required.
When the original running cost function is in its domain positive definite
and convex, the approximating function should also preserve these properties. The most established fitting methods are evaluated by their accuracy
and do not ensure to preserve particular properties. For example, k-Plane
Clustering that is introduced in [5] can not either preserve convexity or approximate the original function correctly. Piecewise linear fitting introduced
in [20] cannot ensure the positive definiteness around the origin, because
this algorithm does not ensure that L( x ) `( x ) and L( xi ) = `( xi ) for xi are
given data points.
Methods can be chosen with flexibility according to different instinct advantages and disadvantages. The purpose is not to make the approximation
as accurate as possible.In fact, the purpose is to improve accuracy with
limited number of affine functions, and preserving the properties needed.
Let p a be the number of data points and p the number of affine functions, y = (y1 ,...y pa ) is a vector, its element yi is the corresponding original
function value to the data point xi . Similarly, ya = (ya,1 ,...ya,pa ) is a vector
of approximating function value. In order to evaluate the efficiency of the
method, an efficiency index is defined as follows.
Ieff := ky ya k2 p/pa
What worth mentioning is that the comparison between two efficiency
indexes is only meaningful when it is compared with the same original
function and the same domain. Moreover the number of points does not

15

3 Piecewise Linear Approximation Of Cost Functions


influence the efficiency of the online control. Therefore, as far as the calculation of approximating function is not infinite, the number of points is not
limited.

3.2 Upper Envelope


The following part describes the method proposed in [9], called Upper
Envelope therein.A convex interpolation F of a given point set (X, f (X)),in
which X = { x1 ,...,xm | xi X },X Rn is an ordered set,and f : Rn R
is a mapping that is convex in X , is any convex function, that fulfills
F (X) = f (X). The Upper Envelope is known as the maximum of all convex
interpolants. That means, it has the maximal function value among all the
convex interpolants. Denote F ( x ) as arbitrary convex interpolant and U ( x )
as the upper envelope of (X, f (X)), there is
F ( x ) U ( x ), x convh(X).
Given the convex data (X, f (X)), its upper envelope can be defined as:
u(|(X, f (X))) : Rn R,
m

i =1

i =1

i =1

u( x |X, f (X)) = min{ i f j | i = 1,i 0,1 j m, i x j = x }


The domain of the original Upper Envelope is the convex hull of the given
point set. And it should be modified in the form of (2.1):
Find a matrix L = [( L1 ,l1 )> ,( L2 ,l2 )> ,...( Lr L ,lr L )> ]> ,Li Rn ,li R, i
N[1,r L ] , s.t.

x convh(X),
max(L[ x > ,1]> ) = u( x |(X, f (X)))
Define Um ( x ) = max(L[ x > ,1]> ) for x Rn .
Definition 3.1. Define a n-dimensional state space as below:
Let xi, min ,xi, max R,for i N[1,n] ,where xi, min < xi, max , ni 2 N,
xmax = [ x1, max ,x2, max ,...,xn, max ]> ,
xmin = [ x1, min ,x2, min ,...,xn, min ]> , n = [n1 ,n2 ,...nn ]>

16

3.2 Upper Envelope


Define a n1 n2 ... nn grid G( xmax ,xmin ,n) as a n1 n2 ... nn n
Tensor, with

G(i1 ,i1 ,...,in , :) =( x1, min + (i1 1) x1,d ,x2, min + (i2 1) x2,d , ...,xn, min
+ (in 1) xn,d ), i1 N[1,n1 ] ,...,in N[1,nn ]
and
xi,d =

xi, max xi, min


.
ni 1

A grid is handled as a set of n-dimensional points. Gi1 ,i1 ,...,in = G(i1 ,i1 ,...,in , :) is
its element.
Upper Envelope of the grid is denoted by uG () = u(|(G , f (G))).To
calculate the L in MatLab, the following algorithm is designed: for any
x G , and xi 6= xi, max , where xi is the i-th coordinate of x. Let xi+ =
( x1 ,x2 ,...,xi + xi,d ,...,xn ), obviously, ( xi+ ,uG ( xi+ )) (G ,uG (G)). The simplex
defined by n + 1 vertexes {( x,uG ( x )),( x1+ ,uG ( x1+ ),...,( xn+ ,uG ( xn+ ))} represents the Upper Envelope and is of dimension n. Then, it holds that
uG ( x ) = Ax + b for all x S, where A and b are uniquely determined (S is
the name of this simplex).
Proof. Denote UG = (uG ( x ),uG ( x1+ ,...,uG ( xn+ )), X = ( x,x1+ ,...,xn+ ). Let the
possible equality constraints for the simplex be y = Ax + b, ( x,y) are the
points in simplex,x Rn ,y R,A R1n ,b R, all the vertexes of the
simplex should fulfill this equality, denote B = b1(n+1) , there is:
> ,1n1 )> ,
UG = AX + B = ( A,b)(X
2 : X 2 (: ,i ) = (X
> ,1n1 )> (: ,i ) x, it is easy to see that
Define X
x1,d

..

2 =
X

.
xn,d

1
is of full rank, hence so is (X > ,1n1 ) and ( A,b) = (X > ,1n1 )> UG has the
only solution, that is, A and b are uniquely determined.
Proof completed.

17

3 Piecewise Linear Approximation Of Cost Functions


The equality can be obtained with the toolbox mpt3 [17] with command
S.Aeq , S.beq. Rewriting it as Aeq (n + 1)uG ( x ) = Aeq (1 : n) x beq , the
( L x ,lx ) pair for the region in the simplex can be obtained with L x = S.Aeq(1 :
n)/S.Aeq(n + 1), l x = S.beq/S.Aeq(n + 1). After calculating ( L x ,l x ) pairs
for all x X,xi 6= xi, max , Um can be obtained. The domain can be arbitrarily
chosen with Um .
Lemma 3.2. Assume that the original function is convex, positive definite in
its domain. The modified Upper Envelope u : Rn R preserves the positive
definiteness and convexity, if the chosen data set contains the origin, and the origin
is an interior point of convh(X).
Proof. x X Rn , because of the convexity, u( x |(X, f (X))) = min in=+11 i
f ( xi ), xi X,i 0, in=+11 i = 1}, there is always u( x |(X, f (X))) = f ( x ).
0 X, u(0|(X, f (X))) = f (0) = 0;
x convh(X), there is Um ( x |(X, f (X)) = iN[1,m] i f ( xi ), xi X. Because i 0, f ( xi ) > 0,Um ( x |(X, f (X)) > 0 for x 6= 0.
x
/ convh(X), a x closed enough to the origin and > 0 R can be found,
so that there is a

{( L,0) L|Um (0|(X, f (X))) = L 0,Um ( x |(X, f (X))) = Lx },L Rn


L
and x = x. And this make Um ( x |(X, f (X))) = maxri=
1 ( Li x + li ) Lx =
Lx > 0.

3.3 Convex Piecewise Linear Fitting


Convex piecewise linear fitting (CPLF) introduced in [20] is a method that
attempts to locate the best fitting for m data points (X, f (X)) with a convex
piecewise affine function that consists of p affine functions. This is defined
by the function:
F ( x ) = max { ai> x + bi }
(3.1)
i =N[1,P]

So the fitting problem to be solved can be written in the form of a leastsquares problem:
minimize

J=

i N[1,m]

2
(max( a>
j xi + b j ) f i )
j =1

with a j Rn and b j R, f i = f ( xi ),xi X.

18

3.3 Convex Piecewise Linear Fitting


To solve it, the following algorithm which is adapted from [20] can be
used:
Step 1 Randomly choose points u1 ,...u p from X, and define initial partition to be the Voronoi sets associated with these points,
(0)

P j = {i |k xi u j k k xi uk k,xi X,i N[1,m] k N[1,p] },j N[1,p]


(3.2)
It can be revealed from the above analysis that the points in X are reassigned
into p groups, the i-th group consists of points that are closest to ui among
all chosen points u1 ,...,u p .In order to avoid the situation that one point is in
(0)

more than one partitions, for any i P j , if i

(0)

k N[1,j1]

(0)

{Pk }, then i
/ Pj .

(l )

For l-th partition P j , there is a unique pair ( a j ,b j ) to solve the

Step 2

( a > x i + b f i )2 :

problem minimize

(l )

i P j

xi xi>

"

alj
blj

(l )
i P j

(l )

xi>

xi

(l )
|P j |

(l )
i P j

iP(j l )

fi

i P j

if

xi xi>

(l )
i P j

(l )

xi>

xi

(l )
i P j

(l )
|P j |

f i xi

(3.3)

(l )
i P j

is not singular. Otherwise an additional quadratic

i P j

term k a||22 + b2 can be added to the problem. In this step p ( a j ,b j ) pairs are
obtained.
Step 3 For the next iteration, there is defined a new partition
( l +1)

Pj

= {i |( alj> alk> ) xi + blj bkl 0,i N[1,m] k N[1,p] }


( l +1)

j N[1,p] , it means, for i Pj


max ( al xi
kN[1,p] k
( l +1)
i
/ Pj
.

, ( alj ,blj ) is ctive", i.e. alj xi + blj =


( l +1)

+ bkl ). Again, for any i P j

, if i

kN[1,j1]

( l +1)

{Pk

}, then

19

3 Piecewise Linear Approximation Of Cost Functions


Step 4 The iteration of Step1 to Step 3 is performed several times, and
then calculation of the RMS (Root-Mean-Square) of the result:
RMS = ( J/pa )0.5
Step 5 Repetition of step 1 to step 4 is performed several times, and
chosen is the ( a j ,b j ) with best(smallest) RMS.
The result obtained from CPLF is not the optimal solution, but (in most
cases) is a good solution to the fitting problem.In Figure 3.1 below the CPLF
approximation of y = x2 , 10 x 10 with 10 "pieces" affine functions.
100
Approximation
Original Function
80

60

40

20

20
10

10

Figure 3.1: CPLF

3.4 Comparison Between Two Algorithms


The Upper Envelope can keep all the properties needed and can be arbitrarily
accurate. However, the number of affine functions is nearly proportional
to the number of data points. Moreover, it is less accurate with few affine
functions. Thus, this method is very inefficient. In Figure 3.2 is an Upper
Envelope approximation of function `x ( x ) = | x |22 ,x R2 consisting of 100
affine functions. In Figure 3.3 is a comparison between the approximation
and the original function in a chosen hyperplane. It takes much less time
to calculate the result of UE than of CPLF. If the number of " pieces " in the

20

3.4 Comparison Between Two Algorithms


piecewise affine function, denoted as r L is not limited, UE is a simple and
efficient method to do the piecewise affine approximation.
50
45
40
35
30
25
20
15
10
5
0

Figure 3.2: Upper Envelope Approximation


1.2

104

UE
original function

0.8

0.6

0.4

0.2

0
100

80

60

40

20

20

40

60

80

100

Figure 3.3: Comparison between UE Approximation and the original function in hyperplane x (2) = 5
As an example consider the approximation of the function

`( x,u) = | x |22 + u2 ,x [50,100] [50,100] R2 ,u [5,10] R.


The efficiency index Ieff of the upper envelope, measured by G((100,100,15)> ,
(50, 50, 5)> , (150, 150, 15)> ) with 64 affine functions is 1472, while the

21

3 Piecewise Linear Approximation Of Cost Functions


Ieff of CPLF with only 5 affine functions is 99. The latter method with only 5
affine functions is already more accurate than the upper envelope with 64
affine functions.
In order to get a piecewise affine function with m affine functions with
CPLF, the number of data points needed are much higher than m. Also,
the time for offline calculation increases with the number of data points.
Additionally, the more data points included, the better the results generated
with CPLF. It takes longer than 1 hour to calculate a piecewise affine function
consisting of 40 affine functions based on 1331 data points.
Furthermore, since CPLF does not deal with the positivity, its positive
definiteness cannot be guaranteed. The simplest solution is to add a 0a
hyperplane into the original affine functions ( aiT ,bi ), i.e. (b p+1 ) = 0 Rn+1 .
p +1

However it will only ensure the positive semi-definiteness. In order to make


sure that the controlled states finally converge to the origin, the combination
of these two methods is required.

3.5 Combined Method


The positive (semi-)definiteness is not very likely to be hold for {u|k f (u)k 
max | f ( x )|,x X }, because the error | LCPLF(u) f (u)| is still very insignificant for the whole approximation, even though LCPLF(u) < 0. For a CPLF
for convex positive definite function, the region in which positive definiteness does not hold, will be a neighborhood of the origin, because for such
functions, the minimum of the function value is at the origin, and the farther
is the point away from the origin, the larger is its function value.
Let the result of Step 1 to Step 4 of CPLF with an appropriate data set, that
means, a data set that homogeneously or almost homogeneously distributed
in domain, be ( Lci ,lci ), N[1,sc ] . It is first amended with lci = 0, if lci > 0 so
that max( Lci 0 + lci ) = max(lci ) = 0 to avoid the situation, that max( Lci 0 +
lci ) > 0, and then denoted as Lc = {( Lci ,lci )},i N[1,sc ] . The result of
Upper Envelope with another data point set that satisfies the assumptions in
Lemma 3.2 be denoted as Lue = {( Luej ,luej )},j N[1,su ] . The data point set
for UE should be chosen in a relatively small neighborhood of the origin, so
> ]t op [ x > ,1]t op ) =
that the region will not be too large, in which max([Lc> ,Lue
>
t
[ Luej ,luej ][ x ,1] op, j N[1,r L ] . Additionally, the combined method will
UE
not be overapproximated. Moreover, the data point set should be with
relatively less number of points. Thus, the row length of Lue will not
be too large and the efficiency of the approximation will not be lowered.

22

3.6 MPC Problem For Piecewise Linear Cost Function


The choices of data point set for CPLF and UE are discussed in detail in
Section 5.3.3 and 5.4.The result of combined method would be described as
`( x ) = max{ Lx + l |( L,l ) Lue Lc }.
For all positive definite f ( x ), its apparent that `(0) = max( Lx + l ) =
max(max(lci ), max(luej )) = 0, and `( x ) max( Luej x + luej ) > 0 for x 6= 0.
`( x ) is positive definite.

3.6 MPC Problem For Piecewise Linear Cost Function


The problem (2.2) should be rewritten with equalities and inequalities that
consist of matrix and vectors, so that it can be programmed. Let X =
{ x R n | A X x bX } , U = { u R m | A U u bU } , X f = { x R n | A X f x
 
x
bX f },L( x,u) := max( L
+ l ),L Rr L (n+m) ,l Rr L is the piecewise affine
u
approximation of the running cost function, max Vx the piecewise affine
terminal cost. In this section, denote M j the j-th row of the matrix M. The
problem can be described as below:
N 1

minimize
c p ,c N ,u p


s.t.

Li

c p + cN ,

(3.4a)

p =0

xp
up

+ li s p 0

Vk x N + vk c N 0

(3.4b)
(3.4c)

i N[1,r L ] ; k N[1,rV ]
x p X , u p U ,x N X f ,x0 = x0 ,

(3.4d)

x p+1 = Ax p + Bu p ,p N[0,N 1]

(3.4e)

N is the horizon of the MPC controller, c0 ,...,c N R. It can be seen that the
dimension of the parameter is (m + 1) N + 1.While the number of inequalities
for (1.2) would be decided by the original problem and the horizon and
there would be pr N + pn N inequalities for (3.4b) and (3.4c). Therefore it is
necessary to limit the number of affine functions for the piecewise affine
functions, otherwise, the computational complexity is probably too large to
be calculated. It is apparent that this method is also under negative influence
from the "curse of dimensionality" because of the discretization of state space.

23

3 Piecewise Linear Approximation Of Cost Functions


The relation between the performance of the controller and the number of
affine functions is also taken account in this work.
With X = { x Rn | AX x bX }, U = {u Rm | AU u bU }, problem (3.4) can be reformulated into a linear problem, its variables are ui
Rm ,i = 0,...,N 1, c j R,j = 0,...,N, in program its written as z =
> R N (m+1)+1 . X = ( x > ,...,x > )> can be calculated
(u0> ,...,u>
N
N 1 ,c0 ,...c N )
1
>
>
with U = (u0 ,...,u N 1 )> :
X = U + x0

with

AB
..
.

A N 1 B

..
.

0
..

0
B

and

A
A2
..
.
AN

Let
F = [01m ,11(n+1) ],

Lu
Lx B

0
Lu

0
0
..
.
..
.
Lu
VB

L AB

Lx B

L x = L(: ,1 : n),
x
Aineq11 =
,
..
..
..

Lu = L(: ,(n + 1) : (n + m))

.
.
.

L x A N 2 B

Lx B
VA N 1 B
VAB

1r L 1

..
Aineq12 =
, Aineq12 Rr L ( N +1)( N +1)
.
1r L 1
Aineq1 = [ Aineq11 ,Aineq12 ]

24

3.6 MPC Problem For Piecewise Linear Cost Function

Aineq2 =

AU
..

0 Nr A ( N +1)
U

AU
>
>
Aineq = [ Aineq1
,Aineq2
]>

l Lx0
..

bineq = l LA N 2 x
0

v VA N 1 x
0
( bU ) N 1

Problem (3.4) can be written as:


min
s.t.

Fz

Aineq z bineq
x 0 = x0

25

4 Calculation Of The Terminal Cost Function


In order to construct an MPC problem with piecewise affine cost function, a piecewise affine terminal cost that fulfills Assumption 1 should
be constructed. Given a partition of the terminal region Xif X f ,
i N[1,M]

i N[1,M]

Xif = X f , int(Xif X jf ) = , i,j N[1,M] ,i 6= j , where Xif and X f are

polytopes, solve one of these two problems in [6] to get F : X R, x


Vi x + vi , if x Xif :
Problem 4.1 Pi := extreme(Xif ),Pij := extreme(Xif Ak1 X jf )i,j N[1,M]
minimize
Vi ,vi

i N[1,M] pPi

Vi p + vi

(4.1a)

vi = 0

(4.1b)

subject to

i such that 0 Xif :


i,j N[1,M] : p Pij :

Vj Ak p + v j Vi p vi + L( p, ( p)) 0

(4.1c)

i,j N[1,M] : p Pi :
Vi p + vi Vj p + v j

(4.1d)

where extreme() means the extreme points of a polytope. Problem 4.2 Let
Xif = { x Rn | Gi x gi },i N[1,M] .
minimize
ti
ti ,Vi ,vi ,Hit ,Hijd ,Hijc

i N[1,M]

subject to

i,j N[1,M] : Hit 0, Hijd 0


Hit Gi = Vi , Hit gi ti vi

i such that 0 Xif : vi = 0

26

i,j N[1,M] such that


f

Xif Ak1 X j 6= :


Gi
Hijd
= Vj ( Ak ) Vi + Li
G j Ak
 
g
Hijd i li + vi v j
gj
Hijc 0

i,j N[1,M] :
Hijc Gi = Vj Vi ,Hijc gi vi v j
Generally, computational complexity of Problem 4.2 can be very large. If
there are N (N > M) inequalities for all convh(Xif ), the maximal dimension
of Problem 4.2 could be M + Mn + M + N + 2N M2 + N M2 , the minimal
dimension is M + Mn + M + N + 2N M + N M2 if and only if for every
i N[1,M] , a j N1,M can always be produced, which leads to x

Xif , Ak x X jf . The dimension of the problem is superlinear to M3 . For


example, division of X f into 20 neighboring triangles in 2-dimensional
space, that is, M=20 and N=60, the maximal dimension is 72140 and the
minimal dimension is 27280. In this thesis, only Problem 4.1 is solved.
It is remarkable that the results of Problem 4.1 for the original and the
approximating MPC problem should be calculated separately, because the
running cost functions are different.
However, the Problem 4.1 is not guaranteed to have a feasible solution.
In order to ensure the feasibility of Problem 4.1, we need to construct a
partition Xif X f ,i N[1,rV ] , so that X f X , int(Xif X jf ) = for i 6= j,
S
i N[1,rV ]

Xif = X f , and X f is a convex, compact set.

Assumption 4. There is a [0,1), so that


Ak P P

(4.3)

, where P is the smallest, proper polyhedral C-set defined by

P = { x Rn | j N[1,rV ] : FjP x 1},


and X f P .

27

4 Calculation Of The Terminal Cost Function


Lemma 4.1. Let f : Rn R be a convex positive definite function, and let
P = { FiP x 1,i N[1,m] } be a bounded set, let further c = max f ( x ), then it
x P
holds that

f (x)
max FiP x

c.

i N[1,m]

Proof. There is max FiP x > 0, for any x P \{0}.Because if it is not so,
i N[1,m]

there will be > 0,y = x, max FiP y 0,y P and P is not bounded.
i N[1,m]

There is max{

f (x)
| x
max FiP x

i N[1,m]

P , max FiP x = 1} = max f ( x ) = c.


i N[1,m]

Every point x P \{0} can be interpreted as x = 1 x = 1 x + 2 0, 1 , 2


0, 1 + 2 = 1, max FiP x = 1, with x = x/( max Fi x ). Because of the
i N[1,m]

i N[1,m]

convexity, there is f ( x ) = f (1 x + 2 0) 1 f ( x ) + 2 f (0) = 1 f ( x )


and max FiP x = max 1 FiP x = 1 . Hence it holds that
i N[1,m]

f (x)
max FiP x

i N[1,m]

f (x)
max FiP x

i N[1,m]

c.

i N[1,m]

Proof completed.
Theorem 4.2. Suppose Assumption 4 holds, Problem 4.1 has feasible solution
for

Xif = Pi X f ,

(4.4)

with Pi = { x Rn | j N[1,rV ] : FiP x FjP x, FiP x 1}.


Proof. Let [0,) with

1
max `( x, ( x )), x P ,
1 xP

(4.5)

where `( x,u) is the running cost. According to Lemma 4.1, for x Xif ,
(1 ) FiP x `( x, ( x )). Define a function V : Rn R by V ( x ) = FiP x,
if x Xif . Assume x Xif Ak x X jf , it follows from Assumption 4 that

28

FjP Ak x FiP x and


V ( Ak x ) V ( x ) + `( x,x ) FjP Ak x FiP x + (1 ) FiP x

( + (1 )) FiP x
= 0.
Hence V ( x ) = FiP x is a feasible solution for Problem 4.1.
Proof completed.
This method is slightly modified from Theorem 5 in [6], in which the
construction of S is unnecessary. Moreover, it worth mentioning that
X f is independent from , but the largest positively invariant set w.r.t.
x (k + 1) = Ak x (k) considering the system constraints. Any further partition
Pij and Xijf = Pij X f based on (4.4), that is, if i N[1,rV ] ,j N[1,p p ] ,Pij

Pi ,int(Pij Pik ) = , j 6= k,

pp
S
j =1

Pij = Pi , always makes Problem 4.1 feasi-

ble.

29

5 Parameters
The controller is designed on Matlab with help of add-on mpt3 [17] and
cplex [11]. In this chapter we describe the parameters that are used in
algorithm.

5.1 Local Controller K


There is an optimal local controller for the problem with time-discrete linear
dynamic and quadratic cost function. In Matlab it can be calculated with
command "dlqr". For problem with non-quadratic cost function, the pole
assignment can be applied. For time-discrete problem, the poles should be
assigned as | pi | < 1,i N[1,n] ." Alternatively, "dlqr" with appropriate Q and
R can still offer a well defined local controller.

5.2 And Pi
Lemma 5.1. = max(| Ak |), where Ak are the eigenvalues of Ak , is the smallest
possible , so that (4.3) is satisfied.
The proof that the choice = max(| Ak |) is possible can be found in
Lemma 1 of [3], with A = Ak and B = 0. And the proof that the choice
< max(| Ak |) is impossible can be found in [12], let Ak1 = Ak /, then
max(| Ak1 |) = max(| Ak /|) > 1.
However, max(| Ak |) is in most cases not a good choice for . Because it
introduces a large number of constraints in P , and therefore too many Pi .
The dimension of V would be too large, thus the dimension of problem (4)
would have too many constraints.
The terminal cost function is defined on P but its domain is X f . Hence
X f P should be satisfied, or the terminal cost function is not defined
for some x X f . This condition can be interpreted as FjP x 1, x X f .
Because P and X f are both convex, only the vertexes of X f are required to
be checked.

30

5.2 And Pi
In this thesis, Pi are chosen to be in form of a spider web structure
which have la layers. The Pi in 4.4 is further devided into Pij , so that
j 1

Pij = { x Rn |k N[1,rV ] : FiP x FkP x,FiP x la ,FiP x la }, j = 1,...,la .


In Figure 5.1 below we depict a spider web structure, with n = 2 and P is
divided into 6 5 pieces.

Figure 5.1: spider web structure


The next the relation between the conservaivity of the terminal cost function and would be discussed. An example is chosen here.




1 1
0.5
x ( k + 1) =
x (k) +
u(k)
(5.1)
0 1
1





1 0
J ( x,u) = x T
x + u2
0 1
i =1
x (k) [100,100] [100,100]

5 u 5
The local
 controller is calculated
 by the function dlqr:
0.6917
0.3648
Ak =
and the largest eigenvalue of it is 0.2904. The
0.6167 0.2703
conservatism of the piecewise affine terminal cost calculated after Chapter 4
is remarked by the largest function value in terminal region. Again, because

31

5 Parameters
V(x) is a convex function and terminal region is a polyhedral which is also
convex, only the terminal cost of the vertexes of terminal region are required
to be checked. And the result is represented in Figure 5.2. The conservatism
is not monotonicallly increasing or decreasing to . Theoretically, a less
conservative terminal cost can result in a non-optimal solution, especially
when u weights more in cost function. On the other side, generally, the
smaller is, the larger the dimension of V is, and thus the longer online
calculation takes.
2.5

105

maximum of the terminal cost

1.5

0.5

0
0.4

0.45

0.5

0.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

lambda

Figure 5.2: The influence of on terminal cost function


In order to get P , a random bounded initial constraints for x is required,because without an initial constraints, Rn itself is a set that satisfies (18) for
any R\{0}. In this thesis, the system constraints x X and Kx U
are applied in form Ai x 1. For k = 1,2,..., Pk = { x Rn |( Ak /) j Ai x
bi ,j = 1,...,k}. Find the smallest k = k N, so that Pk +1 = Pk , Denote P := Pk . Denote Ak, := Ak ,the absolute value of its eigenvalues
( Ak, < 1) for 0 < < max(| Ak |), it is proved that P is finitely determined in [12], and P satisfies (18). It is apparent that

32

5.3 Parameters For Convex Piecewise Linear Fitting

P = { x Rn |( Ak /) j Ai x bi ,j = N[1,k ] } also satisfies (18) for all


f

R+ . Let xi ,i N[1,m] be extreme points of X f , where m is number of


extreme points. Find P = P1 , where
f

1 = max , s.t. Ai xi 1,i N[1,m] ,


i.e. P is the smallest possible P , so that X f P . [12]
The number of layers la is also a parameter for the definition of Xi . If rV is
too large, then the time cost of MPC control would be expensive. Denote c as
the number of constraints for P , we have rV = cla . The range of la is limited
by c. Generally, c increases with n. for a 5-dimensional x, the calculation of
P and the resulting MPC control would be very slow even when la = 1.

5.3 Parameters For Convex Piecewise Linear Fitting


In this section, parameters for CPLF are discussed, but the combined method
is actually used in the examples.

5.3.1 Comparison Between Two CPLF Results Based On


Different Data Point Sets
The "best RMS" acquired from Step 5 in Section 3.3 can not be used to
compare the performance of two CPLF results based on different data point
sets. A simple example is given in Figure 5.3
In this example, the RMS of 5.3(a) is 0 and of 5.3(b) is 0.5. However,
when the RMS of 5.3(a) is calculated with data point set in 5.3(b), it will
be 0.63, larger than the RMS of 5.3(b). Therefore when two CPLF results
based on different data point set is compared, their RMS should be at least
calculated with the union of their data point sets, and the result would be
more reliable, when the point set for RMS contains points that are not used
in the calculation of CPLF functions.

5.3.2 Decomposition Of The Original Function


Definition 5.2. Let f be mappings Rn R, f 1 ,... f m be mappings f i : Rni
i
R,ni N[1,m] ,i N[1,m] , Ni Nn[1,n
, x = { xi |i Ni } .If f : ( x1 ,...,xn ) 
] Ni
f 1 ( x N1 ) + f 2 ( x N2 ) + ... + f m ( x Nm ), f 1 ,... f m is called a decomposition of function f

33

5 Parameters

(-2,4)

(2,4)

(-2,4)

(2,4)

(-1,1)

(1,1)
(0,0)

(0,0)
(a) Approximation with 3 data (b) Approximation with 5 data
points and 2 affine functions
points and 2 affine functions

Figure 5.3: CPLF results of y = x2


and f is decomposed into f 1 ,..., f m . It is remarkable that im=1 ni n and Ni Nj
does not need to be for i 6= j,i,j N[1,m] .
A function of higher dimension should be approximated with a piecewise
affine function consisting of a large number of affine functions. CPLF works
out in 5 minutes on the computer used for the simulations with 8 GB RAM
and AMD E1-1200 APU with Radeon(tm) HD Graphics 1.40GHz, when the
size of data set is smaller than 1000 and the requested number of affine
functions pr is smaller than 40. For finer data nets and more pieces of
linear functions, it works much slower. While the MPC controller can still
calculate the strategy in 0.1 second on the same computer for pr = 500,
the CPLF lasts longer than 1 day. Therefore a reduction of the dimension
is required, whether the original running cost function `( x,u) : Rn R
can be decomposed into several independent parts `i : Rni R, makes a
great difference. If the function can be decomposed into several independent
functions and approximated separately, the whole approximation could be
much more accurate. (5.1) can still be used as a simplest example here. If
the `( x,u) is approximated with a 8 8 8 grid as its data point set and
with 40 affine functions, the resulting best RMS is about 1300. And if the
` x = x 0 Qx is approximated with 21 21 grids as its data set and 20 affine
functions, `u = Ru2 is approximated with 101 homogeneously distributed
points as its data set and 8 affine functions, its best RMS will be about
300, and the resulting approximating function `( x,u) consists of 160 affine

34

5.3 Parameters For Convex Piecewise Linear Fitting


functions. Moreover, it is noteworthy that if the data points are too few,
the resulting number of affine functions may be not as many as requested
and generally, pr 6= r L , where pr the requested number and r L the resulting
number of affine functions of which the piecewise affine function consists.
A more complicated example is given by the function,

`( x,u) = x12 + x2 x3 + x22 + x33 + 2x1 u1 + 4u21 + u22 .


This cost function is first decomposed as `( x,u) = `1 + `2 + `3 , where
`1 = x12 + 2x1 u1 + 4u21 , `2 = x22 + x2 x3 + x32 ,`3 = u22 . As result of CPLF,
there are L1 = {( L1i ,l1i )| L1i = ( L1i1 ,0,0,L1i2 ,0)}, L2 = {( L2i ,l2i )| L2i =
(0,L2i1 ,L1i2 ,0,0)}, L3 = {( L3i ,l3i )| L3i = (0,0,0,0,L3i1 )}, and define function
Li + L j = {( Lim ,lim ) + ( L jn ,l jn ), ( Lim ,lim ) Li , ( L jn ,l jn ) L j }. The 3
decomposed cost function can be summed as L = L1 + L2 + L3 = {( Li ,li )},
and the piecewise affine function can be interpreted as L( x,u) = max(( Li ,li )
( x,u,1)T ).

5.3.3 Choice Of The Data Point Set


A well defined data set can also produce a better performance. There are two
data point sets constructed for problem (5.1). A consists of 22 22 homogeneously distributed on [100,100] [100,100] points, B consists of 11 11
homogeneously distributed on [50,50] [50,50] points, and 353 more
points in the area {[100,100] [100,100]}\{[50,50] [50,50]}. The
size of the point sets is almost the same.The approximations are calculated
with pr = 20. To compare the results with A and B , the RMS of both results
are calculated based on point set C = { x [100,100] [100,100]| x Z2 }.
RMSA = 257 and RMSB = 322, the homogeneously distributed point set
have better performance. For pr = 40, RMSA = 147, RMSB = 253.
There is also a compromise between the iteration time of Step 5 I1 , of Step
4 I2 of CPLF and the size of data set ds. The CPLF of Jx ( x ) = x T x in problem
(5.1) is calculated with different parameters, the t in the table represents the
calculation time.
In Table 5.1 it can be seen that the best RMS of CPLF approximation
with pr = 20 is about 250, in order to get a good result, I2 10 is required
and I1 10 is a good guarantee for the approximation result. The data
size is big enough with 21 21, a larger data size will not improve its
performance. The computation complexity depends strongly on pr and
ds, and is almost proportional to I1 and I2 . The size of data set is chosen

35

5 Parameters
appropriately according to the number of affine functions. A data set, which
is too large increases the time cost and does not improve the performance,
but the results with too few data points are much worse. In order to ensure
the quality of the approximation, neither I1 nor I2 could be too few. They
are chosen to be I1 = I2 = 10 in the rest of this thesis. It also shows that the
approximation takes too much time with a large data size of 1600 or more.
pr does not only depend on the efficiency of the approximation, but also on
the efficiency of the final MPC control.
I1
10
10
2
5
10
20
50
50
1
10
10
1
10

I2
10
10
50
20
10
5
2
10
10
10
10
20
10

ds
11 11
11 11
21 21
21 21
21 21
21 21
21 21
21 21
41 41
41 41
41 41
41 41
41 41

pr
10
20
20
20
20
20
20
20
20
40
20
40
40

t
8
20
130
137
169
133
247
630
230
543
2043
1933
19332

bestrms
498
344
257/333/328/380/440/2681
276/255/253
269/245
379
285
257
250/339/369/256
144
237
241
118

Table 5.1: CPLF with different parameters

5.4 Data Set For Upper Envelope


As mentioned in Section 3.2, the data set should include the origin and the
origin should be contained in the interior of the convex hull of the data set,
so that the result of combined method would be positive definite. In order to
ensure this, at least n + 2 points are needed. n + 1 points are needed to build
a n-dimensional simplex, so that it has interior and surface. Additionally,
the origin in the internal is also needed. In this thesis the data point set for
UE is chosen as { x = ( x1 ,...xn )> | xi { a,0,a},i N[1,n] },a R\{0}.
1

The results strongly vary when I1 is too small, therefore the process should be repeated for
several times to show its average performance

36

5.5 Algorithm For Combined Method


In Section 3.2 the modified Upper Envelope is introduced. To modify the
original UE into the form y a = max(L[ x,1]> ) as in (3.1), the toolbox MPT3
is again required [17]. MPT3 is a very powerful tool to handle polyhedrons,
it can calculate the constraints of the polyhedron described by vertexes. For
a ( Nd )n grid GUE = G( xmax ,xmin ,n),n = ( Nd ,...,Nd ) Rn , construct the
polyhedrons Pi1 ,...in with n + 1 vertexes

{Gi1 ,...in , Gi1 +1,...,in , Gi1 ,i2 +1,...in , Gi1 ,...,in +1 } f or i1 ,...,in N[1,Nd 1] .
And the uniquely determined pair ( Ae ,be ) as described in Section 3.2 for
Pi1 ,...in can be calculated directly by MPT3. With Ae = ( ae,1 ,...,ae,n+1 ), note
that ae,n+1 6= 0, there is
f (x) =
Hence
LUE ( j, :) =

1
(( ae,1 ,...ae,n ) x be ).
ae,n+1

1
be
( a ,...ae,n ), lUE ( j) =
.
ae,n+1 e,1
ae,n+1

This is also a reason why a data set in grid form is more preferred: the
polyhedrons can be easily established.
The size of the convex hull of this data point set, which is a cube and
determined by a, should be chosen in this way, so that the ( LUE , lUE,j )
describe the original cost function better in the neighborhood of the origin.
Moreover, the accuracy of approximation may not be dependable if the value
of a is too high, because many rows of the result of CPLF ( LCPLF ,lCPLF )
will be covered by ( LUE , lUE ), i.e. for many i N[1,r L
] , LCPLF (i, : ) x +
CPLF
lCPLF (i ) max( LUE x + lUE , x X . However, a a that is too small might
make the function value in some region of neighborhood of origin too
small. In this thesis, ai , i N[1,n] are given to every dimension. Denote the
maximum of absolute value of x in i-th dimension as ri ,then ai are chosen to
be
r
ai = i1 .
prn

5.5 Algorithm For Combined Method


The approximation with Upper Envelope in Section 5.4 is first calculated.
The RMS is calculated on each iteration of Convex Piecewise Linear Fitting

37

5 Parameters
by L = LCPLF LUE = ( Li ,li ),i N[1,sc +su ] . After the best result is obtained,
there can be some unnecessary ( Li ,li ), that
P = { x Rn |( Li L j ) x + li l j > 0} X =

(5.2)

They will result in a larger computation complexity by MPC control. To


remove them in practical coding, MPT3 is again used. Construct Polyhedron P = Polyhedron([( L j Li ); X .A],[(li lj); X .b]), Polyhedron( A,b), A
Rm n,b Rm builds Polyhedron with constraints Ax b, i.e. construct
the polyhedron in (5.2), if P.isFullDim == 0, that means, the dimension
of Polyhedron P is smaller than n,hence the interior of the Polyhedron P
is empty, ( Li L j ) x + li l j > 0 does not have a solution in X , the (5.2) is
fulfilled, then remove ( Li ,li ) from L. The results of CPLF
and combined

1
0
method are compared with example L x = x T Qx, Q =
, and data
0 1
set X a 41 41 grids net in [100,100] [100,100], pr = 20. The result
of combined method consists of 24 affine functions. From Figure 5.4 and
Figure 5.5 we can see that CPLF can not get a positive definite result while
the Combined Method can.
104
2

1.5

0.5

0.5
100

100 100 80 60 40 20

20

40

60

Figure 5.4: Approximation with CPLF

38

80

100

5.5 Algorithm For Combined Method


104

2
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0
100

50

50

100 100

50

50

100

Figure 5.5: Approximation with Combined Method

39

6 Algorithm
The MPC controller design is divided into several parts. runco, space etc.
that are introduced below are parts of computer programs.

6.1 Runco
"Runco" is used to define the original cost function and it returns the cost
value according to given input and state. It is also referred as a calculation
of approximating running cost function and piecewise affine terminal cost
function for the original cost function. The inputs are x X and u U , the
output is y = `( x,u) R. In some situations, the input of runco can also be
x Ni , as introduced in Section 5.3.2, and the output `i

6.2 Space
"Space" is used to build the data point set of the variables, in our situation,
the states and the inputs. Inputs for this function are the possible values
of the data points x in form of n pan matrix, where pa = ( pan )n . As
mentioned in Section 5.3.3, a homogeneously distributed data set makes a
better performance. Hence for an n-dimensional variable, it can build a data
set in form of Definition 3.1 in Section 3.2. It gives a Rn pa matrix xs , where
xi, max xi, min
pa =
. The data point set of variables and function values
xi,d
i N[1,n]


xs (: ,i )
can be later interpreted as
, i N[1,pa ] , f ( x ) can be chosen
f ( xs (: ,i ))
according to our needs.
As a simple example, for n = 
2, the possiblevalues for x1 are 1,0,1 and
1 0 1
for x2 1,0,1. The input is then
, and the output
1 0 1


1 0 1 1 0 1 1 0 1
.
1 0 1 0 1 1 1 1 0

40

6.3 Piecewise Linear Approximation

6.3 Piecewise Linear Approximation


"pwla" calculates the approximating piecewise affine cost function. It includes 3 inputs: requested number of the affine functions pr , data point set
X = ( x1 ,x2 ,...,x pa ) in form of n pa matrix, domain of x X in form of ndimensional polyhedron, the iteration time I1 and I2 . Below the algorithm of
pwla is introduced. The output is a rL n matrix L, where rL N,rL pr .
To be mentioned is that X, n are defined according to the domain of runco,
and are not always the data point set and dimension of the system state.
For theoretical explanation of it please refer to Section 3.3 and 3.5.
The
Algorithm 1 pwla
1 for i = 1 to pa
2
do A(: ,i ) := [X(: ,i )> , runco(X(: ,i ))]> % A is the new data point
set with function values
3 for i = 1 to n
4 xi, min = min(X(i, :)), xi, max = max(X(i, :))
x1, min
x1, max
0
1
1
n
p
pn
x2, min
x2, max

0
1
p n1

pn

5 xUE :=

..
..
..

.
.
.
x

xn, max
n, min
0
1
1
pn

6
7
8
9
10
11
12
13
14

pn

( LUE ,lUE ) = UE( xUE ) % "UE" is the function block for Upper
Envelope and will be introduced in section 6.4
LUE := ( LUE ,lUE )
Rbest := + inf
for t = 1 to I1 %Iteration in Step 5, as mentioned in Section 5.3.3, on the
operating computer, the iteration times are chosen to be I1 = I2 = 10
do a is a vector of p different random integer numbers between 1
and pa
for i = 1 to p
do ui = X(: ,a(i ))
P := 0 pa p ,c := 01( p+1)
%cluster the data points into p groups according to (3.2) in Step 1;
for i := 1 to pa

41

6 Algorithm

15
16
17
18
19
20
21
22
23
24
25

do find m so that kum xi k :=

min

j{1,...,p}

k u j xi k

P(c(m + 1) + 1,m) := i %it stores the point number


c(m + 1) := c(m + 1) + 1 %the point number of the m-th group.
Pnew := 01 pa p
for i = 1 to pa
do for j = 1 to p
do Pnew (( j 1) pa + i ) := P(i,j) %reshape P to a
one-row matrix
for i = 1 to column length of Pnew
do if Pnew (i ) = 0
then Pnew = [ Pnew (1),Pnew (2),...,Pnew (i 1),Pnew (i + 1),
...Pnew (end)]% Pnew (i ) is deleted
for i = 0 to p 1
p i

26

do c( p i ) := c( j)
j =1

27
28
29
30

31
32
33
34
35
36
37
38
39

42

% The i-th group is then assigned as A(: ,Pnew ((c(i ) + 1) : c(i + 1)))
for t2 = 1 to I2 %Iteration in Step 4
do Calculate LCPLF = ( LCPLF ,lCPLF ) by (3.3)
%Step 2
Do line 11 to 22 again, replacing
  line 12 with
 
x
x
Find m so that LCPLF (m, :) i = max (LCPLF ( j, :) i )
1
1
j{1,...,p}
%Step 3
for i = 1 to rlCPLF
do if lCPLF (i ) > 0
then

 lCPLF (i ) = 0
LCPLF
L=
% combine the CPLF result with UE result
LUE
for i = 1 to pa
 
x
do y approxi (i ) = max(L i )
1
yi = A(n + 1,i )
R = k(y approxi y)/p0.5
a ||
if R < Rbest

6.4 Upper Envelope

40

then Lbest = L and Rbest = R

superposition of two results make some lines in L useless, i.e. they are
"redundant" in the whole domain. To simplify this result, mpt3 is again
applied. If the Polyhedron
 
x
P = { x X |(L(i, :) L( j, :))
0, j = N1,r L ,j 6= i }
1
is not of full dimension, in Matlab P.isFullDim() == 0, then delete L(i, :).

6.4 Upper Envelope


"UE" calculates the Upper Envelope of given data point set. Its input is the
possible values of the variables x in form of n pan matrix and its output is
a rLUE n matrix LUE . Its algorithm is introduced as below:
Algorithm 2 UE
1 xs = space( x )
2 p a = c xs
3 for i = 1 to pa
4
do yi = runco( xs (: ,i ))
5 for i = 1 to n
6
do xd (i ) = x (i,2) x (i,1)
7 for i = 1 to pa
8
do for j = 1 to n
9
do if xs ( j,i ) 6= x ( j,end)

xs (1,i ) xs (1,i ) + x1,d . . .


xs (1,i )
xs (2,i )

xs (2,i )
...
xs (2,i )

10
then xn+1 = .

..
.
.
.
.

.
.
xs (n,i )
xs (n,i )
. . . xs (n,i ) + xn,d
% Every column of this matrix is one of the n + 1 vertexes of the n-dimensional simplex.

43

6 Algorithm

11
12

for j = 1 to n + 1

pa

do Solve linear problem z j = minimize k y(k)


pa

13

s.t. k = 1

14

k 0

k =1

k =1
pa

15
16

17
18
19

20
21
22
23

k xn (: ,k) = xn+1 (: ,j)


k =1
(

)
nS
+1 x
n+1 ( : ,j )
Si = convh
zj
j =1
% The simplex introduced in Section 3.2, page 17
for i = 1 to pa
do if Si is empty set
then Delete Si
% Because if xn ( j,i ) = x ( j,end) in line 7,
it will build an empty S j
for i = 1 to number of Si
do Get the equality constraint of Si :Aeq x = beq
LUE (i, :) = Aeq (1 : n)/Aeq (n + 1)
lUE (i ) = beq /Aeq (n + 1)

6.5 Terminal Region and Its Partition


"TerCon" gives the terminal region and the partition of domain of the
terminal cost for the MPC problem. Note that the terminal region X f is
a subset to P ,i.e. the union of the partitions Pij . Its inputs are the local
control law K and accordingly Ak , and la as introduced in Section 5.2,
matrices AX Rr AX n ,bX Rr AX ,AU Rr AU m ,bU Rr AU of domains
X := { x Rn | AX x bX } and U := {u Rm | AU u bU }. The outputs are
denoted as Pter and Pm,i in form of Polyhedrons. Its algorithm is introduced
as below:

44

6.5 Terminal Region and Its Partition


Algorithm 3 TerCon

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22
23



AX
D0 =
 AUK
b
b1 = X
bU
Pter =TerRe(D0 ,b1 ,K,Ak )%Terminal Region,its defined in the page 45
[ ,AP ,bP ]=TerRe(D0 ,b1 ,K,Ak /)
% "" means that the first output of the function is ignored
Obtain an array (V1 ,...,Vp ) containing the vertexes of Pter
1 = max(max( AP Vi ))
% 1 is designed after (4.5)
AP = AP /1
Build polyhedron P with constraints AP x bP
for i = 1 to row size of AP
do for j = 1 to row size of AP
do D ( j, :) = AP ( j, :) AP (i, :)
Build Polyhedron Pi with constraints Dx 0 and AP x bP
delete redundant constraints of Pi
% it can be done in Matlab by command "Pi .minHRep"
Get constraints of Pi A Pi x bPi
for i = 1 to row size of AP
do for j = 1 to la
do Ala (i1)+ j = A Pi
bla (i1)+ j = bPi
for k = 1 to row size of A Pi
do if bPi (k) 6= 0

Ala (i1)+ j
then Ala (i1)+ j = A Pi (k, :)
A Pi (k, :)

bla (i1)+ j
j

bla (i1)+ j =

la bPi ( k, : )
j 1
la bPi (k, :)
Build Polyhedron Pm,la (i1)+ j with constraints
Ala (i1)+ j x bPla (i1)+ j % Pm,i s are the partition
for terminal cost

45

6 Algorithm

24
25
26
27

for i = 1 to row size of AP


do Get Vertexes Vi of Polyhedron Pm,la (i1)+1
if the sum of absolute values of coordinates of Vi : s 103
then Vi = 0n1 , where n is the dimension of x
% Eliminate the errors to ensure that the points that should be at the origin are exactly at the origin.

Algorithm 4 TerRe
1
2
3
4
5
6
7
8
9
10
11
12
13
14

46

function [P,D,b]=TerRe(D0 ,b1 ,A,B)


% This algorithm is adapted from [24]
b = b1
i=1
Buildpolyhedron
P A with constraints D0 x b

D0
D=
 D0 B
b
b=
b1
Build polyhedron P B with constraints Dx b
while P A 6= P B
do i = i + 1
P B = P A
b
b=
b
1

D
D=
D0 ( B)i
Polyhedron P A is redefined with constraints Dx b
P = PB

6.6 Calculation of the Terminal Cost

6.6 Calculation of the Terminal Cost


"terco" calculates the piecewise affine terminal cost from given partition and
running cost. Its inputs are the local control law K and accordingly Ak , la ,
Lbest from Section 6.3,Pm , i.e. from Pm,1 to Pm,la r ,with r = row size o f AP ,
from Section 6.5. The outputs are rV n matrix V and rV 1 matrix v. If
the original problem is non-quadratic, terco can also be applied to calculate
its terminal cost function, the input Lbest should be removed and an external
running cost function runco should be inserted.
In this algorithm, The Problem 4.1 is designed to be a linear problem,
to be solved is Vv = (V (1, :),v(1),V (2, :),v(2),...). In contrary, V (i, :) =
Vv (((i 1)(n + 1) + 1) : i (n + 1) 1), and v(i ) = Vv (i (n + 1)) for i = N[1,rV ] .
The Vs and vs are ordered in the way shown in Figure 5.1 .That is, If the
active region of the (V (i, :),v(i ) pair, i.e where V (i, :) x + v(i ) = max V ( j, :
jN[1,rV ]

) x + v( j), contains the origin, then i = la (k 1) + 1, k N[1,rV /la ] . The


algorithm is introduced as follow:
Algorithm 5 terco
1
2
3
4
5
6
7
8
9
10
11

12

M =size of Pm % Pm is an array of polyhedrons, size of it is


the number of polyhedrons.
r= M
la
Aeq = []
beq = []
for i = 1 to M
do Get constraints of Pm,i : Gi x gi % Pm,i is the i-th Polyhedron
in Polyhedron array Pm
for j = 1 to M
do Get constraints of Pm,j : Hj x h j
Build polyhedron P with constraints Gi x gi and
1
Hj Ak x h j % P is the intersection of Pm,i and A
k Pm,j
if P is not an empty set
then Get its vertexes VP in form of rVP n matrix.
i.e the extreme points of the intersection of Pm,i
1
and A
k Pm,j
k=1

47

6 Algorithm

13
14
15

16
17

while k rVP
do if |VP (k, :)| 1e 3
then delete VP (k, :) % For VP (k, :) = 0,
%theoretically (4.1c) is fulfilled
with (4.1b), thus we delete the
points should be but may not actually
be at the origin to make the computation
easier and avoid the possible errors
else k = k + 1
Aeq,1 = [0rV ((n+1)(i1) , VP , 1rV 1 ,0rV ((n+1)( Mi) ]
P

18
19
20
21
22

beq

23
24
25
26

28
29
30
31
32
33
34
35
36
37
38

48


VP
do L (k) = max(Lbest
)
KVP


beq
=
%right side of inequality (4.1c)
L

Aeq = []
beq = 0r1
for i = 1 to r


27

Aeq,2 = [0rV ((n+1)( j1) ,VP Ak> ,1rV 1 ,0rV ((n+1)( M j) ]


P
P
P


Aeq
Aeq =
% left side of inequality (4.1c)
Aeq,1 + Aeq,2
L = 0r V 1
P
for k = 1 to rVP


Aeq
do Aeq =
[01((i1)la (n+1)+n) ,1,01((n+1)( M(i1)la 1)) ]
% equation (4.1b)
f = 01((n+1) M)
for i = 1 to M
do Get vertexes of Pm,i : VPm
rV := row size of VPm
k=1
while k rV
do if |VPm (k, :)| 1e 3
then delete VPm (k, :)
else k=k+1
for j = 1 to rV
do f = f + [01((i+1)(n+1) ,VPm ( j, :),1,01(( Mi)(n+1)) ]

6.6 Calculation of the Terminal Cost

39
40
41
42
43
44

45
46
47
48
49
50
51

for j = 1 to M
do Aeq,1 = [0rV ((n+1)(i1)) , VPm , 1rV 1 ,0rV ((n+1)( Mi)) ]
Aeq,2 = [0rV ((n+1)( j1)) ,VPm ,1rV 1 ,0rV ((n+1)( M j)) ]


Aeq
Aeq =
% inequality (4.1d)
 Aeq,1+ Aeq,2
beq
beq =
0r V 1
Solve problem min y = f x
s.t. Aeq x beq
Aeq x = beq
Denote its solution as Vv
for i = 1 to size of Vv
do if |Vv (i )| 1e 3
then Vv (i ) = 0
rt = rVv /(n + 1)
for i = 1 to rt
V (i, :) = Vv (((i 1)(n + 1) + 1) : ((i 1)(n + 1) + n))
v(i ) = Vv ((i 1)(n + 1) + n + 1)

For the calculation of terminal cost function for the original problem, line
23 should be replaced with:

23

do L (k) = runco (VP ,KVP )

where "runco" is a function of x and u as introduced in Section 6.1.

49

7 Simulation Studies
In this chapter the piecewise MPC method will be simulated in Matlab under
different conditions. Moreover, a MPC controller with original running cost
function and proper terminal cost function will be designed to conduct
comparison. The solver applied for quadratic problem is "cplexqp", for the
approximating problem "cplexlp" and for non-quadratic problem "fmincon".
The unit of time in this section is second (s). In this chapter, the running cost
functions are always decomposed into two parts, L( x,u) = L x ( x ) + Lu (u) =
L x [ x > ,1]> + Lu [u> ,1]> , and the row size of L x and Lu are denoted as r Lx ,
r Lu .

7.1 Problem With 1-dimensional State And 1-dimensional


Input And Quadratic Cost Function
This is the simplest situation, so that some basic characteristics can be tested.
Example. Given a discrete-time control problem with linear dynamic:
min

c( x,u) =

x (i )2 + 0.01u(i )2

i N

s.t.
x (k + 1) = 1.01x (k) u(k)
x X ,u U

X = { x R| 50 x 50}; U = {u R| 5 u 5}
, sampling time T = 0.01s. The local controller is obtained by LQR:K =
1.0001 and Ak = 0.0099 The terminal cost function for MPC with original
running cost function can be chosen as, Vlqr ( x ) = x T Px, with P = 1.011.
MPC controller is run until x X f . Denote cpl = c( xpl ,upl ) and tpl as cost
and running time with the piecewise affine cost function, co = c( xpl ,upl )
and to as cost and running with the original cost function note that u pl are
obtained with piecewise affine cost function, but c pl is still calculated with
the original cost function.

50

7.2 Problem With 2-dimensional State And 1-dimensional Input


There is only one state to be controlled. Therefore the largest or smallest
value will be chosen for u before the state runs into the terminal region.
Hence the approximation can be as simple as possible, and it leads to a
lower computational complexity while the resulting cost will not be higher.
Table 7.1 shows that the calculation time grows with the horizon for both
MPC controller, and the controller with cplexqp runs much faster.
r Lx
21
12
12
4
20
20

r Lu
7
4
4
4
4
4

la
5
1
1
1
5
5

N
10
10
10
10
10
20

c pl
2367.8
2367.8
5391.6
5391.6
7102
7102

t pl
0.3897
0.1965
0.2612
0.1780
0.3715
0.8428

co
2367.8
2367.8
5391.6
5391.6
7102
7102

to
0.1351
0.1251
0.1740
0.1719
0.1739
0.2414

x0
30
30
40
40
-45
-45

Table 7.1: Comparison between two methods,1D state, 1D input,quadratic


function

7.2 Problem With 2-dimensional State And 1-dimensional


Input
The system (5.1) is still used here. The local feedback u = Kx is calculated
by LQR with Q and R in (5.1). P for terminal cost function of MPC controller
with original running cost can be calculated by Matlab command


2.06 0.59
P = dlyap( Ak0 ,Q + K 0 R K ) =
0.59 1.42
Because in this example, the running cost can be divided into
 
x1
`( x,u) = ` x1 ( x1 ) + ` x2 ( x2 ) + `u (u), f or x =
x2
, the approximating running cost function can also be divided into three
parts.
It can be seen in Table 7.2 that the controller with piecewise affine cost
function still does not have advantages in comparison to quadratic programming with 2-dimensional state and 1-dimensional input.

51

7 Simulation Studies
The controller with non-quadratic original cost function is also tested.
(k x k3 )3 is used as cost function here. The terminal cost function for the
original function is also calculated by the piecewise affine method. Therefore
two la s are needed here, la,pl is the number of layers for the approximated
function, and la,o for the original. In this example, the controller works
until all states and inputs converge to zero, because u = Kx is no longer the
optimal solution in terminal region.
r Lx
24
24
24

r Lu
4
4
4

la
5
5
5

hor
10
20
50

c pl
5008.8
5008.8
5008.8

t pl
1.2978
3.4388
14.2777

co
5008.8
5008.8
5008.8

to
0.1842
0.2288
0.9328

x0
(-50,25)
(-50,25)
(-50,25)

Table 7.2: Comparison between two methods,2D state, 1D input,quadratic


cost function
The reason for the slightly higher cost is suggested to be the inexact
approximation in terminal region. And this inexaction can hardly be lowered
by simply rising r Lx . In order to confirm this suggestion, the approximation
is made two times, one in [50,50] [50,50] with r Lx = 20 and one in
[20,20] [20,20] with r Lx = 10,20 and 40, combined them together and
delete the unneeded rows,the final cost stay just the same. The reason for the
slightly worse result is then supposed to be the different algorithm between
"fmincon" and "cplexlp".
r Lx
23
9
9
23

r Lu
4
4
4
4

hor
10
10
10
10

la pl
5
1
1
1

c pl
180220
180220
298.8
298.8

t pl
5.7889
2.7405
2.6825
5.9138

lao
5
1
5
5

co
180020
180030
289.1
289.1

to
7.2529
12.3374
12.3325
12.3325

x0
(-50,25)
(-50,25)
(-5,5)
(-5,5)

Table 7.3: Comparison between two methods,2D state, 1D input,nonquadratic cost function
As conclusion of Table 7.3, the approximating controller runs much faster
than the original one by non-quadratic problems. The approximating controller for higher-order cost function will lead to slightly higher cost than
the original one, and it is not effected by how well the cost function is

52

7.3 Higher Dimensional Problem


approximated.

7.3 Higher Dimensional Problem


The higher the dimensions of states and inputs are, the longer time it takes
to calculate. It is to be tested in this section, whether the approximated MPC
controller still hold its advantages over the original in higher dimensional
problem with longer horizon.
Problem with 3D states and 2D inputs:

1 0
1 12 16
A = 0 1 12
B = 12 12
(7.1a)
0 1
0 0 1

X = { x R3 ,x = ( x1 ,x2 ,x3 )T | xi [5,5],i = 1,2,3}

(7.1b)

U = {u R ,u = (u1 ,u2 ) |ui [1,1],i = 1,2}


3

`( x,u) = (k x k3 ) + (kuk3 ) = | x1 | + | x2 | + | x3 | + |u1 | + |u2 |


The local feedback is calculated by LQR with


1 0 0
1
Q= 0 1 0
R=
0
0 0 1

r Lx
27
27
16
46
46

r Lu
14
14
8
24
24

hor
30
30
30
30
30

la pl
1
1
1
1
5

c pl
347.01
243.41
373.87
331.28
331.28

t pl
121.81
219.37
108.43
574.96
601.61

lao
5
5
5
5
5

0
1

(7.1c)
3

(7.1d)

co
333.82
241.08
333.82
333.82
333.82

(7.2)

to
1157
1084
1230
1230
1230

x0
(-4,-5,3)
(-3,4,2)
(-4,-5,3)
(-4,-5,3)
(-4,-5,3)

Table 7.4: Comparison between two methods,3D state, 2D input,nonquadratic cost function
In Table 7.4 it is shown that the performance of approximating controller
can be superior to the original controller, where the conservatism of the
terminal cost has no influence on it.We suggest that the reason for it is,

53

7 Simulation Studies
for some steps, the Matlab function "fmincon" has reached its maximum
calculation time and stopped searching the optimal solution. To confirm this,
Max Iteration times is risen from 10000 to 20000, but the cost remains the
same.
The cost function of (7.1d) is divided into 5 parts with elld (t) = |t|3 ,t R.
It is approximated with L1 ( x1 ) = max( L1i x1 + l1i ) `d ( x1 ), L2 ( x2 ) =
max( L2j x2 + l2j ) `d ( x2 ), ..., L5 (u2 ) = max( L5k u2 + l5k ) `d (u2 ), and each
approximating function for xi consists of 6 functions, each approximating
function for ui consists of 4 linear functions. As result the approximating
function for (7.1d) consists of 63 42 = 3456 affine functions. But the final
cost with this piecewise affine controller is 341, worse than the one with
piecewise affine function consisting of 46 24 affine functions.

7.4 A Practical Model For Temperature Control


Although the majority of the cost functions in practical control problems are
chosen to be quadratic, there could be need for higher-order cost function.
Consider an air conditioner of a car and assume that the temperature should
be controlled around 25 C. The input heat flow given by air conditioner
is Q [1,1]/kW. System dynamic dT/dt = ( Q + Q 2 )/ air VCair , where
air VCair = 4kJ/ C. The Q 2 = 0.5kW considers the effect of sunshine and
the natural heat dissipation and is determined by the weather.With sample
time Ts = 10s, the discrete dynamic is then T (k + 1) = T (k) + 2.5( Q + Q 2 )
Let the penalty function as F ( T,Q ) = Q 2 + 0.01( T 25)3 . The initial state is
T0 = 40 C.
In Figure 7.1 it is shown that the traditional QP control in comparison to
control with higher-order penalty function can either slow down the cooling
when the temperature is still high with Q = 1, R = 100, or try too hard
to control the temperature in a very small range with Q = 1,R = 1. The
piecewise affine approximation can preserve the advantage of higher-order
function, and keep the calculation complexity in an acceptable degree at the
same time. In this example , it takes 13.5s for the approximating problem,
while 33.41s for the QP MPC on the same computer.

54

7.4 A Practical Model For Temperature Control

40
with pwl cost function
QP control with R=1
QP control with R=10
QP control with R=100

38

Temperature/ C

36
34
32
30
28
26
24

20

40

60

80

100

120

140

160

180

200

220

240

260

280

300

t/s

Figure 7.1: Temperature control with piecewise affine cost function and with
different quadratic cost function

55

8 Conclusions and Outlook


The thesis is constructed under the design of a piecewise affine MPC controller. The controller is to stabilize a discrete-time linear system with domain
in form of polytopes to its origin by approximating a proper non-linear cost
function with piecewise affine cost function. Furthermore, the parameters for
this method were discussed and chosen and detailed algorithm for controller
design is constructed. In the end we evaluated the benefits of this method in
comparison to the original problem with non-linear cost function.
To summarize, in the context of MPC for linear discrete-time systems, due
to well-developed algorithm for Quadratic Problem (QP), computational
benefits in approximating quadratic cost functions with piecewise affine cost
functions are proven to be limited. However, control with piecewise affine
approximating lowers down the calculation cost and provides the possibility
to deal with complex and convex higher-order cost functions, which can
meet some practical needs better than quadratic cost function.
However, the research in the thesis still remains to be improved in the
future. For example, the question remains how this methods works with
piecewise affine dynamic, or piecewise affine approximation of a nonlinear
system dynamic, as mentioned in [28]. Thus, the future research will address
the question whether there is a more efficient algorithm to approximate
the running cost function. Answering to the question can test whether the
approximation is more accurate with a lower number of affine functions.
Additionally, further research can also investigative the questions whether
the evaluation function for the approximation is a good index that is strongly
related to the performance of controller. In conclusion, more research
questions can be covered to give the gravity of future researches.

56

Eigenstndigkeitserklrung
Ich versichere hiermit, dass ich, Junsheng Su, die vorliegende Arbeit selbststndig angefertigt, keine anderen als die angegebenen Hilfsmittel benutzt
und sowohl wrtliche, als auch sinngem entlehnte Stellen als solche kenntlich gemacht habe. Die Arbeit hat in gleicher oder hnlicher Form noch
keiner anderen Prfungsbehrde vorgelegen. Weiterhin besttige ich, dass
das elektronische Exemplar mit den anderen Exemplaren bereinstimmt.

Ort, Datum

Unterschrift

57

Bibliography
[1] Richard Bellman. Dynamic Programming. Dover Publications, INC, 1
edition, 2003.
[2] Richard Bellman and Robert Roth. Curve fitting by segmented straight
lines. Journal of the American Statistical Association, 64:10791084, 1969.
[3] Franco Blanchini, Fouad Mesquine, and Stefano Miani. Constrained
stabilization with an assigned initial condition set. International Journal
of Control, 62:3:601617, 2007.
[4] Stephen Boyd and Lieven Vandenberghe. Convex Optimization. Cambridge University Press, 7 edition, 2009.
[5] P.S. Bradley and O.L. Mangasarian. Constrained model predictive control:stability and optimality. Journal of Global Optimization, 16(1):2332,
2000.
[6] F. D. Brunner, M. Lazar, and F. Allgwer. Computation of piecewise
affine terminal cost functions for model predictive control. HSCC 14,
17:110, 2014.
[7] Eduardo F. Camacho and Carlos Bordons. Model Predictive Control.
Springer Verlag London, 2 edition, 2013.
[8] E. Camponogara, D. Jia, B.H. Krogh, and S. Talukdar. Distributed model
predictive control. IEEE Control Systems, 22(1):44 52, 2002.
[9] J. M. Carnicer. Multivariate convexity preserving interpolation by
smooth functions. Advances in Computational Mathematics, 3(4):395404,
1995.
[10] J. M. Carnicer and M. S. Floater. Piecewise linear interpolants to
lagrange and hermite convex scattered data. Numerical Algorithms,
13(2):345364, 1996.

58

Bibliography
[11] Adrian Curic. Using ibm cplex optimization studio with mathworks matlab. http://www-01.ibm.com/support/docview.wss?uid=
swg27043897&aid=1, 2014. Online,accessed 17-June-2016.
[12] E. G. Gilbert and K. T. Tan. Linear systems with state and control
constraints: The theory and application of maximal output admissible
sets. IEEE Transactions on Automatic Control, 36(9):10081020, 1991.
[13] Andreas Griewank. On stable piecewise linearization and generalized algorithmic differentiation. Optimization Methods and Software,
28(6):11391178, 2013.
[14] Shun ichi Azumaa, Jun ichi Imurab, and Toshiharu Sugie. Lebesgue
piecewise affine approximation of nonlinear systems. Nonlinear Analysis:
Hybrid Systems, 4(1):92102, 2010.
[15] RE Kalman. Contributions to the theory of optimal control. Bol. Soc.
Mat. Mexicana, 5:102 119, 1960.
[16] Basil Kouvaritakis and Mark Cannon. Model Predictive Control. Springer
International Publishing Switzerland, 1 edition, 2016.
[17] Michal Kvasnica. Mpt3 wiki. http://people.ee.ethz.ch/~mpt/3,
2014. Online,accessed 17-June-2016.
[18] Chow Yin Lai, Cheng Xiang, and Tong Heng Lee. Data-based identification and control of nonlinear systems via piecewise affine approximation. IEEE Transactions on Neural Networks, 22(12):2189 2200,
2011.
[19] Christian Lengauer. Loop parallelization in the polytope model. International Conference on Concurrency Theory, 715:398416, 1993.
[20] Alessandro Magnani and Stephen P. Boyd. Convex piecewise-linear
fitting. Optimization and Engineering, 10(1):117, 2008.
[21] R. Milman and E. J. Davison. A fast mpc algorithm using nonfeasible active set methods. Journal of Optimization Theory and Applications,
139(3):591616, 2008.
[22] R. Milsener and C. A. Floudas. Piecewise-linear approximations of multidimensional functions. Journal of Optimization Theory and Applications,
145(1):120147, 2010.

59

Bibliography
[23] L.S. Pontryagin, V.G. Boltyanskii, R.V. Gamkrelidze, and E.F.
Mishchenko. The Mathematical Theory of Optimal Processes. Gordon
and Breach Science Publishers, 1 edition, 1986.
[24] D. Q.Mayne, J. B. Rawlings, C. V. Rao, and P. O. M. Scokaert. Constrained model predictive control:stability and optimality. Automatica,
48(10):27212725, 2000.
[25] J. B. Rawlings and D. Q.Mayne. Model Predictive Control: Theory and
Design. Springer Verlag London, 2009.
[26] Stefan Richter, Colin Neil Jones, and Manfred Morari. Computational
complexity certification for real-time mpc with input constraints based
on the fast gradient method. IEEE TRANSACTIONS ON AUTOMATIC
CONTROL, 57(6):13911403, 2012.
[27] E. Sontag. Nonlinear regulation: The piecewise linear approach. IEEE
Transactions on Automatic Control, 26(2):346 358, 1981.
[28] Marco Storace and Oscar De Feo. Piecewise-linear approximation of
nonlinear dynamical systems. IEEE TRANSACTIONS ON CIRCUITS
AND SYSTEMSI: REGULAR PAPERS, 51(4):830842, 2004.
[29] A. Toriello and J. P. Vielma. Fitting piecewise linear continuous functions. European Journal of Operational Research, 219(1):8695, 2012.
[30] Yang Wang and Stephen Boyd. Fast model predictive control using
online optimization. IEEE Transactions on Control Systems Technology,
18(2):267 278, 2009.

60

Anda mungkin juga menyukai