Homework 3: Answer
Homework 3: Answer
Replacing coefficients:
√ √
51 5+ 2 1 5− 2 1
X(s) = − + √ + √
2s 4 s+ 2 4 s− 2
In order to satisfy the boundary conditions such that x(0) = 1 and x(1) = 3. We must
find the constant values.
√ ! √ !
5 5 + 2 √ 5 − 2 √
x∗ (0) = − + C1 e−(0) 2 + C2 e(0) 2
2 4 4
√ ! √ !
5 5+ 2 √ 5− 2 √
∗ −(1) 2
x (1) = − + C1 e + C2 e(1) 2
2 4 4
Simplifying:
√ √
14 = C1 5 + 2 + C2 5 − 2
√ √ √ √
22 = C1 5 + 2 e− 2 + C2 5 − 2 e 2
Constant values:
C1 = 1.4335
C2 = 1.34
2. One important calculus of variations problem that we did not discuss in class has the
same basic form, but with constraints that are given by an integral - called isoperimetric
constraints: Z tf
min J = g[x, ẋ, t] dt
t0
such that: Z tf
e[x, ẋ, t] dt = C
t0
2
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
(a) Use the same approach followed in the notes to find the necessary and bound-
ary conditions for this optimal control problem. In particular, augment the
constraint to the cost using a constant Lagrange multiplier vector ν, and show
that these conditions can be written in the form:
∂ga d ∂ga
− = 0
∂x dt ∂ ẋ
∂ga
ga (tf ) − ẋ(tf ) = 0
∂ ẋ
Z tf
e[x, ẋ, t] dt = C
t0
where ga = g + ν T e.
(b) Use the results of part (a) to clearly state the differential equations and corre-
sponding boundary conditions that must be solved to find the curve y(x) of a
specified length L with endpoints on the x-axis (i.e., at x = 0 and x = xf ) that
encloses the maximum area, so that:
Z xf Z xf p
J= ydx and 1 + ẏ 2 dx = L
0 0
with xf free.
Answer a):
Finding a necessary condition with t0 , x(t0 ) = x0 , and x(tf ) = xf are specified, tf is
free and ga = g + ν T e.
Z tf +δtf Z tf
∆J = T
[g + ν e]dt − [g ∗ + ν T e∗ ]dt
t0 t0
Z tf Z tf +δtf
T ∗ T ∗
= {[g + ν e] − [g + ν e ]}dt [g + ν T e]dt
t0 tf
The first integrand can be expanded about x∗ (t), ẋ∗ (t) in a Taylor series to give:
Z tf
∂ ∗ T ∗ ∂ ∗ T ∗
∆J = (g + ν e ) δx(t) + (g + ν e ) δ ẋ(t) dt + o(δx(t), δ ẋ(t))
t0 ∂x ∂ ẋ
Z tf +δtf
+ [g + ν T e]dt
tf
3
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
Integrating by parts:
∂ ∗ T ∗
∆J = (g + ν e ) δx(tf ) + [g + ν T ]δtf (1)
∂ ẋ
Z tf
∂ ∗ T ∗ d ∂ ∗ T ∗
+ (g + ν e ) − (g + ν e ) δx(t)dt
t0 ∂x dt ∂ ẋ
We have also used the fact that ∂x(t0 ) = 0. Now expressing the function g in terms of
g∗.
∂ ∗ ∂ ∗
[g + ν T ] = [g ∗ + ν T e∗ ] + [g + ν T e∗ ]δx(tf ) + [g + ν T e∗ ]δ ẋ(tf ) + o(·)
∂x ∂ ẋ
Simplifying this equation:
[g + ν T ] = [g ∗ + ν T e∗ ]
δx(tf ), which is neither zero nor free, depends on δtf . The variation of J, δJ, consists
of the first-order terms in the increment ∆J; therefore, the dependence of δx(tf ) on
δx(tf ) must be linearly approximated.
From the last equation we can get the necessary and boundary conditions:
∂ ∗ T ∗ d ∂ ∗ T ∗
(g + ν e ) − (g + ν e ) = 0
∂x dt ∂ ẋ
∂ ∗
[g ∗ + ν T e∗ ] − (g + ν T e∗ )ẋ∗ (tf ) = 0
∂ ẋ
With:
[g ∗ + ν T e∗ ] = ga
4
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
Answer b):
First, we are going to identify g function and e function:
p
g=y e = 1 + ẏ 2
∂g ∂e
=1 =0
∂y ∂y
∂g ∂e ẏ
=0 =p
∂ ẏ ∂ ẏ 1 + ẏ 2
With the information in the last subsection:
p ∂ga ∂ga ẏ
ga = y + ν 1 + ẏ 2 =1 = νp
∂y ∂ ẏ 1 + ẏ 2
Using the first condition:
∂ga d ∂ga
− =0
∂y dt ∂ ẏ
! ! !
d ẏ d ẏ 1 d ẏ
1− νp =0→1=ν p → = p
dt 1 + ẏ 2 dt 1 + ẏ 2 ν dt 1 + ẏ 2
p 1
1 1 + ẏ 2 (ÿ) − ẏ(1 + ẏ 2 )− 2 (ẏ ÿ)
=
ν 1 + ẏ 2
1 ÿ
= 3
ν (1 + ẏ) 2
So that:
1 3
ÿ = (1 + ẏ) 2
ν
Using the second condition:
∂ga (tf ) ∗
ga (tf ) − ẏ (tf ) = 0
∂ ẏ
ẏ(tf )
q
y(tf ) + ν 1 + ẏ 2 (tf ) − ν p ẏ(tf ) = 0
1 + ẏ 2 (tf )
−ν
y(tf ) = p
1 + ẏ 2 (tf )
5
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
ẏ(tf ) = ∞
Replacing e in equation: Z tf q
1 + ẏ 2 (tf )dt = L
t0
O
ẋ1 = x2
ẋ2 = x2 + u
(a) For Rxx /Ruu = 1 show analytically (i.e. not using Matlab) that the steady-state
LQR gains are: √
K = [1 3 + 1]
√
and that the closed-loop poles are at s = −( 3 ± j)/2
(b) Using the steady-state regulator gains from Matlab in each case, plot (on one
graph) the closed-loop locations for a range of possible values of Rxx /Ruu . Show
the pole locations for the expensive control problem. Do you see any trends here?
Answer a):
We have the following system:
0 1 0
ẋ = x+ u
0 1 1
1 tf T
Z
1 T
J = x(tf ) Hx(tf ) + [x (t)Qx(t) + u(t)T R(t)u(t)]dt
2 2 t0
6
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
g(x) = Rx xT Qx + Ru Ru2
T
1 0
x Qx = x1 x2 x 1 x2
0 0
1 0
Q= Ru = 1
0 0
Now, applying the equation to get the gains K:
K values: √ √
k11 = 3 k12 = 1 k22 = 1 ± 3
So: √
3 1√
K=
1 1+ 3
7
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
det(sI − A + BK) = 0
√
s
−1√ = s2 + s 3 + 1 = 0
1 s + 3
√
3±j
s1,2 = − ∇
2
Answer b):
The larger Rxx /Ruu is, the K gains in the system become just as large. In the same
way the poles of the system move away from the imaginary axis. The opposite happens
when Rxx /Ruu tends to be very small.
8
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
4. Find the Hamiltonian and then solve the necessary conditions to compute the optimal
control and state trajectory that minimize:
Z 1
J= u2 dt
0
for the system ẋ = −2x + u with initial state x(0) = 2 and terminal state x(1) = 0.
Plot the optimal control and state response using Matlab.
Answer:
9
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
With:
∂H
ẋ∗ (t) = = −2x∗ (t) + u∗ (t)
∂P
∂H
Ṗ ∗ (t) = − = −2P ∗ (t)
∂x
∂H
= 2u∗ (t) + P ∗ (t) = 0
∂u
10
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
To obtain P(0) value, we must use the conditions that the problem gave to us:
1
0 = [(P (0) + 16)e−2 − P (0)e2 ]
8
0 = P (0) + 16 − P (0)e4
P (0)(e4 − 1) = 16
16
P (0) = 4 = 0.2985
e −1
So, the solution is:
x∗ (t) = 2.03772e−2t − 0.2985e2t
u∗ (t) = −14925e2t
11
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
Using the HAmilton-Jacobi-Bellman equation, show that a possible optimal value func-
tion is of the form:
1 1
J ? (x(t), t) = xT (t)P (t)x(t) + bT (t)x(t) + c(t) (4)
2 2
where:
−1 T −1
K(t) = Ruu B (t)P (t) uf w = −Ruu (t)B T (t)b(t) (5)
In the process demonstrate that the conditions that must be satisfied are:
−1
−Ṗ (t) = AT (t)P (t) + P (t)A(t) + Rxx (t) − P (t)B(t)Ruu (t)B T (t)P (t)
−1
ḃ(t) = −[A(t) − B(t)Ruu (t)B T (t)P (t)]T b(t) − P (t)w(t)
−1
ċ(t) = bT (t)B(t)Ruu (t)B T (t)b(t) − 2bT (t)w(t)
u∗ = −Ru−1 B T Jx∗
12
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
Control input:
u∗ (t) = K(t)x(t) + uwf (t)
Substituting the input in the Hamiltonian:
1
H = Jt∗ + [xT Rx x + Jx∗ T BRu−1 B T Jx∗ ] + Jx∗ T [Ax + B(−Ru−1 B T Jx∗ ) + w]
2
1 1
H = xT Rx x − Jx∗ T BRu−1 B T Jx∗ + Jx∗ T [Ax + w]
2 2
13
Victor M. Chan Ortiz Optimal Control
CINVESTAV - GDL Homework 3 March 17, 2020
We can se that:
xT P BRu−1 B T b = bT BRu−1 B T P x
Thus:
1 1 1 1
0 = xT Ṗ x + ḃT x + ċ + xT Rx x − xT P BRu−1 B T P x − xT P BRu−1 B T bT
2 2 2 2
1
− bBRu−1 B T bT + xT P Ax + xT P w + bAx + bw
2
1 T
0 = x [Ṗ + Rxx + P BRu−1 B T P + 2P A]x + xT (P BRu−1 B T b + 2P w + ḃ + AT b)
2
1
+ (ċ − bT BRu−1 B T b + 2bT w)
2
The conditions to satisfy the last equation are:
−1
−Ṗ (t) = AT (t)P (t) + P (t)A(t) + Rxx (t) − P (t)B(t)Ruu (t)B T (t)P (t)
−1
ḃ(t) = −[A(t) − B(t)Ruu (t)B T (t)P (t)]T b(t) − P (t)w(t)
−1
ċ(t) = bT (t)B(t)Ruu (t)B T (t)b(t) − 2bT (t)w(t)
14