Een 686: Optimal Control Sheet 03
Een 686: Optimal Control Sheet 03
dp
SHEET 03 p + 2p − 1
dp
1. Find the closed loop optimal control and optimal value of cost dt =
(p + 1) − 2
function for the system ẍ (t) + x(t) = u(t) with initial Let, u = p + 1 ⇒ du = dp
conditions x(0)=0, ẋ (0) =1. du
1 dt =
J(x) = 2x (t) + u (t) dt u −2
4 Let, u = √2v ⇒ du = √2dv
Answer : √2dv
The closed loop control input is given by, dt =
2v − 2
u(t) = −R B Px(t) 1 dv
dt =
√2 v − 1
The solution of P using MRE is given by, Integrating,
PA + A P + Q − PBR B P = 0 √2t + C = − tanh v
0 1 0 4 0 p+1
A= ,B = ,Q = , R = [0.5]
−1 0 1 0 0 √2t + C = − tanh
p p √2
Let P = p p p+1
tanh √2t + C = −
We have, √2
p p 0 1 0 −1 p p 4 0 p(t) = −√2 tanh √2t + C − 1
p p −1 0 + 1 0 p p + 0 0
p p 0 p p The boundary condition is given by,
− p p [0.5] [0 1] p p =0 P(t ) = F(t )
1
−2p − 2p + 4 = 0 We have, t = 1 and F(t ) = 0
p − p − 2p p = 0 Therefore,
2p − 2p = 0 p(1) = −√2 tanh √2 + C − 1 = 0
Solving the equations results in, 1
p = 1, p = 1, p = 3 tanh √2 + C = −
√2
p = 1, p = −1, p = −3 1
⇒ C = tanh − − √2 = −2.29
p = −2, p = √2i, p = −3√2i √2
p = −2, p = −√2i, p = 3√2i p(t) = −√2 tanh √2t − 2.29 − 1
Since P is to be positive definite,
3 1 The optimal control is given by,
P=
1 1
𝐮(𝐭) = √𝟐 𝐭𝐚𝐧𝐡 √𝟐𝐭 − 𝟐. 𝟐𝟗 + 𝟏 𝐱(𝐭)
The optimal closed loop control is given by,
3 1 x 3. For a first order system given by ẋ (t) = x(t) + u(t), Find the
u(t) = −R B PX = −[0.5] [0 1]
1 1 x optimal control u(t) to minimize the given performance index.
𝐮(𝐭) = −𝟐𝐱 𝟏 (𝐭) − 𝟐𝐱 𝟐 (𝐭)
J(x, u) = [2x (t) + 0.25 u (t)]dt
The optimal value of cost function is, (a) For tf is fixed and x(tf) is free
1 1 3 1 0
J(x ∗ ) = X PX = [0 1] (b) For tf → ∞
2 2 1 1 1 Answer :
𝐉(𝐱 ∗ ) = 𝟎. 𝟓
(a) Fixed tf:
The closed loop control input is given by,
2. Find the optimal feedback control law for the system ẋ (t) =
u(t) = −R B Px(t)
−x(t) + u(t) to minimize the given performance index.
The solution of P is given by,
1
J(x, u) = [x (t) + u (t)]dt PA + A P + Q − PBR B P = −Ṗ
2 A = [1], B = [1], Q = [4], R = [0.5]
Answer : Let P = [p]
The closed loop control input is given by, We have,
u(t) = −R B Px(t) [p][1] + [1][p] + [4] − [p][1][0.5] [1][p] = −ṗ
The solution of P is given by, 2p + 4 − 2p = −ṗ
PA + A P + Q − PBR B P = −Ṗ 2p − 2p − 4 = ṗ
A = [−1], B = [1], Q = [1], R = [1]
Let P = [p] dp
We have, 2p − 2p − 4 =
dt
[p][−1] + [−1][p] + [1] − [p][1][1] [1][p] = −ṗ 1
dt = dp
−2p + 1 − p = −ṗ 1 9
p + 2p − 1 = ṗ √2p − −
2
√2
Let, u = √2p − ⇒ du = √2dp
dp √
p + 2p − 1 =
dt
1 du PA + A P + Q − PBR B P = 0
dt =
9 √2 0 1 0 2q 0
u − A= ,B = ,Q = , R = [2r]
2 −c −b 1 0 0
1 p p
dt = √2du Let P = p p
2u − 9
Let, u = v ⇒ du = dv We have,
√ √ p p 0 1 0 −c p p 2q 0
1 p p −c + +
dt = 3dv −b 1 −b p p 0 0
9v − 9 p p 0 p p
1 1 − p p [2r] [0 1] p p =0
1
dt = dv p
3v −1
Integrating, −cp − cp + 2q − =0
2𝑟
3t + C = − tanh v p p
p − bp − 𝑐p − =0
2𝑟
√2 1 p
3t + C = − tanh √2p − p − bp + p − bp − =0
3 √2 2𝑟
1
tanh(3t + C) = − (2p − 1) p + 4rcp − 4rq = 0
3
1 −4rc ± 16𝑟 𝑐 + 16𝑟𝑞
p(t) = (1 − 3 tanh(3t + C)) p = = −2rc ± 2 𝑟 𝑐 + 𝑟𝑞
2 2
The boundary condition is given by, p + 4rbp − 4rp = 0
P(t ) = F(t ) −4rb ± 16𝑟 𝑏 + 16𝑟p
We have, F(t ) = 0 p = = −2rb ± 2 𝑟 𝑏 + 𝑟p
2
Therefore,
1 The closed loop control is given by,
p(t ) = (1 − 3 tanh(3t + C)) = 0
2 p p x(t)
1 u∗ (t) = −[2r] [0 1] p p
ẋ (t)
⇒ C = tanh − 3t = 0.35 − 3t
3 1 x
1 u = − [p p ]
∗
p(t) = (1 − 3 tanh(3t + 0.35 − 3t )) 2r ẋ
2 𝟏
𝐮∗ (𝐭) = − (𝐩𝟐 𝐱(𝐭) + 𝐩𝟑 𝐱̇ (𝐭))
𝟐𝐫
The optimal control is given by,
𝟏 5. Determine the optimal closed-loop control law for the multi-
𝐮(𝐭) = − 𝟏 − 𝟑 𝐭𝐚𝐧𝐡 𝟑𝐭 + 𝟎. 𝟑𝟓 − 𝟑𝐭 𝒇 𝐱(𝐭)
𝟐 input system
0 1 1 1
Ẋ(t) = X(t) + U(t)
1 1 0 1
(b) tf is infinity: for minimizing the cost function,
The solution of P is given by, [2x (t) + 4x (t) + 0.5u (t) + 0.25u (t)]dt
J(x)
4. Determine the closed-loop control law for the system in terms while er>1e-12
AA=A-B*inv(R)*B'*Pk;
of states and its derivatives for the system, ẍ (t) + bẋ (t) + LHS=AA'*P+P*AA;
cx(t) = u(t), to minimize the performance index, RHS=-Q-Pk*B*inv(R)*B'*Pk;
sys= LHS==RHS;
J(x) [qx (t) + ru (t)]dt k=1;
for i=1:N
Answer : for j=i:N
eqns(k)=sys(i,j);
The closed loop control input is given by, k=k+1;
u(t) = −R B Px(t) end
end
The solution of P is given by,
if N==1
sol=double(solve(eqns));
else
sol=double(sym(struct2cell(solve(eqns))));
end
Pk1=Pk;
k=1;
for i=1:N
for j=i:N
Pk(i,j)=sol(k);
k=k+1;
end
end
Pk=triu(Pk,0)+triu(Pk,1).';
er=max(max(abs(Pk-Pk1)));
itr=itr+1;
end
K=inv(R)*B'*Pk;
OUTPUT
Solution of P Matrix is
1.2887 -0.42666
-0.42666 2.966