PROPT Bryson Maxrange: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 68: | Line 68: | ||
<pre> | <pre> | ||
Problem type appears to be: lpcon | Problem type appears to be: lpcon | ||
Time for symbolic processing: 0. | Time for symbolic processing: 0.11045 seconds | ||
Starting numeric solver | Starting numeric solver | ||
===== * * * =================================================================== * * * | ===== * * * =================================================================== * * * | ||
Line 83: | Line 83: | ||
FuncEv 1 ConstrEv 55 ConJacEv 55 Iter 34 MinorIter 185 | FuncEv 1 ConstrEv 55 ConJacEv 55 Iter 34 MinorIter 185 | ||
CPU time: 0. | CPU time: 0.187201 sec. Elapsed time: 0.192000 sec. | ||
</pre> | </pre> | ||
Line 102: | Line 102: | ||
[[File:brysonMaxrange_01.png]] | [[File:brysonMaxrange_01.png]] | ||
[[Category:PROPT Examples]] |
Latest revision as of 04:55, 14 February 2012
This page is part of the PROPT Manual. See PROPT Manual. |
Problem description
Max range version of Bryson-Denham problem
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t
p = tomPhase('p', t, 0, 2, 50);
setPhase(p);
tomStates x y v
tomControls u1 u2
% Various constants and expressions
xmin = -10; xmax = 10;
ymin = xmin; ymax = xmax;
Vmin = -100; Vmax = 100;
g = 1;
a = 0.5*g;
% Initial guess
x0 = collocate({u1 == 1; u2 == 0});
% Box constraints
cbox = {xmin <= icollocate(x) <= xmax
ymin <= icollocate(y) <= ymax
Vmin <= icollocate(v) <= Vmax
-100 <= collocate(u1) <= 100
-100 <= collocate(u2) <= 100};
% Boundary constraints
cbnd = {initial({x == 0; y == 0; v == 0})
final(y == 0.1)};
% ODEs and path constraints
ceq = {collocate({
dot(x) == v.*u1
dot(y) == v.*u2
dot(v) == a-g*u2
})
collocate(u1.^2+u2.^2 == 1)};
% Objective
objective = -final(x);
Solve the problem
options = struct;
options.name = 'Bryson MaxRange';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x = subs(collocate(x),solution);
y = subs(collocate(y),solution);
v = subs(collocate(v),solution);
u1 = subs(collocate(u1),solution);
u2 = subs(collocate(u2),solution);
Problem type appears to be: lpcon Time for symbolic processing: 0.11045 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Bryson MaxRange f_k -1.712314875015308500 sum(|constr|) 0.000000100745006408 f(x_k) + sum(|constr|) -1.712314774270302200 f(x_0) 0.000000000000000000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 55 ConJacEv 55 Iter 34 MinorIter 185 CPU time: 0.187201 sec. Elapsed time: 0.192000 sec.
Plot result
subplot(2,1,1)
plot(t,x,'*-',t,y,'*-',t,v,'*-');
legend('x','y','v');
title('Bryson MaxRange state variables');
subplot(2,1,2)
plot(t,u1,'+-',t,u2,'+-');
legend('u1','u2');
title('Bryson MaxRange control');