SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
Real Time Code Generation for
Nonlinear Model Predictive Control
Behzad Samadi
Department of Research and Development
Model Predictive Control (MPC)
What is MPC?
MPC is a closed loop implementation of optimal control.
Why not use a PID?
PID controllers do not perform well for highly nonlinear systems.
To control a multi-input multi-output (MIMO) system, many
PID controllers in different loops are required.
Tuning PID controllers is not an easy task, especially when
there are state and input constraints.
Why MPC?
MPC can handle constraints on inputs and states.
MPC can be designed for MIMO nonlinear systems.
Tuning an MPC controller is more intuitive compared to a set
of PID controllers.
MPC is a systematic, model based approach.
There are tools for generating code for MPC controllers
automatically.
Nonlinear
System Model
MPC Controller
Code
Automatic
Code Generation
Example
A race driver needs to look forward! (prediction)
Minimize a cost function at each time instant depending on the
current situation (closed loop optimal control)
Optimization constraints:
Vehicle’s dynamic behavior
Limited power
No skidding
Following the road
Avoiding collision
MPC Applications
Chemical process control
Oil refineries
Pulp and paper
Mechatronics
Robotics
Washing machines
Automotive
Engine controllers
Aerospace
Aircraft control
Spacecraft formation and attitude control
Power generation
Computational biology
Nonlinear Model
Consider the following nonlinear system:
˙x(t) =f (x(t), u(t))
x(t0) =x◦
where:
x(t) is the state vector
u(t) is the input vector
Optimal Control Problem
minimize
u
J(x0, t0) = φ(x(tf )) +
tf
t0
L(x(τ), u(τ))dτ
subject to ˙x(t) = f (x(t), u(t))
x(t0) = x◦
gi (x(t), u(t)) = 0, for i = 1, . . . , ng
hi (x(t), u(t)) ≤ 0, for i = 1, . . . , nh
Barrier Method
Using a particular interior-point algorithm, the barrier method,
the inequality constraints are converted to equality constraints:
minimize
u,α
φ(x(tf )) +
tf
t0
L(x(τ), u(τ)) − rT
α(τ) dτ
subject to ˙x(t) = f (x(t), u(t))
x(t0) = x◦
gi (x(t), u(t)) = 0, for i = 1, . . . , ng
hi (x(t), u(t)) + αi (t)2
= 0, for i = 1, . . . , nh
where α(t) ∈ Rnh is a vector slack variable and the entries of
r ∈ Rnh are small positive numbers.
(Boyd and Vandenberghe 2004)
(Diehl, Ferreau, and Haverbeke 2009)
Discretization
Discretize the problem into N steps from t0 to tf :
minimize
u,α
φd (xN) +
N−1
k=0
L(xk, uk) − rT
αk
subject to xk+1 = fd (xk, uk)
x0 = x◦
gi (xk, uk) = 0, for i = 1, . . . , ng
hi (xk, uk) + α2
ik = 0, for i = 1, . . . , nh
where ∆τ = tf −t0
N and:
φd (xN) =
φ(x(tf ), tf )
∆τ
fd (xk, uk) = xk + f (xk, uk)∆τ
Optimization Problem
minimize
u,α
φd (xN) +
N−1
k=0
L(xk, uk) − rT
αk
subject to xk+1 = fd (xk, uk)
x0 = x◦
G(xk, uk, αk) = 0
where:
G(xk, uk, αk) =











g1(xk, uk)
...
gng (xk, uk)
h1(xk, uk) + α2
1k
...
hnh
(xk, uk) + α2
nhk











