Nagurka Problem

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.

Contents

Problem description

Find u over t in [0; 1 ] to minimize

$$ J = \int_{0}^{1} x'*x + u'*u \mathrm{d}t + 10*x_1(t_F)^2 $$

subject to:

$$ \frac{dx}{dt} = 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 ] ,$$

$$ -\infty <= u(1:n) <= \infty .$$

% Copyright (c) 2007-2008 by Tomlab Optimization Inc.

Problem setup

toms t
n  = 6;
tF = 1;

p = tomPhase('p', t, 0, tF, 25);
setPhase(p);

x = tomState('x', n, 1);
u = tomState('u', n, 1);

vec = (1:n);
A = [sparse(n-1,1), speye(n-1); ...
    sparse(vec.*(-1).^(vec+1))];

% Initial guess
guess = icollocate(x == vec');

% Initial conditions
cinit = (initial(x) == vec');

% 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: qpcon
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2010-02-05
=====================================================================================
Problem: ---  1: Nagurka Problem                f_k     109.074347752044370000
                                       sum(|constr|)      0.000000000014092963
                              f(x_k) + sum(|constr|)    109.074347752058470000
                                              f(x_0)    100.999999999999290000

Solver: snopt.  EXIT=0.  INFORM=1.
SNOPT 7.2-5 NLP code
Optimality conditions satisfied

FuncEv    1 ConstrEv   30 ConJacEv   30 Iter   29 MinorIter  288
CPU time: 0.796875 sec. Elapsed time: 0.829000 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');