Eective Classroom Teaching of Optimal Control and Optimization using MATLAB Saket Adhau, Sayli Patil, Dayaram Sonawane College of Engineering, Pune, India MATLAB EXPO 2019 March 23, 2019 Saket Adhau (COEP) March 23, 2019 1 / 25
E�ective Classroom Teaching of Optimal Control andOptimization using MATLAB
Saket Adhau, Sayli Patil, Dayaram Sonawane
College of Engineering, Pune, India
MATLAB EXPO 2019
March 23, 2019
Saket Adhau (COEP) March 23, 2019 1 / 25
Optimal Control
• Finding values of the variables that optimize (minimize or maximize)the objective function while satisfying the constraints
Saket Adhau (COEP) Optimal Control March 23, 2019 2 / 25
Ingredients of Optimal Control Problem
Saket Adhau (COEP) Optimal Control March 23, 2019 3 / 25
Methods to Solve OCP
AnalyticalMethods –Pontryagins
maximum principle
Numerical Methods
Saket Adhau (COEP) Optimal Control March 23, 2019 4 / 25
Numerical Methods to Solve OCP
Optimal Con-trol Problem
Indirect MethodsPontryagin:Solves BVP
Direct MethodsTransformsinto NLP
Hamilton-JacobiBellman Equation:
Multiple Shooting:Controls and
node Start valuesin NLP (Simul-taneous/hybrid)
Collocation:Discretized
Controls andstate in NLP
(Simultaneous)
Single Shooting:Only discretizedControls in NLP
(Sequential)
Saket Adhau (COEP) Optimal Control March 23, 2019 5 / 25
Optimal Control Problem Flow Chart
DAEs/ODEsz′(t) = f(t, z, y, u)0 = g(t, z, y, u)
Algebraic EquationsFk(zk+1, zk, yk, uk)
Gk(zk, yk, uk)
Large Non-Linear Programs
Path Constraints andObjective Function
umin ≤ u(k) ≤ umax ,ymin ≤ y(k) ≤ ymax,zmin ≤ z(k) ≤ zmax
Non-LinearProgram
(NLP) SolverOptimal Solution
Temporal Discretization
Saket Adhau (COEP) Optimal Control March 23, 2019 6 / 25
Example Problem: Time Optimal Rocket Problem (TimeOptimization Problem)
minU
tf
Subject to
˙s(t) = v(t) ; ˙v(t) =(u(t)− 0.02 ∗ v(t)2)
m(t)
˙m(t) = −0.01 ∗ u(t)2 ; t ∈[0 t
]s(0) = 0; v(0) = 0; m(0) = 1;
s(tf ) = 10; v(tf ) = 0
Bounds
− 0.1 ≤ v ≤ 1.7; −1.1 ≤ u ≤ 1.1; 5 ≤ T ≤ 15
Saket Adhau (COEP) Optimal Control March 23, 2019 7 / 25
Approach: MATLAB and Simulink Onramp
To provide a brief introduction to the MATLAB language and to give students hands-on MATLAB experience via the use of an integrated,
web-based version of MATLAB, as shown below.
Saket Adhau (COEP) Optimal Control March 23, 2019 8 / 25
Approach: MATLAB and Simulink Onramp Report
Saket Adhau (COEP) Optimal Control March 23, 2019 9 / 25
Classroom teaching approach: MATLAB Live Script:Interactive approach
Saket Adhau (COEP) Optimal Control March 23, 2019 10 / 25
Teaching Optimal Control using Live Script
Saket Adhau (COEP) Optimal Control March 23, 2019 11 / 25
Teaching Optimal Control using Live Script
Saket Adhau (COEP) Optimal Control March 23, 2019 12 / 25
Assessing the students using MATLAB Grader
Saket Adhau (COEP) Optimal Control March 23, 2019 13 / 25
Assessing the students using MATLAB Grader
Saket Adhau (COEP) Optimal Control March 23, 2019 14 / 25
Assessing the students using MATLAB Grader: Report
Saket Adhau (COEP) Optimal Control March 23, 2019 15 / 25
Case Study:
• We have a class of 20 students opting for Process Modeling andOptimization.• As an instructor, it is one challenging task to teach students MATLAB
based coding interactively and assessing them individually.• MATLAB has made this task easier than ever, by introducing MATLAB
Live script and MATLAB Grader.
Saket Adhau (COEP) Optimal Control March 23, 2019 16 / 25
Optimal Control Problem leads to Model PredictiveControl (MPC)
inputreference
measurement
rt ut yt
xt
processoptimization
output
min
st
Use a dynamical model of the process to predict its future evolution andchoose the “best” control action
Saket Adhau (COEP) Optimal Control March 23, 2019 17 / 25
Receding Horizon Implementation
PAST FUTURE
Measured output
Predicted output
Reference trajectory Implemented inputs
Predicted inputs
Current input
t1 t2 t3 dots tN 1
PredictionHorizon
t0
Sample
LEGEND
Saket Adhau (COEP) Optimal Control March 23, 2019 18 / 25
Teaching students MPC using Live Editor
Saket Adhau (COEP) Optimal Control March 23, 2019 19 / 25
Teaching students MPC using Live Editor
Saket Adhau (COEP) Optimal Control March 23, 2019 20 / 25
Teaching students MPC using Live Editor
Saket Adhau (COEP) Optimal Control March 23, 2019 21 / 25
Teaching students MPC using Live Editor
Saket Adhau (COEP) Optimal Control March 23, 2019 22 / 25
Live Demo using Simulink and Arduino
Saket Adhau (COEP) Optimal Control March 23, 2019 23 / 25
Live Demo using Simulink and Arduino
Saket Adhau (COEP) Optimal Control March 23, 2019 24 / 25
Live Demo using Simulink and Arduino
The END
Saket Adhau (COEP) Optimal Control March 23, 2019 25 / 25