Lagrange Multipliers
Lagrange multipliers:
L(x, u, α, λ, ν) = φd (xN, N) + (x◦ − x0)T
λ0
+
N−1
k=0
L(xk, uk) − rT
αk
+ (fd (xk, uk) − xk+1)T
λk+1
+G(xk, uk, αk)T
νk
Optimality conditions:
Lxk
= 0, Lλk
= 0 for k = 0, . . . , N
Lαk
= 0, Luk
= 0, Lνk
= 0 for k = 0, . . . , N − 1
Hamiltonian
L(x, u, α, λ, ν) can be rewritten as:
L(x, u, α, λ, ν) =φd (xN) + xT
◦ λ0 − xT
N λN
+
N−1
k=0
H(xk, uk, αk, λk+1) − xT
k λk
Hamiltonian:
H(xk, uk, αk, λk+1, νk) =L(xk, uk) − rT
αk
+ fd (xk, uk)T
λk+1 + G(xk, uk, αk)T
νk
Pontryagin’s Maximum Principle
Optimality Conditions
Lλk+1
= 0 xk+1 = fd (xk , uk)
Lλ0 = 0 x0 = x◦
Lxk
= 0 λk = Hx (xk , uk, αk, λk+1, νk )
LxN
= 0 λN = ∂
∂xN
φd (xN)
Luk
= 0 Hu(xk , uk, αk, λk+1, νk ) = 0
Lαk
= 0 Hα(xk , uk, αk, λk+1, νk ) = 0
Lνk
= 0 G(xk , uk, αk) = 0
for k = 0, . . . , N − 1 where denote the optimal solution
Model Predictive Control
This is optimal control but what is MPC?
MPC is the optimal controller in the loop:
1. Measure/estimate the current state xn.
2. Solve the optimal control problem to compute uk for
k = n, . . . , n + N − 1.
3. Return un as the value of the control input.
4. Update n.
5. Goto step 1.
MPC is implemented in real time.
Continuation/GMRES Method
Step 1: Compute xk and λk as functions of uk, αk and νk,
given the following equations:
xk+1 = fd (xk, uk)
x0 = xn
λk = Hx (xk, uk, αk, λk+1, νk)
λN =
∂
∂xN
φd (xN)
(Ohtsuka 2004)
Continuation/GMRES Method
Step 2: For
U = [uT
0 , . . . , uT
N−1, αT
0 , . . . , αT
N−1, νT
0 , . . . , νT
N−1]T
solve the equation F(xn, U) = 0, where:
F(xn, U) =












Hu(x0, u0, α0, λ1, ν0)
Hα(x0, u0, α0, λ1, ν0)
G(x0, u0, α0)
...
Hu(xN−1, uN−1, αN−1, λN, νN−1)
Hα(xN−1, uN−1, αN−1, λN, νN−1)
G(xN−1, uN−1, αN−1)












(Ohtsuka 2004)
Continuation/GMRES Method
Continuation method: Instead of solving F(x, U) = 0, find U
such that:
˙F(x, U) = AsF(x, U)
where As is a matrix with negative eigenvalues.
Now, we have:
Fx ˙x + FU
˙U = AsF(x, U)
GMRES: To compute ˙U using the following equation, which is
linear in ˙U, we use the generalized minimum residual (GMRES)
algorithm.
FU
˙U = AsF(x, U) − Fx f (x, u)
To compute U at any given time, we need to have an initial
value for U and then use the above ˙U to update it.
(Ohtsuka 2004)
Example
Controling the position and orientation of a hovercraft:
(Seguchi and Ohtsuka 2003)
Example
Dynamic equations:
M¨x =u1 cos(θ) + u2 cos(θ)
M¨y =u1 sin(θ) + u2 sin(θ)
I ¨θ =u1r − u2r
Variables:
Variable Type Unit
x position m
y position m
θ orientation rad
u1 force N
u2 force N
(Seguchi and Ohtsuka 2003)
Example
Nonlinear Model Predictive Control (NMPC)
Automatic code generation
References
Boyd, S.P., and L. Vandenberghe. 2004. Convex Optimization.
Cambridge Univ Pr.
Diehl, Moritz, Hans Joachim Ferreau, and Niels Haverbeke. 2009.
“Efficient Numerical Methods for Nonlinear MPC and Moving
Horizon Estimation.” In Nonlinear Model Predictive Control,
391–417. Springer.
Ohtsuka, Toshiyuki. 2004. “A Continuation/GMRES Method for
Fast Computation of Nonlinear Receding Horizon Control.”
Automatica 40 (4). Elsevier: 563–74.
Seguchi, Hiroaki, and Toshiyuki Ohtsuka. 2003. “Nonlinear
Receding Horizon Control of an Underactuated Hovercraft.”
International Journal of Robust and Nonlinear Control 13 (3-4).
Wiley Online Library: 381–98.
Real Time Code Generation for Nonlinear Model Predictive Control

Más contenido relacionado

La actualidad más candente

Engineering formula sheet
Engineering formula sheetEngineering formula sheet
Engineering formula sheetsankalptiwari
 
Sampled-Data Piecewise Affine Slab Systems: A Time-Delay Approach
Sampled-Data Piecewise Affine Slab Systems: A Time-Delay ApproachSampled-Data Piecewise Affine Slab Systems: A Time-Delay Approach
Sampled-Data Piecewise Affine Slab Systems: A Time-Delay ApproachBehzad Samadi
 
