Você está na página 1de 93

Optimization

Optimal Control
Conclusion

Introduction to Optimization and Optimal Control


using the software packages CasADi and ACADO

Adriaen Verheyleweghen and Christoph Backi

Subsea Production and Processing


Department of Chemical Engineering
Norwegian University of Science and Technology

October 27, 2016

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control
Conclusion

Installation

For CasADi:
Download the files from GitHub and add them to your MATLAB /
Python path - done.

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control
Conclusion

Installation

For CasADi:
Download the files from GitHub and add them to your MATLAB /
Python path - done.
For ACADO:
You need: MATLAB, a C/C++ compiler and the ACADO files
Download from https://github.com/acado/acado
Go to https://sourceforge.net/p/acado/wiki/MATLAB
Interface - Getting Started/ and follow the instructions.
Link the C/C++ compiler to MATLAB and then build the
ACADO interface in MATLAB

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Introduction

Mathematically speaking, optimization is the minimization or


maximization of a function subject to constraints on its variables.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Introduction

Mathematically speaking, optimization is the minimization or


maximization of a function subject to constraints on its variables.
x is the vector of variables, also called unknowns or parameters

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Introduction

Mathematically speaking, optimization is the minimization or


maximization of a function subject to constraints on its variables.
x is the vector of variables, also called unknowns or parameters
V is the objective function, a (scalar) function of x that we
want to maximize or minimize

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Introduction

Mathematically speaking, optimization is the minimization or


maximization of a function subject to constraints on its variables.
x is the vector of variables, also called unknowns or parameters
V is the objective function, a (scalar) function of x that we
want to maximize or minimize
gi and hj are constraint functions, which are scalar functions
of x that define certain equalities and inequalities that the
unknown vector x must satisfy.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Notation

min V (x) subject to gi (x) ≤ 0, i = 1, . . . , m


x∈R
hj (x) = 0, j = 1, . . . , p,
with V (x) objective function, gi (x) inequality constraints and
hj (x) equality constraints.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Notation

min V (x) subject to gi (x) ≤ 0, i = 1, . . . , m


x∈R
hj (x) = 0, j = 1, . . . , p,
with V (x) objective function, gi (x) inequality constraints and
hj (x) equality constraints.
A maximization problem for the objective V (x) is simply
min V (x) = max − V (x).
x∈R x∈R

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Notation

min V (x) subject to gi (x) ≤ 0, i = 1, . . . , m


x∈R
hj (x) = 0, j = 1, . . . , p,
with V (x) objective function, gi (x) inequality constraints and
hj (x) equality constraints.
A maximization problem for the objective V (x) is simply
min V (x) = max − V (x).
x∈R x∈R
The minimization problem formulated as a maximization problem
min − V (x) subject to gi (x) ≤ 0, i = 1, . . . , m
x∈R
hj (x) = 0, j = 1, . . . , p.
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Terminology

Unconstrained and constrained optimization:


Most technical and engineering applications are constrained by e.g.
the dynamics of the system, environmental factors, technical
limitations.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Terminology

Unconstrained and constrained optimization:


Most technical and engineering applications are constrained by e.g.
the dynamics of the system, environmental factors, technical
limitations.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Terminology

Local and global optimization:


Many algorithms only look for a local solution, which need less
computational power compared to global solutions.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Terminology

Local and global optimization:


Many algorithms only look for a local solution, which need less
computational power compared to global solutions.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Terminology

Convexity:
Convex problems are generally easier to solve. Convexity often
holds for the objective function, however, in order to obtain a
convex programming problem, the equality constraints must be
linear and the inequality constraints convex.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Terminology

Convexity:
Convex problems are generally easier to solve. Convexity often
holds for the objective function, however, in order to obtain a
convex programming problem, the equality constraints must be
linear and the inequality constraints convex.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi

CasADi
What is it?
Tool for Algorithmic Differentiation (ADi) with syntax
borrowed from Computer algebra systems (Cas)
Interfaces with optimization software such as IPOPT,
qpOASES, SNOPT, fmincon etc.

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi

CasADi
What is it?
Tool for Algorithmic Differentiation (ADi) with syntax
borrowed from Computer algebra systems (Cas)
Interfaces with optimization software such as IPOPT,
qpOASES, SNOPT, fmincon etc.

What is it not?
Not an optimization software
Not a conventional AD tool, that can be used on existing user
code with little to no modification
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi
Algorithmic differentiation?

AD generates an expression graph of the program, then uses


chain rule to find derivatives

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi
Algorithmic differentiation?

AD generates an expression graph of the program, then uses


chain rule to find derivatives
Example:

z = f (x1 , x2 )
= x1 x2 + sin(x1 )

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi
Algorithmic differentiation?

AD generates an expression graph of the program, then uses


chain rule to find derivatives
f (x1 , x2 )
Example:

z = f (x1 , x2 )
w5 +
= x1 x2 + sin(x1 )
= w1 w2 + sin(w1 ) w4 sin ∗ w3

= w3 + w4
= w5
w1 x1 x2 w2

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi
Algorithmic differentiation?

AD generates an expression graph of the program, then uses


chain rule to find derivatives
f (x1 , x2 )
Example:
ẇ5 = ẇ3 + ẇ4
z = f (x1 , x2 )
w5 +
= x1 x2 + sin(x1 ) ẇ4 = cos(w1 )ẇ1 ẇ3 = ẇ1 w2 + w1 ẇ2
= w1 w2 + sin(w1 ) w4 sin ∗ w3

= w3 + w4 ẇ 1
ẇ1 ẇ2
= w5
w1 x1 x2 w2

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi

Why bother?
sympy
100
Time to generate graph [s]

10−1

10−2

10−3

10−4 0
10 101 102 103 104
Number of variables

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi

Why bother?
sympy
100 yalmip
Time to generate graph [s]

mupad

10−1

10−2

10−3

10−4 0
10 101 102 103 104
Number of variables

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi

Why bother?
sympy
100 yalmip
Time to generate graph [s]

mupad
casadi
10−1

10−2

10−3

10−4 0
10 101 102 103 104
Number of variables

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi

Why bother?
sympy
100 yalmip
Time to generate graph [s]

mupad
casadi
10−1

10−2 Flexibility of
programming
10−3 language
Performance of
10−4 0
10 101 102 103 104 modeling language
Number of variables

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Syntax

addpath ( ' path / c a s a d i ' )


import casadi .∗ % Import c a s a d i

r = SX . sym ( ' r ' ) ; % Declare symbolic v a r i a b l e s


V = 4/3∗ p i ∗ r ˆ 3 ; % E x p r e s s i o n w i t h sym . v a r s .
A = j a c o b i a n (V , r ) ; % D e r i v a t i v e of V wrt r

f = F u n c t i o n ( ' f ' , { r } , {A} ) ; % C a l l −a b l e f u n c t i o n

f (1) % Evaluate function

1
Python/C++ also available
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Syntax

addpath ( ' path / c a s a d i ' )


import casadi .∗ % Import c a s a d i

r = SX . sym ( ' r ' ) ; % Declare symbolic v a r i a b l e s


V = 4/3∗ p i ∗ r ˆ 3 ; % E x p r e s s i o n w i t h sym . v a r s .
A = j a c o b i a n (V , r ) ; % D e r i v a t i v e of V wrt r

f = F u n c t i o n ( ' f ' , { r } , {A} ) ; % C a l l −a b l e f u n c t i o n

f (1) % Evaluate function

1
Python/C++ also available
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example
Example 1 - Linear programming
Farmer wants to grow apples and bananas

Acreage needed Fertilizer needed Profit


[m2 /ton] [kg/ton] [NOK/ton]
A 4000 60 7000
B 3000 80 6000

Farmer has a field of 100 000 m2 and can legally use no more than
2000 kg fertilizer.

What to plant?
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example

min c | x
x

subject to

Ax ≤b
xl ≤x

where

      
−7000 4000 3000 100000 0
c= A= b= xl =
−6000 60 80 2000 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example
B
30
min c | x
x

subject to 20

Ax ≤b
10
xl ≤x

where
A
10 20 30
      
−7000 4000 3000 100000 0
c= A= b= xl =
−6000 60 80 2000 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example
B
30
min c | x
x

