ITERATIVE DYNAMIC PROGRAMMING, REIN LUUS
6.4 Further example
CHAPMAN & HALL/CRC Monographs and Surveys in Pure and Applied Mathematics
n’th-order linear time-invariant system.
Find u over t in [0; 1 ] to minimize
| J = | ∫ |
| x′*x + u′*u dt + 10*x1(tF)2 |
subject to:
| = A*x + u |
A = [0 1 0 ... 0
0 0 1 ... 0
... ... ...
0 0 0 ... 1
1 -2 3 ... (-1)^(n+1)*n]The initial condition are:
| x(0) = [ 1 2 ... n ] , |
| −∞ <= u(1:n) <= ∞ . |
Reference: [25]
toms t
n = 6;
t_F = 1;
p = tomPhase('p', t, 0, t_F, 25);
setPhase(p);
x = tomState('x', n, 1);
u = tomState('u', n, 1);
nvec = (1:n);
A = [sparse(n-1,1), speye(n-1); ...
sparse(nvec.*(-1).^(nvec+1))];
% Initial guess
guess = icollocate(x == nvec');
% Initial conditions
cinit = (initial(x) == nvec');
% ODEs and path constraints
ceq = collocate(dot(x) == A*x+u);
% Objective
objective = 10*final(x(1))^2 + integrate(x'*x + u'*u);
options = struct;
options.name = 'Nagurka Problem';
solution = ezsolve(objective, {ceq, cinit}, guess, options);
t = subs(collocate(t),solution);
x = subs(collocate(x),solution);
u = subs(collocate(u),solution);
Problem type appears to be: qp
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license 999001. Valid to 2011-02-05
=====================================================================================
Problem: 1: Nagurka Problem f_k 109.074347751904550000
sum(|constr|) 0.000000000002256926
f(x_k) + sum(|constr|) 109.074347751906810000
f(x_0) 0.000000000000000000
Solver: CPLEX. EXIT=0. INFORM=1.
CPLEX Barrier QP solver
Optimal solution found
FuncEv 3 GradEv 3 ConstrEv 3 Iter 3
CPU time: 0.046875 sec. Elapsed time: 0.032000 sec.
subplot(2,1,1)
x1 = x(:,1);
plot(t,x1,'*-');
legend('x1');
title('Nagurka Problem - First state variable');
subplot(2,1,2)
u1 = u(:,1);
plot(t,u1,'+-');
legend('u1');
title('Nagurka Problem - First control variable');
figure(2)
surf(t, 1:n, x')
xlabel('t'); ylabel('i'); zlabel('x');
title('Nagurka Problem - All state variables');
figure(3)
surf(t, 1:n, u')
xlabel('t'); ylabel('i'); zlabel('u');
title('Nagurka Problem - All control variables');