6 radar range-doppler-angular loops
6 radar range-doppler-angular loops6 radar range-doppler-angular loops
6 radar range-doppler-angular loopsSolo Hermelin
 
Mecánica para ingeniería dinámica bedford - 5ed (sol)
Mecánica para ingeniería  dinámica   bedford - 5ed (sol)Mecánica para ingeniería  dinámica   bedford - 5ed (sol)
Mecánica para ingeniería dinámica bedford - 5ed (sol)sneydergustavo diaz
 
Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...
Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...
Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...Alexander Litvinenko
 
ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)Antonin Hoskovec
 
Unbiased Markov chain Monte Carlo
Unbiased Markov chain Monte CarloUnbiased Markov chain Monte Carlo
Unbiased Markov chain Monte CarloJeremyHeng10
 
Phase Retrieval: Motivation and Techniques
Phase Retrieval: Motivation and TechniquesPhase Retrieval: Motivation and Techniques
Phase Retrieval: Motivation and TechniquesVaibhav Dixit
 
Circuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace TransformCircuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace TransformSimen Li
 
Ultrasound lecture 1 post
Ultrasound lecture 1 postUltrasound lecture 1 post
Ultrasound lecture 1 postlucky shumail
 
Dynamic response to harmonic excitation
Dynamic response to harmonic excitationDynamic response to harmonic excitation
Dynamic response to harmonic excitationUniversity of Glasgow
 
Calculus of variations
Calculus of variationsCalculus of variations
Calculus of variationsSolo Hermelin
 
Computation of electromagnetic fields scattered from dielectric objects of un...
Computation of electromagnetic fields scattered from dielectric objects of un...Computation of electromagnetic fields scattered from dielectric objects of un...
Computation of electromagnetic fields scattered from dielectric objects of un...Alexander Litvinenko
 
Operators n dirac in qm
Operators n dirac in qmOperators n dirac in qm
Operators n dirac in qmAnda Tywabi
 

La actualidad más candente (20)

Engineering formula sheet
Engineering formula sheetEngineering formula sheet
Engineering formula sheet
 
Sampled-Data Piecewise Affine Slab Systems: A Time-Delay Approach
Sampled-Data Piecewise Affine Slab Systems: A Time-Delay ApproachSampled-Data Piecewise Affine Slab Systems: A Time-Delay Approach
Sampled-Data Piecewise Affine Slab Systems: A Time-Delay Approach
 
6 radar range-doppler-angular loops
6 radar range-doppler-angular loops6 radar range-doppler-angular loops
6 radar range-doppler-angular loops
 
Mecánica para ingeniería dinámica bedford - 5ed (sol)
Mecánica para ingeniería  dinámica   bedford - 5ed (sol)Mecánica para ingeniería  dinámica   bedford - 5ed (sol)
Mecánica para ingeniería dinámica bedford - 5ed (sol)
 
Newton's Laws of Motion L2.1
Newton's Laws of Motion L2.1Newton's Laws of Motion L2.1
Newton's Laws of Motion L2.1
 
Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...
Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...
Computation of electromagnetic_fields_scattered_from_dielectric_objects_of_un...
 
ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)
 
beamer
beamerbeamer
beamer
 
Unbiased Markov chain Monte Carlo
Unbiased Markov chain Monte CarloUnbiased Markov chain Monte Carlo
Unbiased Markov chain Monte Carlo
 
Phase Retrieval: Motivation and Techniques
Phase Retrieval: Motivation and TechniquesPhase Retrieval: Motivation and Techniques
Phase Retrieval: Motivation and Techniques
 
Ch19
Ch19Ch19
Ch19
 
Ladder operator
Ladder operatorLadder operator
Ladder operator
 
Circuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace TransformCircuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace Transform
 
Lecture13 controls
Lecture13  controls Lecture13  controls
Lecture13 controls
 
Ultrasound lecture 1 post
Ultrasound lecture 1 postUltrasound lecture 1 post
Ultrasound lecture 1 post
 
Dynamic response to harmonic excitation
Dynamic response to harmonic excitationDynamic response to harmonic excitation
Dynamic response to harmonic excitation
 
residue
residueresidue
residue
 
Calculus of variations
Calculus of variationsCalculus of variations
Calculus of variations
 
Computation of electromagnetic fields scattered from dielectric objects of un...
Computation of electromagnetic fields scattered from dielectric objects of un...Computation of electromagnetic fields scattered from dielectric objects of un...
Computation of electromagnetic fields scattered from dielectric objects of un...
 
