PROPT Bryson-Denham Problem: Difference between revisions
From TomWiki
Jump to navigationJump to search
(Created page with " ==Problem description== Standard formulation for Bryson-Denham <syntaxhighlight lang="matlab"> % Copyright (c) 2007-2008 by Tomlab Optimization Inc. </syntaxhighlight> ==Prob...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{Part Of Manual|title=the PROPT Manual|link=[[PROPT |PROPT Manual]]}} | |||
==Problem description== | ==Problem description== | ||
Line 4: | Line 5: | ||
Standard formulation for Bryson-Denham | Standard formulation for Bryson-Denham | ||
< | <source lang="matlab"> | ||
% Copyright (c) 2007-2008 by Tomlab Optimization Inc. | % Copyright (c) 2007-2008 by Tomlab Optimization Inc. | ||
</ | </source> | ||
==Problem setup== | ==Problem setup== | ||
< | <source lang="matlab"> | ||
setPhase([]); | setPhase([]); | ||
Line 53: | Line 54: | ||
p = tomPhase('p', t, 0, t_f, 50); | p = tomPhase('p', t, 0, t_f, 50); | ||
</ | </source> | ||
==Solve the problem== | ==Solve the problem== | ||
< | <source lang="matlab"> | ||
options = struct; | options = struct; | ||
options.name = 'Bryson Denham'; | options.name = 'Bryson Denham'; | ||
options.phase = p; | options.phase = p; | ||
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options); | solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options); | ||
</ | </source> | ||
<pre> | <pre> | ||
Line 87: | Line 88: | ||
==Plot result== | ==Plot result== | ||
< | <source lang="matlab"> | ||
subplot(2,1,1) | subplot(2,1,1) | ||
ezplot(subs(docollocate(p,[x1 x2 x3]),solution),0,solution.t_f); | ezplot(subs(docollocate(p,[x1 x2 x3]),solution),0,solution.t_f); | ||
Line 97: | Line 98: | ||
legend('u'); | legend('u'); | ||
title('Bryson Denham control'); | title('Bryson Denham control'); | ||
</ | </source> |
Revision as of 10:54, 2 November 2011
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.13757 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.354000 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');