Different Types of Systems: TF X (TF)
Different Types of Systems: TF X (TF)
is clear why .x(t) is called the costate vector. Finally, using the
relation (2.7.28), the boundary condition (2.7.26) at the optimal
condition reduces to
(2.7.32)
• Type (b): Free-Final Time and Fix ed-Final State System: Since
tf is free or not specified in advance, 8tf is arbitrary, and since
X(tf) is fixed or specified, 8xf is zero as shown in Figure 2.9(b).
Then, the coefficient of the arbitrary 8t f in the general boundary
condition (2.7.32) is zero resulting in
(2.7.33)
x(t) x(t)
x*(t)+ox(t)
xo ..
t t
(a) (b)
x(t) x(t)
xo .. Xo ...
o to t o to it t
(c) (d)
(2.7.35)
(2.7.38)
(2.7.39)
(2.7.41)
(2.7.42)
i
t!
J = S(x(tf), tf) + V(x(t), u(t), t)dt (2.7.43)
to
Here, x(t) and u(t) are n- and r- dimensional state and control vec-
tors respectively. Let us note that u( t) is unconstrained. The entire pro-
cedure (called Pontryagin Principle) is now summarized in Table 2.1.
Note: From Table 2.1 we note that the only difference in the proce-
dure between the free-final point system without the final cost function
(Lagrange problem) and free-final point system with final cost function
(Bolza problem) is in the application of the general boundary condition.
To illustrate the Pontryagin method described previously, consider
the following simple examples describing a second order system. Specif-
ically, we selected a double integral plant whose analytical solutions for
the optimal condition can be obtained and the same verified by using
MATLAB©.
First we consider the fixed-final time and fixed-final state problem
(Figure 2.9(a), Table 2.1, Type (a)).
Example 2.12
Given a second order (double integrator) system as
Xl(t) = X2(t)
X2(t) = u(t) (2.7.46)
and the performance index as
(2.7.47)
find the optimal control and optimal state, given the boundary
(initial and final) conditions as
xi(t) = + ( : ) * = x2(t)
.
Ai(t) = - (aH)
aXI * = 0
Optimal
Controller
u*(t)
J x2 *(t)
J x 1*(Q
**************************************************************
%% Solution Using Symbolic Toolbox (STB) in
%% MATLAB Version 6.0
%%
S=dsolve('Dxl=x2,Dx2=-lambda2,Dlambdal=0,Dlambda2=-lambdal, ...
xl(0)=1,x2(0)=2,xl(2)=1,x2(2)=0')
S.xl
S.x2
S.lambdal
S.lambda2
S =
lambdal: [lxl symJ
lambda2: [lxl symJ
xl: [lxl symJ
x2: [lxl symJ
S.xl
ans=
2.7 Variational Approach to Optimal Control Systems 73
S.x2
ans=
2-4*t+3/2*t-2
S.lambdal
ans=
3
S.lambda2
ans=
Next, we consider the fixed-final time and free-final state case (Fig-
74 Chapter 2: Calculus of Variations and Optimal Control
, '"
u(t), .. ,.
.-
-2 ., .,'
,. ,.
..
"
·3 ,,." "
,
,.
.,'
"
-4~~~~--~--~--~--~--~--~--~--~
o 0.2 0.4 0.6 0.8 1.2 1.4 1.6 1.8 2
Example 2.13
Consider the same Example 2.12 with changed boundary conditions
as
x(O) = [1 2]'; xl(2) = 0; x2(2) is free. (2.7.58)
Find the optimal control and optimal states.
(2.7.60)
* 5 3 15 2
xl (t) = 16 t - 8 t + 2t + 1,
* 15 2 15
x2 (t) =- t - -t + 2
16 4 '
*( ) 15
Al t = 8'
* 15 15
A2(t) = -8 t + 4'
* 15 15
u (t) = 8 t - 4·
(2.7.63)
***************************************************************
%% Solution Using Symbolic Toolbox (STB) in
%% MATLAB Version 6.0
%%
S=dsolve('Dxl=x2,Dx2=-lambda2,Dlambdal=0,Dlambda2=-lambdal,
xl(0)=1,x2(0)=2,xl(2)=0,lambda2(2)=0')
S =
76 Chapter 2: Calculus of Variations and Optimal Control
ans=
S.x2
ans=
S.lambdal
ans=
15/8
S.lambda2
ans=
-15/8*t+15/4
gtext ('x_2(t)')
gtext ('u(t) ')
*******************************************************
It is easy to see that the previous solutions for xi (tj, x2 (t), Ai (t), A2 (t),
and u*(t) = -A2(t) obtained by using MATLAB© are the same as
those given by (2.7.63) obtained analytically. The optimal control
and states for Example 2.13 are plotted in Figure 2.12.
0
.... "".-
-1
-2 .-'
. ..
,"
-3
".
."
"
-4
0 0.2 0.4 0.6 0.8 1.2 1.4 1.6 1.8 2
Example 2.14
Consider the same Example 2.12 with changed boundary conditions
as
* C3 t 3 C4 2
X1(t) =6 - 2t + C2t + C1,
X2(t) = ~3t2 - C4t + C2,
Ai(t) = C3,
A2(t) = -C3 t + C4,
U*(t) = -A2(t) = C3t - C4. (2.7.65)
(2.7.66)
Finally, the optimal states, costates, and control are given from
2.7 Variational Approach to Optimal Control Systems 79
(2.7.70)
The solution for the set of differential equations (2.7.53) with
the boundary conditions C2. 7.68} for Example 2.14 using Symbolic
Toolbox of the MATLA~, Version 6 is shown below.
********************************************************
%% Solution Using Symbolic Toolbox (STB) in
%% of MATLAB Version 6
%%
clear all
S=dsolve('Dx1=x2,Dx2=-lam2,Dlaml=O,Dlam2=-lam1,xl(0)=l,
x2(0)=2,x1(tf)=3,lam2(tf)=0')
t='tf' ;
eq1=subs(S.x1)-'x1tf';
eq2=subs(S.x2)-'x2tf';
eq3=S.lam1-'lam1tf';
eq4=subs(S.lam2)-'lam2tf';
eq5='lamltf*x2tf-0.5*lam2tf 2'; A
S2=solve(eq1,eq2,eq3,eq4,eq5,'tf,x1tf,x2tf,lam1tf,
lam2tf','lam1tf<>0')
%% lam1tf<>0 means lam1tf is not equal to 0;
%% This is a condition derived from eq5.
%% Otherwise, without this condition in the above
%% SOLVE routine, we get two values for tf (1 and 3 in this case)
%%
tf=S2.tf
xltf=S2.xltf;
x2tf=S2.x2tf;
clear t
x1=subs(S.xl)
x2=subs(S.x2)
lam1=subs(S.lam1)
80 Chapter 2: Calculus of Variations and Optimal Control
lam2=subs(S.lam2)
%% Convert the symbolic values to
%% numerical values as shown below.
j=l;
tf=double(subs(S2.tf))
%% coverts tf from symbolic to numerical
for tp=O:O.05:tf
t=sym(tp);
%% coverts tp from numerical to symbolic
xlp(j)=double(subs(S.xl));
%% subs substitutes S.xl to xlp
x2p(j)=double(subs(S.x2));
%% double converts symbolic to numeric
up(j)=-double(subs(S.lam2));
%% optimal control u = -lambda_2
tl(j)=tp;
j=j+l ;
end
plot(tl,xlp, 'k' ,tl,x2p, 'k' ,tl,up, 'k:')
xlabel('t' )
gtext (' x_l (t) ')
gtext ( , x_2 ( t) , )
gtext ('u(t) ')
*******************************************************
The optimal control and states for Example 2.14 are plotted in
Figure 2.13.
Example 2.15
We consider the same Example 2.12 with changed performance
index
1
J = -[xl(2) 1
- 4] 2 + -[x2(2) 1102
- 2] 2 + -2 u2 dt (2.7.71)
2 2 0
and boundary conditions as
2.5
1.5
0 ",-~
-,- .. -'"
,-- _~o#--
-1.5
0 0.5 1.5 2 2.5 3
t
we have
* C3 3 C4 2
X1(t) = (it - 2t + C2t + C1,
(2.7.74)
where,
(2.7.75)
82 Chapter 2: Calculus of Variations and Optimal Control
Now, we have two initial conditions from (2.7.72) and two final
conditions from (2.7.76) to solve for the four constants as
(2.7.77)
* 1 3
Xl (t) = 14 t -"72 t 2 + 2t + 1,
x2*( t ) = -3 t2 - -t
4 +2
14 7 '
Ai(t) = ~,
A2(t) = -~t + ~,
u*(t) = ~t - i.7 (2.7.78)
7
The previous results c~ also obtained using Symbolic Math
Toolbox of the MATLAB\9, Version 6, as shown below.
***************************************************************
%% Solution Using Symbolic Math Toolbox (STB) in
%% MATLAB Version 6
%%
S=dsolve('Dxl=x2,Dx2=-lambda2,Dlambdal=O,Dlambda2=-lambdal,
xl(O)=1,x2(O)=2,lambdal(2)=x12-4,lambda2(2)=x22-2')
t='2' ;
S2=solve(subs(S.xl)-'x12',subs(S.x2)-'x22','x12,x22');
%% solves for xl(t=2) and x2(t=2)
x12=S2.x12;
x22=S2.x22;
clear t
S =
2.7 Variational Approach to Optimal Control Systems 83
xl=subs(S.xl)
xl =
x2=subs(S.x2)
x2 =
lambdal=subs(S.lambdal)
lambdal
3/7
lambda2=subs(S.lambda2)
lambda2 =
4/7-3/7*t
-1~--~--~--~--~--~--~--~--~~--~~
o 0.2 0.4 0.6 0.8 1.2 1.4 1.6 1.8 2