Operators n dirac in qm
Operators n dirac in qmOperators n dirac in qm
Operators n dirac in qm
 

Similar a Real Time Code Generation for Nonlinear Model Predictive Control

A numerical method to solve fractional Fredholm-Volterra integro-differential...
A numerical method to solve fractional Fredholm-Volterra integro-differential...A numerical method to solve fractional Fredholm-Volterra integro-differential...
A numerical method to solve fractional Fredholm-Volterra integro-differential...OctavianPostavaru
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESTahia ZERIZER
 
Markov Tutorial CDC Shanghai 2009
Markov Tutorial CDC Shanghai 2009Markov Tutorial CDC Shanghai 2009
Markov Tutorial CDC Shanghai 2009Sean Meyn
 
Natalini nse slide_giu2013
Natalini nse slide_giu2013Natalini nse slide_giu2013
Natalini nse slide_giu2013Madd Maths
 
An Approach For Solving Nonlinear Programming Problems
An Approach For Solving Nonlinear Programming ProblemsAn Approach For Solving Nonlinear Programming Problems
An Approach For Solving Nonlinear Programming ProblemsMary Montoya
 
Reinforcement Learning: Hidden Theory and New Super-Fast Algorithms
Reinforcement Learning: Hidden Theory and New Super-Fast AlgorithmsReinforcement Learning: Hidden Theory and New Super-Fast Algorithms
Reinforcement Learning: Hidden Theory and New Super-Fast AlgorithmsSean Meyn
 
Geometric and viscosity solutions for the Cauchy problem of first order
Geometric and viscosity solutions for the Cauchy problem of first orderGeometric and viscosity solutions for the Cauchy problem of first order
Geometric and viscosity solutions for the Cauchy problem of first orderJuliho Castillo
 
International journal of engineering and mathematical modelling vol2 no3_2015_2
International journal of engineering and mathematical modelling vol2 no3_2015_2International journal of engineering and mathematical modelling vol2 no3_2015_2
International journal of engineering and mathematical modelling vol2 no3_2015_2IJEMM
 
Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...
Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...
Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...Michael Lie
 
5.2 primitive recursive functions
5.2 primitive recursive functions5.2 primitive recursive functions
5.2 primitive recursive functionsSampath Kumar S
 
Quantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averagesQuantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averagesVjekoslavKovac1
 
Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014Nikita V. Artamonov
 
A series of maximum entropy upper bounds of the differential entropy
A series of maximum entropy upper bounds of the differential entropyA series of maximum entropy upper bounds of the differential entropy
A series of maximum entropy upper bounds of the differential entropyFrank Nielsen
 
Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)Haruki Nishimura
 

Similar a Real Time Code Generation for Nonlinear Model Predictive Control (20)

A numerical method to solve fractional Fredholm-Volterra integro-differential...
A numerical method to solve fractional Fredholm-Volterra integro-differential...A numerical method to solve fractional Fredholm-Volterra integro-differential...
A numerical method to solve fractional Fredholm-Volterra integro-differential...
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
 
Markov Tutorial CDC Shanghai 2009
Markov Tutorial CDC Shanghai 2009Markov Tutorial CDC Shanghai 2009
Markov Tutorial CDC Shanghai 2009
 
Natalini nse slide_giu2013
Natalini nse slide_giu2013Natalini nse slide_giu2013
Natalini nse slide_giu2013
 
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
 
An Approach For Solving Nonlinear Programming Problems
An Approach For Solving Nonlinear Programming ProblemsAn Approach For Solving Nonlinear Programming Problems
An Approach For Solving Nonlinear Programming Problems
 
Navid_Alavi
Navid_AlaviNavid_Alavi
Navid_Alavi
 
Reinforcement Learning: Hidden Theory and New Super-Fast Algorithms
Reinforcement Learning: Hidden Theory and New Super-Fast AlgorithmsReinforcement Learning: Hidden Theory and New Super-Fast Algorithms
Reinforcement Learning: Hidden Theory and New Super-Fast Algorithms
 
Geometric and viscosity solutions for the Cauchy problem of first order
Geometric and viscosity solutions for the Cauchy problem of first orderGeometric and viscosity solutions for the Cauchy problem of first order
Geometric and viscosity solutions for the Cauchy problem of first order
 
International journal of engineering and mathematical modelling vol2 no3_2015_2
International journal of engineering and mathematical modelling vol2 no3_2015_2International journal of engineering and mathematical modelling vol2 no3_2015_2
International journal of engineering and mathematical modelling vol2 no3_2015_2
 
Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...
Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...
Time-Series Analysis on Multiperiodic Conditional Correlation by Sparse Covar...
 
