Optimal Control PDF
Optimal Control PDF
d Rx
f (t)dt = f (x)
dx a
d Rb R b ∂f
f (x, t)dt = a dt
dx a ∂x
φR (x) φ (x)
d 2 R2 ∂f dφ2 dφ1
f (x, t)dt = dt + f (x, φ2 (x)) − f (x, φ1 (x))
dx φ1 (x) φ1 (x) ∂x dx dx
Definition
A function f (t) is said to have a relative optimum at point t ∗ if ∃ > 0 such that
|t − t ∗ | < =⇒ 4f has same sign (positive or negative).
4f = f (t) − f (t ∗ ) ≥ 0 ⇒ f (t ∗ ) is a local minimum.
4f = f (t) − f (t ∗ ) ≤ 0 ⇒ f (t ∗ ) is a local maximum.
Definition
A functional J(x(t)) is said to have a relative optimum at point x ∗ (t) if ∃ > 0 such that
|x(t) − x ∗ (t)| < =⇒ 4J has same sign (positive or negative).
4J = J(x) − J(x ∗ ) ≥ 0 ⇒ J(x ∗ ) is a local minimum.
4J = J(x) − J(x ∗ ) ≤ 0 ⇒ J(x ∗ ) is a local maximum.
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂V d ∂V
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
∂V
δx(tf ) = 0 (Transversality Condition)
∂ ẋ ∗ t
f
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂V d ∂V
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
∂V ∂V
δxf + V − ẋ δtf = 0 (Transversality Condition)
∂ ẋ ∗ t ∂ ẋ ∗ t
f f
Z tf +δtf Z tf
J(x ∗ (t) + δx(t)) − J(x ∗ (t)) = V (x ∗ + δx, ẋ ∗ + δ ẋ, t)dt − V (x ∗ , ẋ ∗ , t)dt
t0 t0
Z tf Z tf
= V (x ∗ + δx, ẋ ∗ + δ ẋ, t)dt − V (x ∗ , ẋ ∗ , t)dt
t0 t0
Z tf +δtf
+ V (x ∗ + δx, ẋ ∗ + δ ẋ, t)dt
tf
This gives
Z tf
∗ ∂V ∂V
δJ(x (t), δx(t)) = δx + δ ẋ dt + red term
t0 ∂x ∗ ∂ ẋ ∗
Z tf
∂V d ∂V ∂V
= δx − δx dt + δx
t0 ∂x ∗ dt ∂ ẋ ∗ ∂ ẋ ∗ t f
+ red term
Z tf +δtf
V (x ∗ + δx, ẋ ∗ + δ ẋ, t)dt
tf
δxf − δx(tf )
ẋ(tf ) + δ ẋ(tf ) ≈
δtf
⇒ δxf = δx(tf ) + {ẋ(tf ) + δ ẋ(tf )}δtf
⇒ δx(tf ) = δxf − ẋ(tf )δtf
Problem - IV
Optimize
Z tf
J(x(t)) = V (x(t), ẋ(t), t)dt,
t0
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂V d ∂V
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
∂V
V + (θ̇ − ẋ) δtf = 0 (Transversality Condition)
∂ ẋ ∗ t
f
Note that
dθ
δxf = δtf
dt tf
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂V d ∂V
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
∂V ∂V
δxf + V − ẋ δtf = 0 (Transversality Condition)
∂ ẋ ∗ t ∂ ẋ ∗ t
f f
No∂Vcondition,
fixed-fixed;
= 0, fixed-(tf fixed, xf free);
∂ ẋ ∗ t∂V
f
Special cases:
V − ẋ ∂ ẋ
,
∗ tf i
fixed-(tf free, xf fixed);
h
∂V
V + (θ̇ − ẋ) ∂ ẋ =0 fixed-(tf and x(tf ) lie on θ(t)).
∗ tf
R1
Optimize: J = 0
(ẋ 2 (t) + x(t))dt with x(0) = 2, x(1) = 3
Solution:
E-L Equation
∂V d ∂V
− =0
∂x dt ∂ ẋ Boundary conditions
d
⇒1 − [2ẋ(t)] = 0 x(0) = c2 = 2
dt
x(1) = 41 + c1 + c2 = 3
⇒2ẍ(t) = 1
⇒ c1 = 1 − 14 = 34
1
⇒ẋ(t) = t + c1
2
1
⇒x(t) = t 2 + c1 t + c2
4
Hence, x ∗ (t) = 41 t 2 + 34 t + 2.
R1
Optimize J = 0
(ẋ 2 (t) + x(t))dt with x(0) = 2, x(1) is free
Solution:
∂V d ∂V
− =0 x(0) = c2 = 2
∂x dt ∂ ẋ
d ∂V ∂V
⇒1 − [2ẋ(t)] = 0 |t=1 δx(1) = 0 ⇒ |t=1 = 0
dt ∂ ẋ ∂ ẋ
⇒2ẍ(t) = 1 ⇒2ẋ(t)|t=1 = 0
1 1
⇒ẋ(t) = t + c1 ⇒ t + c1 |t=1 = 0
2 2
1 1
⇒x(t) = t 2 + c1 t + c2 ⇒c1 = −
4 2
Hence, x ∗ (t) = 41 t 2 − 12 t + 2.
∂V d ∂V
− ( )=0 x(0) = c2 = 0
∂x dt ∂ ẋ
d ẋ ∂V
⇒ − (√ )=0 [V + (θ̇ − ẋ) ]t=tf = 0
dt 1 + ẋ 2 ∂ ẋ
√ 2ẋ 2 ẍ
p ẋ
[ẍ 1 + ẋ 2 − √ ] ⇒[ 1 + ẋ 2 + (−5 − c1 ) √ ]t=tf = 0
2 1+ẋ 2 1 + ẋ 2
⇒− =0
(1 + ẋ 2 ) ⇒ [1 + ẋ 2 − 5ẋ − c1 ẋ]t=tf = 0
⇒ẍ(1 + ẋ 2 ) − ẋ 2 ẍ = 0 ⇒ [1 + c1 2 − 5c1 − c1 2 ]t=tf = 0
⇒ẍ = 0 1
⇒ c1 =
⇒x = c1 t + c2 5
Hence, x ∗ (t) = 51 t.
To find tf :
1 26 75
tf = −5tf + 15 ⇒ tf = 15 ⇒ tf =
5 5 26
N. K. Tomar (IIT Patna) Basics of Optimal Control Theory 20 / 91
Variational Problems: Sufficient Conditions
R tf R tf
J(x ∗ (t) + δx(t)) − J(x ∗ (t)) = t0
V (x ∗ + δx, ẋ ∗ + δ ẋ, t)dt − t0
V (x ∗ , ẋ ∗ , t)dt
This gives
tf
∂2V ∂2V
Z 2
1 ∂ V
δ2 J = (δx)2 + 2 δxδ ẋ + (δ ẋ)2
dt
2 t0 ∂x 2 ∗ ∂x∂ ẋ ∗ ∂ ẋ 2 ∗
2
∂2V
Z tf
∂ V
1 2 δx
δ ẋ ∂x ∂x∂ ẋ
= δx dt
2 ∂2V ∂2V δ ẋ
t0
∂x∂ ẋ ∂ ẋ 2 ∗
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂V d ∂V
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
" T #
∂V ∂V
δxf + V − ẋ T δtf = 0 (Transversality Condition)
∂ ẋ ∗ ∂ ẋ ∗ t
tf f
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂L d ∂L
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
∂L d ∂L
− = 0 (E-L Equation) ⇒ g = 0
∂λ ∗ dt ∂ λ̇ ∗
R tf
Optimize: J(x(t)) = t0
V (x1 (t), x2 (t), ẋ1 (t), ẋ1 (t), t)dt, x(t) ∈ R2
subject to
g (x1 (t), x2 (t), ẋ1 (t), ẋ1 (t)) = 0
where x(t0 ) = x0 (fixed); tf and x(tf ) are also fixed.
Method of Lagrange multipliers:
L = L(x1 (t), x2 (t), ẋ1 (t), ẋ1 (t), λ, t) = V + λg
and optimize a new
Z tf
J(x(t)) = L(x1 (t), x2 (t), ẋ1 (t), ẋ1 (t), λ, t)dt
t0
Z tf
∂L ∂L ∂L ∂L
δJ = δx1 + δ ẋ1 + δx2 + δ ẋ2 dt
t0 ∂x1
∗ ∂ ẋ1
∗ ∂x2 ∗ ∂ ẋ2 ∗
Z tf tf
∂L d ∂L ∂L
= − δx1 dt + δx1
t0 ∂x1 ∗ dt ∂ ẋ1 ∗ ∂ ẋ1 ∗ t0
Z tf tf
∂L d ∂L ∂L
+ − δx2 dt + δx2
t0 ∂x2 ∗ dt ∂ ẋ2 ∗ ∂ ẋ2 ∗ t 0
Now make sure that δJ = 0 for arbitrary δx1 (t). Remember! δx1 (t) and δx2 (t) - both are
not independent.
3. State tracking about fixed state trajectory C with minimum control efforts problem
1 t
Z
J= [(x − C )T Q(x − C ) + u T Ru]dt (Q ≥ 0, R > 0)
2 t0
4. State tracking about zero state trajectory with minimum control efforts problem
1 t T
Z
J= [x Qx + u T Ru]dt (Q ≥ 0, R > 0)
2 t0
5. Minimum control efforts problem for finding final state xf such that xf reaches close
to a constant C
1 t T
Z
J = (xf − C )T Sf (xf − C ) + [u Ru]dt (Sf ≥ 0, R > 0)
2 t0
Optimize
Rt d
J(u(t)) = t0
[V (x, u, t) + dt
S(x, t)]dt
such that
ẋ = f (x, u, t); x(0) = x0 (fixed), tf and xf are free.
Rt
Optimize: J(u(t)) = 0
V + dS
dt
+ λT [f − ẋ]dt with x(0) = x0 and tf , xf are free.
Rt
Optimize: J(u(t)) = 0
V + dS
dt
+ λT [f − ẋ]dt with x(0) = x0 and tf , xf are free.
Take
Rt
Optimize: J = 0
L(x, ẋ, u, λ, t)dt with x(0) = x0 and tf , xf are free.
Necessary Condition
Suppose x ∗ (t) solves the problem. Then
∂V d ∂V
− = 0 (E-L Equation)
∂x ∗ dt ∂ ẋ ∗
" T #
∂V ∂V
δxf + V − ẋ T δtf = 0 (Transversality Condition)
∂ ẋ ∗ ∂ ẋ ∗ t
tf f
Rt
Optimize: J = 0
L(x, ẋ, u, λ, t)dt with x(0) = x0 and tf , xf are free.
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt L = H + dS
dt
− λT (t)ẋ
with x(0) = x0 and tf , xf are free. H = V (x, u, t) + λT (t)f (x, u, t)
" T # " T #
∂L ∂L T ∂S ∂S
δxf + L − ẋ δtf = 0 ⇒ −λ δxf + H + δtf = 0
∂ ẋ ∂ ẋ tf ∂x ∂t tf
tf tf
L = H + dS
dt
− λT (t)ẋ
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt H = V (x, u, t) + λT (t)f (x, u, t)
with x(0) = x0 and tf , xf are free. dS ∂S ∂S T
= +( ) ẋ
dt ∂t ∂x
∂L ∂ dS
= H+ − λT ẋ
∂x ∂x dt
∂H ∂2S ∂2S
+ = + ẋ
∂x " ∂x∂t
( ∂x 2
T ) #
d ∂L d ∂ ∂S ∂S
= + ẋ − λ
dt ∂ ẋ dt ∂ ẋ ∂t ∂x
" T #
d ∂S ∂S ∂S
= −λ ∵ ≡ (x, t)
dt ∂x ∂x ∂x
∂2S ∂2S
= + ẋ − λ̇
∂t∂x ∂x 2
h i h T i
∂L T
δxf + L − ẋ T ∂∂Lẋ t δtf = 0 ⇒ ∂S ∂S
Proof: ∂ ẋ ∂x
−λ δxf + H + ∂t tf
δtf = 0
tf f tf
L = H + dS
dt
− λT (t)ẋ
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt H = V (x, u, t) + λT (t)f (x, u, t)
with x(0) = x0 and tf , xf are free. dS ∂S ∂S T
= +( ) ẋ
dt ∂t ∂x
" T #
∂L ∂S
δxf + L − ẋ T −λ δtf
∂ ẋ ∂x tf
tf
" T # " T #
∂S ∂S ∂S ∂S
= −λ δxf + H + + ẋ − λT ẋ − ẋ T + ẋ T λ δtf
∂x ∂t ∂x ∂x
tf tf
" T #
∂S ∂S
= −λ δxf + H + δtf
∂x ∂t tf
tf
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt L = H + dS
dt
− λT (t)ẋ
with x(0) = x0 and tf , xf are free. H = V (x, u, t) + λT (t)f (x, u, t)
∂H
λ̇ = − (Costate (adjoint) Equation)
∂x
∂H
= 0 (Optimal control Equation)
∂u
ẋ = f (State Equation)
Boundary Conditions
" T #
∂S ∂S
−λ δxf + H + δtf = 0 (Transversality Condition)
∂x ∂t tf
tf
Special cases of
Boundary Conditions
" T #
∂S ∂S
−λ δxf + H + δtf = 0 (Transversality Condition)
∂x ∂t tf
tf
5 2 1 tf 2
Z
1
J = kxf − k + u (t)dt
2 2 2 t0
subject to
ẋ1 x2 0
= ; x(0) = and tf = 2
ẋ2 −x2 + u 0
Solution:
1 2 x2 1
= u 2 + λ1 x2 + λ2 (−x2 + u)
H= u + λ1 λ2
2 −x2 + u 2
Costate equation:
∂H λ̇1 0 0 0 0 λ1
λ̇ = − ⇒ =− = =
∂x λ̇2 λ1 − λ2 −λ1 + λ2 −1 1 λ2
∂H
= 0 ⇒ u + λ2 = 0 ⇒ u(t) = −λ2 (t)
∂u
State equation:
ẋ1 x2 x2
= =
ẋ2 −x2 + u −x2 − λ2
Boundary Conditions:
" T #
∂S λ1 (2) x1 (2) − 5 x1 (0) 0
−λ =0 ⇒ = and =
∂x λ2 (2) x2 (2) − 2 x2 (0) 0
tf
clear;
A = [0 1 0 0;0 -1 0 -1;0 0 0 0;0 0 -1 1];
syms t;
eAt = expm(A*t);
z0 = [0; 0;-2.70;-2.42];
z = eAt*z0;
H = 0.5*z(4)*z(4) + [z(3)
z(4)]*[z(2);-z(2)-z(4)];
ezplot(H,[0,2]);
Theorem
If H is not an explicit function of time t, then H is constant along the optimal path.
Proof:
∂H
λ̇ = − (Costate (adjoint) Equation)
∂x
L = H + dS
dt
− λT (t)ẋ
H = V (x, u, t) + λT (t)f (x, u, t)
∂H
= 0 (Optimal control Equation)
∂u
∂H
ẋ = f = (State Equation)
∂λ
dH ∂H ∂H ∂H ∂H
= + ẋ T + u̇ T + λ̇T
dt ∂t ∂x
∂u
∂λ
∂H T ∂H T ∂H ∂H
= + ẋ + λ̇ + u̇ =
∂t ∂x ∂u ∂t
Rt
Optimize: J(u(t)) = 21 (xf −Cf )T Sf (xf −Cf )+ 12 0 f [(x −C )T Q(x −C )+u T Ru]dt
subject to ẋ = Ax + Bu with x(0) = x0 (fixed),
tf is fixed and finite, and x(tf ) is free.
Sf , Q ≥ 0 and R > 0
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt L = H + dS
dt
− λT (t)ẋ
with x(0) = x0 and tf , xf are free. H = V (x, u, t) + λT (t)f (x, u, t)
∂H
λ̇ = − (Costate (adjoint) Equation)
∂x
∂H
= 0 (Optimal control Equation)
∂u
ẋ = f (State Equation)
Boundary Conditions
" T #
∂S ∂S
−λ δxf + H + δtf = 0 (Transversality Condition)
∂x ∂t tf
tf
Special cases of
Boundary Conditions
" T #
∂S ∂S
−λ δxf + H + δtf = 0 (Transversality Condition)
∂x ∂t tf
tf
Rt
Optimize: J(u(t)) = 12 xfT Sf xf + 12 0 f [x T Qx + u T Ru]dt
subject to ẋ = Ax + Bu with x(0) = x0 (fixed),
tf is fixed and finite, and x(tf ) is free.
Sf , Q ≥ 0 and R > 0
Take
1 T
H ≡ H(x(t), u(t), λ(t), t) = [x Qx + u T Ru] + λT [Ax + Bu] (Hamiltonian)
2
Costate equation:
∂H
λ̇ = − ⇒ λ̇ = −[Qx + AT λ]
∂x
∂H
= 0 ⇒ Ru + B T λ = 0 ⇒ u = −R −1 B T λ
∂u
State equation:
∂H
ẋ = ⇒ ẋ = Ax + Bu
∂λ
Boundary Conditions:
∂S
x(0) = x0 and λ(tf ) = = Sf x(tf )
∂x tf
which implies
Rt
Optimize: J(u(t)) = 12 xfT Sf xf + 12 0 f [x T Qx + u T Ru]dt
subject to ẋ = Ax + Bu with x(0) = x0 (fixed),
tf is fixed and finite, and x(tf ) is free.
Sf , Q ≥ 0 and R > 0
1
Here, H ≡ H(x(t), u(t), λ(t), t) = [x T Qx +u T Ru]+λT [Ax +Bu] (Hamiltonian)
2
Algorithm to solve the above problem:
e −M(t−tf )
w (t) 0 w (tf )
=
z(t) 0 e M(t−tf ) z(tf )
e M(t−tf )
w (tf ) 0 w (t)
⇒ = (3)
z(t) 0 e M(t−tf ) z(tf )
which implies
where
T2 = e −M(tf −t) T1 e −M(tf −t)
and
T1 = − [W22 − Sf W12 ]−1 [W21 − Sf W11 ]
1 2
x1 (5) + x1 (5)x2 (5) + 2x22 (5)
J=
2
1 R5
+ 0 2x12 (t) + 6x1 (t)x2 (t) + 5x22 (t) + 0.25u 2 (t) dt
2
subject to ẋ1 (t) = x2 (t)
ẋ2 (t) = −2x1 (t) + x2 (t) + u(t)
x1 (0) = 2 and x2 (0) = −3
0 1 0 1 0.5 2 3
Here, we have A = ,B= , Sf = ,Q=
−2 1 1 0.5 2 3 5
2 1
x0 = , R = , t0 = 0, and tf = 5.
−3 4
with
p11 (5) p12 (5) 1 0.5
=
p12 (5) p22 (5) 0.5 2
2
ṗ11 (t) = 4p12 (t) + 4p12 (t) − 2; p11 (5) = 1
ṗ12 (t) = −p11 (t) − p12 (t) + 2p22 (t) + 4p12 (t)p22 (t) − 3; p12 (5) = 0.5
2
ṗ22 (t) = −2p12 (t) − 2p22 (t) + 4p22 (t) − 5; p22 (5) = 2
clear;
SC = [0 1 0 0;-2 1 0 -4;-2 -3 0 2;-3 -5 -1 -1];
Sf = [1 0.5;0.5 2]; [W1 D] = eig(SC);
W = W1*[1 0 0 0;0 1 0 0;0 0 0 1;0 0 1 0];
W11 = W(1:2,1:2);
W12 = W(1:2,3:4);
W21 = W(3:4,1:2);
W22 = W(3:4,3:4);
M1 = D(1:2,1:2);
tspan = 0:0.1:5;
n = length(tspan);
p11 = zeros(n);
p12 = zeros(n);
p22 = zeros(n); j = 1; for t = 0:0.1:5
eM1 = expm(M1*(5-t));
T1 = -inv(W22-Sf*W12)*(W21-Sf*W11);
T2 = eM1*T1*eM1;
P = (W21+W22*T2)*inv(W11+W12*T2);
p11(j) = P(1,1);
p12(j) = P(1,2);
p22(j) = P(2,2);
j=j+1;
end
figure
plot(tspan,p11,’g’,tspan,p12,’b’,tspan,p22,’r’)
title(’Solution of DRE’)
xlabel(’t-value’)
ylabel(’P-value’)
function dx = state(t,x)
SC = [0 1 0 0;-2 1 0 -4;-2 -3 0 2;-3 -5 -1 -1];
A= SC(1:2,1:2);
B=[0;1];
Rinv = 4;
Sf = [1 0.5;0.5 2];
W = W1*[1 0 0 0;0 1 0 0;0 0 0 1;0 0 1 0];
W11 = W(1:2,1:2);
W12 = W(1:2,3:4);
W21 = W(3:4,1:2);
W22 = W(3:4,3:4);
M1 = D(1:2,1:2);
eM1 = expm(M1*(5-t));
T1 = -inv(W22-Sf*W12)*(W21-Sf*W11);
T2 = eM1*T1*eM1;
P = (W21+W22*T2)*inv(W11+W12*T2);
dx = [A-B*Rinv*B’*P]*x;
end
R∞
Optimize: J(u(t)) = 12 0 [x T Qx + u T Ru]dt
subject to ẋ = Ax + Bu with x(0) = x0 (fixed),
tf is fixed and finite, and x(tf ) is free.
Sf , Q ≥ 0 and R > 0
1
Here, H ≡ H(x(t), u(t), λ(t), t) = [x T Qx +u T Ru]+λT [Ax +Bu] (Hamiltonian)
2
Assumption: System is controllable.
Recall: Algorithm to solve the LQR Problem-I:
R∞
Optimize: J(u(t)) = 12 0 [x T Qx + u T Ru]dt
subject to ẋ = Ax + Bu with x(0) = x0 (fixed),
tf is fixed and finite, and x(tf ) is free.
Sf , Q ≥ 0 and R > 0
1
Here, H ≡ H(x(t), u(t), λ(t), t) = [x T Qx +u T Ru]+λT [Ax +Bu] (Hamiltonian)
2
Assumption: System is controllable.
1 R∞ 2
2x1 (t) + 6x1 (t)x2 (t) + 5x22 (t) + 0.25u 2 (t) dt
J=
2 0
subject to ẋ1 (t) = x2 (t)
ẋ2 (t) = −2x1 (t) + x2 (t) + u(t)
x1 (0) = 2 and x2 (0) = −3
0 1 0 2 3
Here, we have A = ,B= ,Q=
−2 1 1 3 5
2 1
x0 = , R = , and t0 = 0.
−3 4
PA + AT P − PBR −1 B T P + Q = 0 .
0 0 p11 p12 0 1
= −
0 0 p12 p22 −2 1
0 −2 p11 p12
−
1 1 p12 p22
p11 p12 0 p11 p12 2 3
+ 4 0 1 −
p12 p22 1 p12 p22 3 5
with
p11 (5) p12 (5) 1 0.5
=
p12 (5) p22 (5) 0.5 2
2
0 = 4p12 (t) + 4p12 (t) − 2;
0 = −p11 (t) − p12 (t) + 2p22 (t) + 4p12 (t)p22 (t) − 3;
2
0 = −2p12 (t) − 2p22 (t) + 4p22 (t) − 5;
clear;
A= [0 1;-2 1];
1.73663 0.3660 B=[0;1]; Q = [2 3;3 5];
P= R = [0.25];
0.3660 1.4729 E = B*inv(R)*B’;
P = are(A,E,Q);
Moreover
ku(t)k ≤ U, or − Ui ≤ ui (t) ≤ Ui .
∂H
λ̇ = − (Costate (adjoint) Equation)
∂x
hhh ((((
∂H hhhhh (((Equation)
=0 ((Optimal
( ( (control
h hhh H(x, u ∗ , λ) = min H(x, u, λ)
∂u
(( ( ( ( hh hh ku(t)k≤U
∂H
ẋ = = f (State Equation)
∂λ
Boundary Conditions
" T #
∂S ∂S
−λ δxf + H + δtf = 0 (Transversality Condition)
∂x ∂t tf
tf
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt
with x(0) = x0 and tf , xf are free. L = H + dS
dt
− λT (t)ẋ
Moreover H = V (x, u, t) + λT (t)f (x, u, t)
ku(t)k ≤ U, or − Ui ≤ ui (t) ≤ Ui .
( T T T )
Z tf
∂H ∂H ∂H
δJ = + λ̇(t) δx(t) + δu(t) + − ẋ(t) δλ(t) dt
t0 ∂x ∂u ∗ ∂λ
" T #
∂S ∂S
+ −λ δxf + H + δtf
∂x ∂t tf
tf
Rt
Optimize: J = 0 L(x, ẋ, u, λ, t)dt
with x(0) = x0 and tf , xf are free. L = H + dS
dt
− λT (t)ẋ
Moreover H = V (x, u, t) + λT (t)f (x, u, t)
ku(t)k ≤ U, or − Ui ≤ ui (t) ≤ Ui .
( T )
Z tf
∗ ∂H
δJ(u (t), δu(t)) = δu(t) dt
t0 ∂u ∗
Now
Now make sure that ∆J(u ∗ , δu(t)) ≥ 0 for arbitrary ’admissible’ δu(t). This gives that
Hence
H(x, u ∗ , λ, t) = min H(x, u, λ, t)
ku(t)k≤U
∂H
λ̇ = − (Costate (adjoint) Equation)
∂x
ẋ = f (State Equation)
Boundary Conditions
" T #
∂S ∂S
−λ δxf + H + δtf = 0 (Transversality Condition)
∂x ∂t tf
tf
The PMP
H(x, u ∗ , λ, t) = min H(x, u, λ, t)
ku(t)k≤U
Optimize H = u 2 − 6u + 7, |u| ≤ 2
If there is no constraint then optimizer follows
∂H
= 0 ⇒ 2u − 6 = 0 ⇒ u ∗ = 3
∂u
But this value of u is certainly outside the constraints.
Think!
H(u ∗ ) = min H(u)
|u|≤2
u∗ = 2
ẋ = Ax + Bu
to go from an arbitrary initial condition x(t0 ) = x0 to the desired final state xf . Here
control is constrained by
ku(t)k ≤ U.
Without loss of generality we take
xf = 0 (Time optimal regulator problem)
ku(t)k ≤ 1, i.e. −1 ≤ ui ≤ 1.
Assumption: System is controllable.
Rt
Optimize J = t0f dt
subject to ẋ = Ax + Bu
x(t0 ) = x0 ; x(tf ) = 0; t0 fixed and tf is free
Here,
H = 1 + λT [Ax + Bu]
Rt
Optimize J = t0f dt
subject to ẋ = Ax + Bu
x(t0 ) = x0 ; x(tf ) = 0; t0 fixed and tf is free
∂H
ẋ = ⇒ ẋ = Ax + Bu ∗
∂λ
Costate Equation:
∂H
λ̇ = − ⇒ λ̇ = −AT λ
∂x
Boundary Conditions: x(t0 ) = x0 ; x(tf ) = 0 and tf is free gives
" T #
∂S ∂S
−λ δxf + H + δtf = 0 ⇒ H(x, u ∗ , λ) = 0
∂x ∂t tf
tf
Rt
Optimize J = t0f dt
subject to ẋ = Ax + Bu
x(t0 ) = x0 ; x(tf ) = 0; t0 fixed and tf is free
⇒ (u ∗ )T B T λ = min u T B T λ
ku(t)k≤1
∗ T
⇒ (u ) q = min u T q, where, q = B T λ
ku(t)k≤1
which implies
−1, if q > 0;
u∗ =
1, if q < 0.
N. K. Tomar (IIT Patna) Basics of Optimal Control Theory 80 / 91
Time optimal control problem (TOCP)
Rt
Optimize J = t0f dt
subject to ẋ = Ax + Bu
x(t0 ) = x0 ; x(tf ) = 0; t0 fixed and tf is free
1 The necessary and sufficient condition for the TOCP to be normal is that the system
is completely controllable.
2 The necessary and sufficient condition for the TOCP to be singular is that the
system is not completely controllable.
3 For the normal-TOCP the developed control is the unique minimizer.
4 For the normal-TOCP, if A has all n eigenvalues real, then u ∗ can switch between
−1 and +1 at most (n-1) times
Rt
Minimize J = t0f dt
subject to ẋ = Ax + Bu
x(t0 ) = x0 ; x(tf ) = 0; t0 fixed and tf is free
T
1 Solve costate equation: λ̇ = −AT λ ⇒ λ(t) = e −A t λ(0).
2 Remember! λ(0) is not known, so Assume λ(0).
3 Evaluate: uj∗ = −sgn{qj } = −sgn{bjT λ}.
4 Solve: state dynamics: ẋ = Ax + Bu ∗ with given x0 .
5 Monitor the solution x(t) for a tf such that x(tf ) = 0; otherwise change your guess
for λ(0).
The algorithm is tedious! assume a closed loop controller:
1 R tf
Minimize J = dt
2 t0
subject to ẋ1 (t) = x2 (t)
ẋ2 (t) = u(t)
0
x(t0 ) = x0
0
|u| ≤ 1.
Here: H = 1 + λ1 x2 + λ2 u
State Equation:
∂H ẋ1 0 1 x1 0 ∗
ẋ = ⇒ = + u
∂λ ẋ2 0 0 x2 1
Costate Equation:
∂H λ̇1 0 0 λ1
λ̇ = − ⇒ =−
∂x λ̇2 1 0 λ2
Boundary Conditions: x(t0 ) = x0 ; x(tf ) = 0
⇒ 1 + λ1 x2 + λ2 u ∗ = min (1 + λ1 x2 + λ2 u)
ku(t)k≤1
⇒ λ2 u ∗ = min λ2 u
ku(t)k≤1
⇒ u ∗ = −sgn{λ2 }
∂H ẋ1 0 1 x1 0 ∗ 0 1 x1 0
ẋ = ⇒ = + u = + U; (U = ±1)
∂λ ẋ2 0 0 x2 1 0 0 x2 1
which implies
x2 (t) = x20 + Ut
1 2
x1 (t) = x10 + x20 t + Ut
2
Eliminate t from above solution
(x2 (t) − x20 )
t=
U
1 2 1 1
x1 (t) = x10 − Ux20 + Ux22 (t); (U = ±1 = )
2 2 U
If U = +1 If U = −1
Switch Curve:
1 2
γ− = (x10 , x20 ) : x10 = − x20 , x20 ≥ 0
2
1 2
γ+ = (x10 , x20 ) : x10 = x20 , x20 ≤ 0
2
1
γ = γ− ∪γ+ = (x10 , x20 ) : x10 = − x20 |x20 |
2
Thank you.