PROPT Bryson-Denham Problem

From TomWiki
Jump to navigationJump to search

Notice.png

This page is part of the PROPT Manual. See PROPT Manual.

Problem description

Standard formulation for Bryson-Denham

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

Problem setup

setPhase([]);

toms t t_f

x10 = 0; x20 = 1;
x30 = 0; x1f = 0; x2f = -1;
x1min = -10;   x1max = 10;    x2min = x1min;
x2max = x1max; x3min = x1min; x3max = x1max;

tomStates x1 x2 x3
tomControls u

% Initial guess
x0 = {t_f == 0.5
    icollocate({
    x1 == x10+(x1f-x10)*t/t_f
    x2 == x20+(x2f-x20)*t/t_f
    x3 == x30
    })
    collocate(u==0)};

% Box constraints
cbox = {0.001 <= t_f <= 50
    0      <= mcollocate(x1) <= 1/9
    x2min  <= mcollocate(x2) <= x2max
    x3min  <= mcollocate(x3) <= x3max
    -5000  <= collocate(u)   <= 5000};

% Boundary constraints
cbnd = {initial({x1 == x10; x2 == x20; x3 == x30})
    final({x1 == x1f; x2 == x2f})};

% ODEs and path constraints
ceq = collocate({
    dot(x1) == x2
    dot(x2) == u
    dot(x3) == u.^2/2});

% Objective
objective = final(x3);

p = tomPhase('p', t, 0, t_f, 50);

Solve the problem

options = struct;
options.name = 'Bryson Denham';
options.phase = p;
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
Problem type appears to be: lpcon
Time for symbolic processing: 0.1271 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem: ---  1: Bryson Denham                  f_k       4.000021208621198800
                                       sum(|constr|)      0.000000174861447145
                              f(x_k) + sum(|constr|)      4.000021383482645900
                                              f(x_0)      0.000000000000000000

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

FuncEv    1 ConstrEv   63 ConJacEv   63 Iter   60 MinorIter  260
CPU time: 0.343202 sec. Elapsed time: 0.336000 sec. 

Plot result

subplot(2,1,1)
ezplot(subs(docollocate(p,[x1 x2 x3]),solution),0,solution.t_f);
legend('x1','x2','x3');
title('Bryson Denham state variables');

subplot(2,1,2)
ezplot(subs(docollocate(p,u),solution),0,solution.t_f);
legend('u');
title('Bryson Denham control');

BrysonDenham 01.png