02_AJMS_297_21.pdf
02_AJMS_297_21.pdf02_AJMS_297_21.pdf
02_AJMS_297_21.pdf
 
Adaptive dynamic programming algorithm for uncertain nonlinear switched systems
Adaptive dynamic programming algorithm for uncertain nonlinear switched systemsAdaptive dynamic programming algorithm for uncertain nonlinear switched systems
Adaptive dynamic programming algorithm for uncertain nonlinear switched systems
 
5.2 primitive recursive functions
5.2 primitive recursive functions5.2 primitive recursive functions
5.2 primitive recursive functions
 
Quantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averagesQuantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averages
 
QMC: Operator Splitting Workshop, Boundedness of the Sequence if Iterates Gen...
QMC: Operator Splitting Workshop, Boundedness of the Sequence if Iterates Gen...QMC: Operator Splitting Workshop, Boundedness of the Sequence if Iterates Gen...
QMC: Operator Splitting Workshop, Boundedness of the Sequence if Iterates Gen...
 
Signal Processing Homework Help
Signal Processing Homework HelpSignal Processing Homework Help
Signal Processing Homework Help
 
Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014
 
A series of maximum entropy upper bounds of the differential entropy
A series of maximum entropy upper bounds of the differential entropyA series of maximum entropy upper bounds of the differential entropy
A series of maximum entropy upper bounds of the differential entropy
 
Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)
 

Más de Behzad Samadi

سیستم ترمز ضدقفل ABS
سیستم ترمز ضدقفل ABSسیستم ترمز ضدقفل ABS
سیستم ترمز ضدقفل ABSBehzad Samadi
 
Active Suspension System
Active Suspension SystemActive Suspension System
Active Suspension SystemBehzad Samadi
 
Introducing Myself Through Websites!
Introducing Myself Through Websites!Introducing Myself Through Websites!
Introducing Myself Through Websites!Behzad Samadi
 
Controller Synthesis for Nonholonomic Robots - Japanese
Controller Synthesis for Nonholonomic Robots - JapaneseController Synthesis for Nonholonomic Robots - Japanese
Controller Synthesis for Nonholonomic Robots - JapaneseBehzad Samadi
 
Controller Synthesis for Nonholonomic Robots
Controller Synthesis for Nonholonomic RobotsController Synthesis for Nonholonomic Robots
Controller Synthesis for Nonholonomic RobotsBehzad Samadi
 
Lead-Lag Controller Design - Persian
Lead-Lag Controller Design - PersianLead-Lag Controller Design - Persian
Lead-Lag Controller Design - PersianBehzad Samadi
 
Industrial Control Systems - PLC
Industrial Control Systems - PLCIndustrial Control Systems - PLC
Industrial Control Systems - PLCBehzad Samadi
 
Industrial Control Systems - Special Structures
Industrial Control Systems - Special StructuresIndustrial Control Systems - Special Structures
Industrial Control Systems - Special StructuresBehzad Samadi
 
Industrial Control Systems - PID Controllers
Industrial Control Systems - PID ControllersIndustrial Control Systems - PID Controllers
Industrial Control Systems - PID ControllersBehzad Samadi
 
Industrial Control Systems - Automotive Systems
Industrial Control Systems - Automotive SystemsIndustrial Control Systems - Automotive Systems
Industrial Control Systems - Automotive SystemsBehzad Samadi
 
Industrial Control Systems - Chemical Systems
Industrial Control Systems - Chemical SystemsIndustrial Control Systems - Chemical Systems
Industrial Control Systems - Chemical SystemsBehzad Samadi
 
Industrial Control Systems - Thermal Systems
Industrial Control Systems - Thermal SystemsIndustrial Control Systems - Thermal Systems
Industrial Control Systems - Thermal SystemsBehzad Samadi
 
Industrial Control Systems - Liquid Level Systems
Industrial Control Systems - Liquid Level SystemsIndustrial Control Systems - Liquid Level Systems
Industrial Control Systems - Liquid Level SystemsBehzad Samadi
 
Industrial Control Systems - Hydraulic Systems
Industrial Control Systems - Hydraulic SystemsIndustrial Control Systems - Hydraulic Systems
Industrial Control Systems - Hydraulic SystemsBehzad Samadi
 
Industrial Control Systems - Pneumatic Systems
Industrial Control Systems - Pneumatic SystemsIndustrial Control Systems - Pneumatic Systems
Industrial Control Systems - Pneumatic SystemsBehzad Samadi
 