subject to 20

Ax ≤b
10
xl ≤x Feasible region

where
A
10 20 30
      
−7000 4000 3000 100000 0
c= A= b= xl =
−6000 60 80 2000 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example
B
30
min c | x
x

subject to 20

Ax ≤b Optimal solution
10
xl ≤x

where
A
10 20 30
      
−7000 4000 3000 100000 0
c= A= b= xl =
−6000 60 80 2000 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example
c = [ −7000; −6000]; % Objective function coeffs
A = [4000 ,3000;60 ,80]; % Constraints lhs
b = [100000;2000]; % Constraint rhs
lb = [ 0 ; 0 ] ; % Lower bounds on x
ub = [ i n f ; i n f ] ; % Upper bounds on x
x = SX . sym ( ' x ' , 2 ) ; % Create symbolic v a r i a b l e s

p r o b s t r u c t = s t r u c t ( ' x ' , x , ' f ' , c ' ∗ x , ' g ' ,A∗x−b ) ;


s o l v e r = qpsol ( ' s o l v e r ' , ' qpoases ' , p r o b s t r u c t ) ;

s o l = s o l v e r ( ' x0 ' , [ 1 ; 1 ] , ...


' l b g ' ,[ − i n f ;− i n f ] , ' ubg ' , [ 0 ; 0 ] , ...
' l b x ' , l b , ' ubx ' , ub ) ;

solx = sol . x ; % Optimal s o l u t i o n


solf = sol . f ; % Objective function value

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - LP example
c = [ −7000; −6000]; % Objective function coeffs
A = [4000 ,3000;60 ,80]; % Constraints lhs
b = [100000;2000]; % Constraint rhs
lb = [ 0 ; 0 ] ; % Lower bounds on x
ub = [ i n f ; i n f ] ; % Upper bounds on x
x = SX . sym ( ' x ' , 2 ) ; % Create symbolic v a r i a b l e s

p r o b s t r u c t = s t r u c t ( ' x ' , x , ' f ' , c ' ∗ x , ' g ' ,A∗x−b ) ;


solver = qpsol ( ' s o l v e r ' , ' qpoases ' , p r o b s t r u c t ) ;

s o l = s o l v e r ( ' x0 ' , [ 1 ; 1 ] , ...


' l b g ' ,[ − i n f ;− i n f ] , ' ubg ' , [ 0 ; 0 ] , ...
' l b x ' , l b , ' ubx ' , ub ) ;

solx = sol . x ; % Optimal s o l u t i o n


solf = sol . f ; % Objective function value

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - QP example
What if profit depends on production? (market saturation etc.)
Profit for A (x1 ) is 7000 − 200x1
Profit for B (x2 ) is 6000 − 140x2

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - QP example
What if profit depends on production? (market saturation etc.)
Profit for A (x1 ) is 7000 − 200x1 B
Profit for B (x2 ) is 6000 − 140x2 30

min c | x + x | Qx
x 20
subject to

Ax ≤b 10

xl ≤x
A
where 10 20 30
      
  
2 0 −70 40 30 1000 0
Q= c= A= b= xl =
0 1.4 −60 0.6 0.8 20 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - QP example
What if profit depends on production? (market saturation etc.)
Profit for A (x1 ) is 7000 − 200x1 B
Profit for B (x2 ) is 6000 − 140x2 30

min c | x + x | Qx
x 20
subject to

Ax ≤b 10
Feasible region

xl ≤x
A
where 10 20 30
      
  
2 0 −70 40 30 1000 0
Q= c= A= b= xl =
0 1.4 −60 0.6 0.8 20 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - QP example
What if profit depends on production? (market saturation etc.)
Profit for A (x1 ) is 7000 − 200x1 B
Profit for B (x2 ) is 6000 − 140x2 30

min c | x + x | Qx
x 20
subject to

Ax ≤b 10
Optimal solution
xl ≤x
A
where 10 20 30
      
  
2 0 −70 40 30 1000 0
Q= c= A= b= xl =
0 1.4 −60 0.6 0.8 20 0
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - QP example

Q = [100 ,0;0 ,200]; % Q u a d r a t i c term


c = [ −7000; −6000]; % L i n e a r term
A = [4000 ,3000;60 ,80]; % Constraints lhs
b = [100000;2000]; % Constraint rhs
lb = [ 0 ; 0 ] ; % Lower bounds on x
ub = [ i n f ; i n f ] ; % Upper bounds on x
x = SX . sym ( ' x ' , 2 ) ; % Create symbolic v a r i a b l e s

p r o b s t r u c t = s t r u c t ( ' x ' , x , ' f ' , c ' ∗ x+x ' ∗Q∗x , ' g ' ,A∗x−b ) ;
solver = qpsol ( ' s o l v e r ' , ' qpoases ' , p r o b s t r u c t ) ;

s o l = s o l v e r ( ' x0 ' , [ 1 ; 1 ] , ...


' l b g ' ,[ − i n f ;− i n f ] , ' ubg ' , [ 0 ; 0 ] , ...
' l b x ' , l b , ' ubx ' , ub ) ;

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Nonlinear programming (NLP)

Hard(er) to solve due to:

Non-convexity / Non-smoothness / Discontinuity /

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Nonlinear programming (NLP)

Hard(er) to solve due to:

Non-convexity / Non-smoothness / Discontinuity /

But: Smart tricks in solvers allow efficient calculation! ,

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Nonlinear programming (NLP)

But: Smart tricks in solvers allow efficient calculation! ,

Change from:
s o l v e r = qpsol ( ' s o l v e r ' , ' qpoases ' , p r o b s t r u c t ) ;

to:
solver = nlpsol ( ' solver ' , ' ipopt ' , prob struct ) ;

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Integrator example


Throwing of rocks

What does the trajectory look like?

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Integrator example


Throwing of rocks

What does the trajectory look like?


py

dpx dvx
= vx = ax = 0 θ
dt dt
dpy dvy
= vy = ay = −g
dt dt py0

px

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Integrator example


Throwing of rocks

What does the trajectory look like?


py

dpx dvx
= vx = ax = 0 θ
dt dt
dpy dvy
= vy = ay = −g
dt dt py0

px

Initial conditions:
px,0 = 0 m, py ,0 = 1 m, vx,0 = v0 cos(θ), vy ,0 = v0 sin(θ)

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Integration example

import casadi .∗

v=MX. sym ( ' v ' , 2 ) ; % Velocity


p=MX. sym ( ' p ' , 2 ) ; % Position
t h e t a = MX. sym ( ' t h e t a ' ) ; % Angle o f throw
t f = MX. sym ( ' t f ' ) ; % Time o f f l i g h t

x = [v;p]; % State v a r i a b l e s
p = [ theta ; tf ] ; % Parameters

dv = [ 0 ; − 9 . 8 1 ] ; % D i f f e r e n t i a l equations
dp = v ;
dx = [ dv ; dp ] . ∗ t f ;

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Integration example


MX - matrix valued operations (necessary to embed integrator in
symbolic expression)
import casadi .∗

v=MX. sym ( ' v ' , 2 ) ; % Velocity


p=MX. sym ( ' p ' , 2 ) ; % Position
t h e t a = MX. sym ( ' t h e t a ' ) ; % Angle o f throw
t f = MX. sym ( ' t f ' ) ; % Time o f f l i g h t

x = [v;p]; % State v a r i a b l e s
p = [ theta ; tf ] ; % Parameters

dv = [ 0 ; − 9 . 8 1 ] ; % D i f f e r e n t i a l equations
dp = v ;
dx = [ dv ; dp ] . ∗ t f ;

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Integration example cont’d

v0 = 2 0 ; % Initial velocity

p r o b s t r u c t=s t r u c t ( ' x ' , x , ' ode ' , dx , ' p ' , p ) ;


opts = s t r u c t ( ' grid ' , l i n s p a c e (0 ,1 ,100) ) ;
F = integrator ( 'F ' , ' cvodes ' , prob struct , opts ) ;

a =45;
Fk = F ( ' x0 ' , [ v0 ∗ c o s ( a ) ; v0 ∗ s i n ( a ) ; 0 ; 1 ] , ' p ' , [ a , 3 . 5 ] ) ;
X = f u l l ( Fk . x f ) ' ;
p l o t (X ( : , 3 ) ,X ( : , 4 ) )

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Single shooting

How to maximize throw distance?

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Single shooting

How to maximize throw distance?




min −px (θ)
θ tf

subject to
t=t
Z f
dp
ptf = dt + pt0
dt
t=0
py ≥ 0

Verheyleweghen & Backi Optimization & Optimal Control


General principle - Mathematical Optimization
CasADi Software
Optimization
Linear Programming
Optimal Control
Quadratic Programming
Conclusion
Nonlinear Programming
Integration

CasADi - Single shooting

F = integrator ( 'F ' , ' cvodes ' , prob struct , opts ) ;


x0 = [ v0 ∗ c o s ( t h e t a ) ; v0 ∗ s i n ( t h e t a ) ; 0 ; 1 ] ;
Fk = F ( ' x0 ' , x0 , ' p ' , [ t h e t a , t f i n a l ] ) ;
Xk = Fk . x f ; % Expression f o r s t a t e s at t f

x = [ v ; p ; theta ; tf ] ; % Decision variables


p r o b = s t r u c t ( ' x ' , x , ' f ' ,−p ( 1 ) , ' g ' , [ v ; p]−Xk ) ;
s o l v e r = n l p s o l ( ' s o l v e r ' , ' i p o p t ' , prob ) ;

s o l = s o l v e r ( ' x0 ' , [ 1 ; 1 ; 5 ; 0 ; p i / 6 ; 5 ] , ...


' lbg ' , [ 0 ; 0 ; 0 ; 0 ] , ...
' ubg ' , [ 0 ; 0 ; 0 ; 0 ] , ...
' lbx ' , [ 0 ; −i n f ; 0; 0; 0; 0] , ...
' ubx ' , [ i n f ; i n f ; i n f ; i n f ; p i / 2 ; i n f ] ) ;

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Control explained

What is control / automatic control?

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Control explained

What is control / automatic control?

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Dynamic Optimization

Use optimization tools to calculate optimal input function


minimizing a cost function over a (fixed) time horizon subject
to the dynamical system and other constraints from e.g.
physical limitations

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Dynamic Optimization

Use optimization tools to calculate optimal input function


minimizing a cost function over a (fixed) time horizon subject
to the dynamical system and other constraints from e.g.
physical limitations
Focus here on Direct methods: Finite discretization in time
(first discretize, then optimize)

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Dynamic Optimization

Use optimization tools to calculate optimal input function


minimizing a cost function over a (fixed) time horizon subject
to the dynamical system and other constraints from e.g.
physical limitations
Focus here on Direct methods: Finite discretization in time
(first discretize, then optimize)
- Sequential (single / multiple shooting) and simultaneous
(collocation) approaches

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Dynamic Optimization

Use optimization tools to calculate optimal input function


minimizing a cost function over a (fixed) time horizon subject
to the dynamical system and other constraints from e.g.
physical limitations
Focus here on Direct methods: Finite discretization in time
(first discretize, then optimize)
- Sequential (single / multiple shooting) and simultaneous
(collocation) approaches
- Most commonly used for solving Optimal Control Problems,
but ”only” suboptimal / approximate solution

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Notation

min V (x, u)
u∈U
subject to ẋ − f (x, u) = 0
gi (x, u) ≤ 0, i = 1, . . . , m
hj (x, u) = 0, j = 1, . . . , p,
with V (x, u) objective function
ẋ − f (x, u) = 0 dynamic constraints
gi (x, u) inequality constraints
hj (x, u) equality constraints
U the feasible set of inputs

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Single shooting

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Use and basic structure

With ACADO (Automatic Control And Dynamic Optimization),


different Optimal Control Problems can be solved

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Use and basic structure

With ACADO (Automatic Control And Dynamic Optimization),


different Optimal Control Problems can be solved
Offline dynamic optimization
Parameter and state estimation
Model Predictive Control

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Use and basic structure

With ACADO (Automatic Control And Dynamic Optimization),


different Optimal Control Problems can be solved
Offline dynamic optimization
Parameter and state estimation
Model Predictive Control
ACADO has user-friendly MATLAB implementation with
automatic C++ code generation

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Use and basic structure

With ACADO (Automatic Control And Dynamic Optimization),


different Optimal Control Problems can be solved
Offline dynamic optimization
Parameter and state estimation
Model Predictive Control
ACADO has user-friendly MATLAB implementation with
automatic C++ code generation
ACADO is built up object-oriented and consists of so called base
classes, where lower classes inherit from their base class. ACADO
classes can be replaced by external classes or used stand-alone

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Compressor surge control


1.5

1
← Throttle charact. Φ
← Compr. charact. Ψ

← setpoint
0.5

ψ
0

CCV Throttle
−0.5
−0.4 −0.2 0 0.2 0.4 0.6 0.8
Compressor Plenum φ

1 p √ 
ψ̇ = x˙1 = x2 − γ x1 + x10 − x10
B
φ̇ = x˙2 = B −k3 x23 − k2 x22 − k1 x2 − x1 − u


Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Compressor surge control - simple

Z 20
min V = P(x1 − x1ref )2 + Q(x2 − x2ref )2 + R(u − u ref )2 dt
u 0

1 p √ 
subject to x˙1 = x2 − γ x1 + x10 − x10
B
x˙2 = B −k3 x23 − k2 x22 − k1 x2 − x1 − u


0 ≤ u(t) ≤ 0.2
x1 (0) = 0.1
x2 (0) = 0

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

ACADO - Syntax

BEGIN ACADO ;
a c a d o S e t ( ' problemname ' , ' c o m p r e s s o r c o n t r o l s i m p l e ' ) ;

D i f f e r e n t i a l S t a t e x1 x2 ; C o n t r o l u ;

f = acado . D i f f e r e n t i a l E q u a t i o n ( ) ;
f . add ( d o t ( x1 ) == 1/B∗( x2−gamma ∗ ( ( x1+x10 ) ˆ ( 1 / 2 )−(x10 ) ˆ ( 1 / 2 ) ) ) ) ;
f . add ( d o t ( x2 ) == B∗(−k3 ∗ x2ˆ3−k2 ∗ x2ˆ2−k1∗x2−x1−u ) ) ;

S = 1 e2 ∗ e y e ( 3 ) ; S ( 1 , 1 ) = 1 e2 ; h = {u x1 x2 } ; r = [ 0 0 0 ] ;
ocp = a c a d o . OCP ( 0 . 0 , 2 0 , 5 0 ) ;
ocp . minimizeLSQ ( S , h , r ) ;
ocp . s u b j e c t T o ( f ) ;
ocp . s u b j e c t T o ( 'AT START ' , x1 == 0 . 1 ) ; ocp . s u b j e c t T o ( 'AT START ' , x2 == 0 ) ;
ocp . s u b j e c t T o ( 0 <= u <= 0 . 2 ) ;

a l g o=a c a d o . O p t i m i z a t i o n A l g o r i t h m ( ocp ) ;
a l g o . s e t ( 'KKT TOLERANCE ' , 1 e−6 ) ;
a l g o . s e t ( 'INTEGRATOR TYPE ' , ' INT RK45 ' ) ;
a l g o . s e t ( ' HESSIAN APPROXIMATION ' , 'GAUSS NEWTON ' ) ;
a l g o . s e t ( ' DISCRETIZATION TYPE ' , 'COLLOCATION ' ) ;
END ACADO ;
out = co m p re s so r c on t r ol s i mp l e R U N ( ) ;

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Compressor surge control – more advanced

Z τ
min V = P(x1 − x1ref )2 + Q(x2 − x2ref )2 + R(u − u ref )2
w 0
+ O(w − w ref )2 + W (τ − τ ref ) dt

1 p √ 
subject to x˙1 = x2 − γ x1 + x10 − x10
B
x˙2 = B −k3 x23 − k2 x22 − k1 x2 − x1 − u


u̇ = w
0 ≤ u(t) ≤ 0.2, −0.1 ≤ w ≤ 0.1
15 ≤ τ ≤ 25
x1 (0) = 0.1, x2 (0) = 0
Verheyleweghen & Backi Optimization & Optimal Control
Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

ACADO - Syntax
BEGIN ACADO ;
a c a d o S e t ( ' problemname ' , ' c o m p r e s s o r c o n t r o l ' ) ;

D i f f e r e n t i a l S t a t e x1 x2 u ; C o n t r o l w ; P a r a m e t e r t a u ;

f = acado . D i f f e r e n t i a l E q u a t i o n ( 0 , tau ) ;
f . add ( d o t ( x1 ) == 1/B∗( x2−gamma ∗ ( ( x1+x10 ) ˆ ( 1 / 2 )−(x10 ) ˆ ( 1 / 2 ) ) ) ) ;
f . add ( d o t ( x2 ) == B∗(−k3 ∗ x2ˆ3−k2 ∗ x2ˆ2−k1∗x2−x1−u ) ) ;
f . add ( d o t ( u ) == w) ;

S = 1 e2 ∗ e y e ( 5 ) ; h = { t a u w u x1 x2 } ; r = [ 2 0 0 0 0 0 ] ;
ocp = a c a d o . OCP ( 0 . 0 , tau , 5 0 ) ;
ocp . minimizeLSQ ( S , h , r ) ;
ocp . s u b j e c t T o ( f ) ;
ocp . s u b j e c t T o ( 'AT START ' , x1 == 0 . 1 ) ; ocp . s u b j e c t T o ( 'AT START ' , x2 == 0 ) ;
ocp . s u b j e c t T o ( 0 <= u <= 0 . 2 ) ;
ocp . s u b j e c t T o ( −0.1 <= w <= 0 . 1 ) ;
ocp . s u b j e c t T o ( 15 <= t a u <= 25 ) ;

a l g o=a c a d o . O p t i m i z a t i o n A l g o r i t h m ( ocp ) ;
a l g o . s e t ( 'KKT TOLERANCE ' , 1 e−6 ) ;
a l g o . s e t ( 'INTEGRATOR TYPE ' , ' INT RK45 ' ) ;
a l g o . s e t ( ' HESSIAN APPROXIMATION ' , 'GAUSS NEWTON ' ) ;
a l g o . s e t ( ' DISCRETIZATION TYPE ' , 'COLLOCATION ' ) ;
END ACADO ;
out = compressor control RUN ( ) ;

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Freezing of a block of foodstuff

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Freezing of a block of foodstuff

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Freezing of a block of foodstuff

Temperature

Freezing Thermal arrest


point

Time

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Freezing of a block of foodstuff

Temperature

Freezing Thermal arrest


point

Time

ρ(T )c(T )Tt = [λ(T )Tx ]x = λT (T )Tx2 + λ(T )Txx

⇒ Tt = κ(T )Tx2 + k(T )Txx

with T (t, 0) = T (t, L) = u.

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

Problem description

Z τ
min V = (T − T ref )T P(T − T ref ) + Q(u − u ref )2
v 0
+ R(v − v ref )2 + W (τ − τ ref )2 dt

Ṫ − f (T , u) = 0 T (0) = 280 · 1(9×1)


u̇ = v u(0) = 235
subject to 235 ≤ u(t) ≤ 255 T (τ ) ∈ T
−0.01 ≤ v ≤ 0.01 T (t) ≥ 245
6000 ≤ τ ≤ 10000

Verheyleweghen & Backi Optimization & Optimal Control


Optimization General principle
Optimal Control ACADO Software
Conclusion Examples

ACADO - Syntax
BEGIN ACADO ;
a c a d o S e t ( ' problemname ' , ' f r e e z i n g ' ) ;
D i f f e r e n t i a l S t a t e T1 T2 T3 T4 T5 T6 T7 T8 T9 u ; P a r a m e t e r t a u ; C o n t r o l v ;
f = acado . D i f f e r e n t i a l E q u a t i o n ( 0 , tau ) ;
f . add ( d o t ( T1 ) == kappa ( T1 ) / ( 0 . 1 / 9 ) ˆ2∗( T1−u ) ˆ2 + k ( T1 ) / ( 0 . 1 / 9 ) ˆ2∗( T2−2∗T1+u ) ) ; ...
f . add ( d o t ( u ) == v ) ;
S = 1 e3 ∗ e y e ( 1 2 ) ; S ( 1 , 1 ) = 1 e1 ; S ( 2 , 2 ) = 1 e1 ; S ( 3 , 3 ) = 1 e −1;
h = {u v t a u T1 T2 T3 T4 T5 T6 T7 T8 T9 } ;
r = [ 2 5 5 0 8000 251 2 5 1 . 5 252 2 5 2 . 5 253 2 5 2 . 5 252 2 5 1 . 5 2 5 1 ] ;
ocp = a c a d o . OCP ( 0 . 0 , tau , 1 0 0 ) ;
ocp . minimizeLSQ ( S , h , r ) ;
ocp . s u b j e c t T o ( f ) ;
ocp . s u b j e c t T o ( 'AT START ' , T1 == x0 ( 1 ) ) ; ...
ocp . s u b j e c t T o ( 'AT END ' , 250 <= T1 <= 2 5 2 ) ; ...
ocp . s u b j e c t T o ( T1 >= 2 4 5 ) ; ...
ocp . s u b j e c t T o ( 6000 <= t a u <= 10000 ) ;
ocp . s u b j e c t T o ( 235 <= u <= 255 ) ;
ocp . s u b j e c t T o ( −0.01 <= v <= 0 . 0 1 ) ;
a l g o=a c a d o . O p t i m i z a t i o n A l g o r i t h m ( ocp ) ;
a l g o . s e t ( 'KKT TOLERANCE ' , 1 e−6 ) ;
a l g o . s e t ( 'INTEGRATOR TYPE ' , ' INT RK78 ' ) ;
a l g o . s e t ( ' HESSIAN APPROXIMATION ' , 'GAUSS NEWTON ' ) ;
a l g o . s e t ( ' DISCRETIZATION TYPE ' , ' SINGLE SHOOTING ' ) ;
END ACADO ;
out = freezing RUN ( ) ;

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control Installation
Conclusion

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
Optimization
Optimal Control Installation
Conclusion

When to use what

Use CasADi when solving simple problems (LPs, QPs or NLPs) or


when flexibility is needed.

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control Installation
Conclusion

When to use what

Use CasADi when solving simple problems (LPs, QPs or NLPs) or


when flexibility is needed.
Use ACADO when you want to find an optimal input function to a
set of dynamic equations (ODEs / DAEs) subject to constraints.
Danger: Infeasible solutions for e.g. too short time horizons, too
tight constraints, etc.

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control Installation
Conclusion

Outline
1 Optimization
General principle - Mathematical Optimization
CasADi Software
Linear Programming
Quadratic Programming
Nonlinear Programming
Integration
2 Optimal Control
General principle
ACADO Software
Examples
3 Conclusion
Installation
Verheyleweghen & Backi Optimization & Optimal Control
Optimization
Optimal Control Installation
Conclusion

Procedure and requirements

For CasADi:
Download the files from GitHub and add them to your MATLAB /
Python path - done.

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control Installation
Conclusion

Procedure and requirements

For CasADi:
Download the files from GitHub and add them to your MATLAB /
Python path - done.
For ACADO:
You need: MATLAB, a C/C++ compiler and the ACADO files
Download from https://github.com/acado/acado
Go to https://sourceforge.net/p/acado/wiki/MATLAB
Interface - Getting Started/ and follow the instructions.
Link the C/C++ compiler to MATLAB and then build the
ACADO interface in MATLAB

Verheyleweghen & Backi Optimization & Optimal Control


Optimization
Optimal Control Installation
Conclusion

Further Reading

[1] Jorge Nocedal & Stephen J. Wright –


Numerical Optimization. Springer, Second Edition, 2006.
[2] Moritz Diehl & Sebastien Gros –
Numerical Optimization of Dynamic Systems (Draft). 2016.
[3] David Ariens, Hans J. Ferreau, Boris Houska & Filip Logist –
ACADO for Matlab User’s Manual
[4] David Ariens, Moritz Diehl, Hans J. Ferreau, Boris Houska
Filip Logist, Rien Quirynen & Milan Vukov –
ACADO Toolkit User’s Manual

Verheyleweghen & Backi Optimization & Optimal Control

Você também pode gostar