PROPT Nagurka Problem: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 14: | Line 14: | ||
<math> J = \int_{0}^{1} x'*x + u'*u \mathrm{d}t + 10*x_1(t_F)^2 </math> | <math> J = \int_{0}^{1} x'*x + u'*u \mathrm{d}t + 10*x_1(t_F)^2 </math> | ||
subject to: | subject to: | ||
<math> \frac{dx}{dt} = A*x + u </math> | <math> \frac{dx}{dt} = A*x + u </math> | ||
<pre> | <pre> | ||
Line 30: | Line 32: | ||
<math> x(0) = [ 1 \ 2 \ ... \ n ] ,</math> | <math> x(0) = [ 1 \ 2 \ ... \ n ] ,</math> | ||
<math> -\infty <= u(1:n) <= \infty .</math> | <math> -\infty <= u(1:n) <= \infty .</math> | ||
<source lang="matlab"> | <source lang="matlab"> | ||
Line 79: | Line 83: | ||
<pre> | <pre> | ||
Problem type appears to be: qp | Problem type appears to be: qp | ||
Time for symbolic processing: 0. | Time for symbolic processing: 0.067164 seconds | ||
Starting numeric solver | Starting numeric solver | ||
===== * * * =================================================================== * * * | ===== * * * =================================================================== * * * | ||
Line 94: | Line 98: | ||
FuncEv 3 GradEv 3 ConstrEv 3 Iter 3 | FuncEv 3 GradEv 3 ConstrEv 3 Iter 3 | ||
Elapsed time: 0. | CPU time: 0.015600 sec. Elapsed time: 0.007000 sec. | ||
</pre> | </pre> | ||
Line 129: | Line 133: | ||
[[File:nagurkaProblem_03.png]] | [[File:nagurkaProblem_03.png]] | ||
[[Category:PROPT Examples]] |
Latest revision as of 05:34, 14 February 2012
This page is part of the PROPT Manual. See PROPT Manual. |
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.
Problem description
Find u over t in [0; 1 ] to minimize
subject to:
A = [0 1 0 ... 0 0 0 1 ... 0 ... ... ... 0 0 0 ... 1 1 -2 3 ... (-1)^(n+1)*n]
The initial condition are:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
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);
Solve the problem
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 Time for symbolic processing: 0.067164 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: 1: Nagurka Problem f_k 109.074347751905190000 sum(|constr|) 0.000000000001514694 f(x_k) + sum(|constr|) 109.074347751906710000 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.015600 sec. Elapsed time: 0.007000 sec.
Plot result
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');