Industrial Control Systems - Modeling
Industrial Control Systems - ModelingIndustrial Control Systems - Modeling
Industrial Control Systems - ModelingBehzad Samadi
 
Modeling, Control and Optimization for Aerospace Systems
Modeling, Control and Optimization for Aerospace SystemsModeling, Control and Optimization for Aerospace Systems
Modeling, Control and Optimization for Aerospace SystemsBehzad Samadi
 
A MATLAB Toolbox for Piecewise-Affine Controller Synthesis
A MATLAB Toolbox for Piecewise-Affine Controller SynthesisA MATLAB Toolbox for Piecewise-Affine Controller Synthesis
A MATLAB Toolbox for Piecewise-Affine Controller SynthesisBehzad Samadi
 
Model Based Fault Detection, Identification and Accommodation in Antilock Bra...
Model Based Fault Detection, Identification and Accommodation in Antilock Bra...Model Based Fault Detection, Identification and Accommodation in Antilock Bra...
Model Based Fault Detection, Identification and Accommodation in Antilock Bra...Behzad Samadi
 

Más de Behzad Samadi (20)

سیستم ترمز ضدقفل ABS
سیستم ترمز ضدقفل ABSسیستم ترمز ضدقفل ABS
سیستم ترمز ضدقفل ABS
 
RPS-BehzadSamadi
RPS-BehzadSamadiRPS-BehzadSamadi
RPS-BehzadSamadi
 
Active Suspension System
Active Suspension SystemActive Suspension System
Active Suspension System
 
Introducing Myself Through Websites!
Introducing Myself Through Websites!Introducing Myself Through Websites!
Introducing Myself Through Websites!
 
Controller Synthesis for Nonholonomic Robots - Japanese
Controller Synthesis for Nonholonomic Robots - JapaneseController Synthesis for Nonholonomic Robots - Japanese
Controller Synthesis for Nonholonomic Robots - Japanese
 
Controller Synthesis for Nonholonomic Robots
Controller Synthesis for Nonholonomic RobotsController Synthesis for Nonholonomic Robots
Controller Synthesis for Nonholonomic Robots
 
Lead-Lag Controller Design - Persian
Lead-Lag Controller Design - PersianLead-Lag Controller Design - Persian
Lead-Lag Controller Design - Persian
 
Industrial Control Systems - PLC
Industrial Control Systems - PLCIndustrial Control Systems - PLC
Industrial Control Systems - PLC
 
Industrial Control Systems - Special Structures
Industrial Control Systems - Special StructuresIndustrial Control Systems - Special Structures
Industrial Control Systems - Special Structures
 
Industrial Control Systems - PID Controllers
Industrial Control Systems - PID ControllersIndustrial Control Systems - PID Controllers
Industrial Control Systems - PID Controllers
 
Industrial Control Systems - Automotive Systems
Industrial Control Systems - Automotive SystemsIndustrial Control Systems - Automotive Systems
Industrial Control Systems - Automotive Systems
 
Industrial Control Systems - Chemical Systems
Industrial Control Systems - Chemical SystemsIndustrial Control Systems - Chemical Systems
Industrial Control Systems - Chemical Systems
 
Industrial Control Systems - Thermal Systems
Industrial Control Systems - Thermal SystemsIndustrial Control Systems - Thermal Systems
Industrial Control Systems - Thermal Systems
 
Industrial Control Systems - Liquid Level Systems
Industrial Control Systems - Liquid Level SystemsIndustrial Control Systems - Liquid Level Systems
Industrial Control Systems - Liquid Level Systems
 
Industrial Control Systems - Hydraulic Systems
Industrial Control Systems - Hydraulic SystemsIndustrial Control Systems - Hydraulic Systems
Industrial Control Systems - Hydraulic Systems
 
Industrial Control Systems - Pneumatic Systems
Industrial Control Systems - Pneumatic SystemsIndustrial Control Systems - Pneumatic Systems
Industrial Control Systems - Pneumatic Systems
 
Industrial Control Systems - Modeling
Industrial Control Systems - ModelingIndustrial Control Systems - Modeling
Industrial Control Systems - Modeling
 
Modeling, Control and Optimization for Aerospace Systems
Modeling, Control and Optimization for Aerospace SystemsModeling, Control and Optimization for Aerospace Systems
Modeling, Control and Optimization for Aerospace Systems
 
A MATLAB Toolbox for Piecewise-Affine Controller Synthesis
A MATLAB Toolbox for Piecewise-Affine Controller SynthesisA MATLAB Toolbox for Piecewise-Affine Controller Synthesis
A MATLAB Toolbox for Piecewise-Affine Controller Synthesis
 
Model Based Fault Detection, Identification and Accommodation in Antilock Bra...
Model Based Fault Detection, Identification and Accommodation in Antilock Bra...Model Based Fault Detection, Identification and Accommodation in Antilock Bra...
Model Based Fault Detection, Identification and Accommodation in Antilock Bra...
 

Último

complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Autonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.pptAutonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.pptbibisarnayak0
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectssuserb6619e
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate productionChinnuNinan
 

Último (20)

complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Autonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.pptAutonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.ppt
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate production
 

Real Time Code Generation for Nonlinear Model Predictive Control

  • 1. Real Time Code Generation for Nonlinear Model Predictive Control Behzad Samadi Department of Research and Development
  • 2. Model Predictive Control (MPC) What is MPC? MPC is a closed loop implementation of optimal control. Why not use a PID? PID controllers do not perform well for highly nonlinear systems. To control a multi-input multi-output (MIMO) system, many PID controllers in different loops are required. Tuning PID controllers is not an easy task, especially when there are state and input constraints.
  • 3. Why MPC? MPC can handle constraints on inputs and states. MPC can be designed for MIMO nonlinear systems. Tuning an MPC controller is more intuitive compared to a set of PID controllers. MPC is a systematic, model based approach. There are tools for generating code for MPC controllers automatically. Nonlinear System Model MPC Controller Code Automatic Code Generation
  • 4. Example A race driver needs to look forward! (prediction) Minimize a cost function at each time instant depending on the current situation (closed loop optimal control) Optimization constraints: Vehicle’s dynamic behavior Limited power No skidding Following the road Avoiding collision
  • 5. MPC Applications Chemical process control Oil refineries Pulp and paper Mechatronics Robotics Washing machines Automotive Engine controllers Aerospace Aircraft control Spacecraft formation and attitude control Power generation Computational biology
  • 6. Nonlinear Model Consider the following nonlinear system: ˙x(t) =f (x(t), u(t)) x(t0) =x◦ where: x(t) is the state vector u(t) is the input vector
  • 7. Optimal Control Problem minimize u J(x0, t0) = φ(x(tf )) + tf t0 L(x(τ), u(τ))dτ subject to ˙x(t) = f (x(t), u(t)) x(t0) = x◦ gi (x(t), u(t)) = 0, for i = 1, . . . , ng hi (x(t), u(t)) ≤ 0, for i = 1, . . . , nh
  • 8. Barrier Method Using a particular interior-point algorithm, the barrier method, the inequality constraints are converted to equality constraints: minimize u,α φ(x(tf )) + tf t0 L(x(τ), u(τ)) − rT α(τ) dτ subject to ˙x(t) = f (x(t), u(t)) x(t0) = x◦ gi (x(t), u(t)) = 0, for i = 1, . . . , ng hi (x(t), u(t)) + αi (t)2 = 0, for i = 1, . . . , nh where α(t) ∈ Rnh is a vector slack variable and the entries of r ∈ Rnh are small positive numbers. (Boyd and Vandenberghe 2004) (Diehl, Ferreau, and Haverbeke 2009)
  • 9. Discretization Discretize the problem into N steps from t0 to tf : minimize u,α φd (xN) + N−1 k=0 L(xk, uk) − rT αk subject to xk+1 = fd (xk, uk) x0 = x◦ gi (xk, uk) = 0, for i = 1, . . . , ng hi (xk, uk) + α2 ik = 0, for i = 1, . . . , nh where ∆τ = tf −t0 N and: φd (xN) = φ(x(tf ), tf ) ∆τ fd (xk, uk) = xk + f (xk, uk)∆τ
  • 10. Optimization Problem minimize u,α φd (xN) + N−1 k=0 L(xk, uk) − rT αk subject to xk+1 = fd (xk, uk) x0 = x◦ G(xk, uk, αk) = 0 where: G(xk, uk, αk) =            g1(xk, uk) ... gng (xk, uk) h1(xk, uk) + α2 1k ... hnh (xk, uk) + α2 nhk           
  • 11. Lagrange Multipliers Lagrange multipliers: L(x, u, α, λ, ν) = φd (xN, N) + (x◦ − x0)T λ0 + N−1 k=0 L(xk, uk) − rT αk + (fd (xk, uk) − xk+1)T λk+1 +G(xk, uk, αk)T νk Optimality conditions: Lxk = 0, Lλk = 0 for k = 0, . . . , N Lαk = 0, Luk = 0, Lνk = 0 for k = 0, . . . , N − 1
  • 12. Hamiltonian L(x, u, α, λ, ν) can be rewritten as: L(x, u, α, λ, ν) =φd (xN) + xT ◦ λ0 − xT N λN + N−1 k=0 H(xk, uk, αk, λk+1) − xT k λk Hamiltonian: H(xk, uk, αk, λk+1, νk) =L(xk, uk) − rT αk + fd (xk, uk)T λk+1 + G(xk, uk, αk)T νk
  • 13. Pontryagin’s Maximum Principle Optimality Conditions Lλk+1 = 0 xk+1 = fd (xk , uk) Lλ0 = 0 x0 = x◦ Lxk = 0 λk = Hx (xk , uk, αk, λk+1, νk ) LxN = 0 λN = ∂ ∂xN φd (xN) Luk = 0 Hu(xk , uk, αk, λk+1, νk ) = 0 Lαk = 0 Hα(xk , uk, αk, λk+1, νk ) = 0 Lνk = 0 G(xk , uk, αk) = 0 for k = 0, . . . , N − 1 where denote the optimal solution
  • 14. Model Predictive Control This is optimal control but what is MPC? MPC is the optimal controller in the loop: 1. Measure/estimate the current state xn. 2. Solve the optimal control problem to compute uk for k = n, . . . , n + N − 1. 3. Return un as the value of the control input. 4. Update n. 5. Goto step 1. MPC is implemented in real time.
  • 15. Continuation/GMRES Method Step 1: Compute xk and λk as functions of uk, αk and νk, given the following equations: xk+1 = fd (xk, uk) x0 = xn λk = Hx (xk, uk, αk, λk+1, νk) λN = ∂ ∂xN φd (xN) (Ohtsuka 2004)
  • 16. Continuation/GMRES Method Step 2: For U = [uT 0 , . . . , uT N−1, αT 0 , . . . , αT N−1, νT 0 , . . . , νT N−1]T solve the equation F(xn, U) = 0, where: F(xn, U) =             Hu(x0, u0, α0, λ1, ν0) Hα(x0, u0, α0, λ1, ν0) G(x0, u0, α0) ... Hu(xN−1, uN−1, αN−1, λN, νN−1) Hα(xN−1, uN−1, αN−1, λN, νN−1) G(xN−1, uN−1, αN−1)             (Ohtsuka 2004)
  • 17. Continuation/GMRES Method Continuation method: Instead of solving F(x, U) = 0, find U such that: ˙F(x, U) = AsF(x, U) where As is a matrix with negative eigenvalues. Now, we have: Fx ˙x + FU ˙U = AsF(x, U) GMRES: To compute ˙U using the following equation, which is linear in ˙U, we use the generalized minimum residual (GMRES) algorithm. FU ˙U = AsF(x, U) − Fx f (x, u) To compute U at any given time, we need to have an initial value for U and then use the above ˙U to update it. (Ohtsuka 2004)
  • 18. Example Controling the position and orientation of a hovercraft: (Seguchi and Ohtsuka 2003)
  • 19. Example Dynamic equations: M¨x =u1 cos(θ) + u2 cos(θ) M¨y =u1 sin(θ) + u2 sin(θ) I ¨θ =u1r − u2r Variables: Variable Type Unit x position m y position m θ orientation rad u1 force N u2 force N (Seguchi and Ohtsuka 2003)
  • 20. Example Nonlinear Model Predictive Control (NMPC) Automatic code generation
  • 21. References Boyd, S.P., and L. Vandenberghe. 2004. Convex Optimization. Cambridge Univ Pr. Diehl, Moritz, Hans Joachim Ferreau, and Niels Haverbeke. 2009. “Efficient Numerical Methods for Nonlinear MPC and Moving Horizon Estimation.” In Nonlinear Model Predictive Control, 391–417. Springer. Ohtsuka, Toshiyuki. 2004. “A Continuation/GMRES Method for Fast Computation of Nonlinear Receding Horizon Control.” Automatica 40 (4). Elsevier: 563–74. Seguchi, Hiroaki, and Toshiyuki Ohtsuka. 2003. “Nonlinear Receding Horizon Control of an Underactuated Hovercraft.” International Journal of Robust and Nonlinear Control 13 (3-4). Wiley Online Library: 381–98.