A detailed version of the Bryson-Denham problem
Reference: [9]
It is common for the independent variable to be named "t", but any legal tomSym name is possible. The length of the time-interval is variable, so another tomSym symbol is created for that.
toms t t_f p = tomPhase('p', t, 0, t_f, 30); setPhase(p);
% The name on the mathematics: options = struct; options.name = 'Bryson Denham Detailed'; x1max = 1/9; tfmax = 50;
After a phase has been defined, states can be created Note that the states can be given meaningful names, even though they are simply named x1...x3 in this particular problem.
tomStates x1 x2 x3 % Initial guess % The guess for t_f must appear first in the list x0 = {t_f == 0.5 icollocate({ x1 == 0 x2 == 1-2*t/t_f x3 == 0 })}; cbox = {0 <= t_f <= 50 -10 <= icollocate(x1) <= 10 -10 <= icollocate(x2) <= 10 -10 <= icollocate(x3) <= 10};
tomControls u x0 = {x0 collocate(u == 0)}; cbox = {cbox -5000 <= collocate(u) <= 5000};
The equations are on a nonlinear DAE form, i.e. the states and their derivatives can be combined into arbitrary equations. Equations can also be specified point-wise, or using integrals. Integrals can be achieved by using the function integral(). Each equation must contain one or more equals (==) signs, or one or more greater than (>=) signs, or one or more less than (<=) signs.
usquared = u^2; ceq = collocate({ dot(x1) == x2 dot(x2) == u dot(x3) == 0.5*usquared 0 <= x1 <= x1max % Path constraint }); cbnd = {initial({ x1 == 0; x2 == 1; x3 == 0}) final({x1 == 0; x2 == -1})}; % The "objective" function to minimize. Cost can be specified at a point, % or integrated over time by using the function integral. % If costs are defined as many parts they should be added together. objective = final(x3);
Prob = sym2prob('con',objective,{cbox, ceq, cbnd},x0,options); % Solve the problem using any TOMLAB solver Result = tomRun('snopt', Prob, 1);
===== * * * =================================================================== * * * TOMLAB - Tomlab Optimization Inc. Development license 999001. Valid to 2011-02-05 ===================================================================================== Problem: --- 1: Bryson Denham Detailed f_k 3.998132387937467900 sum(|constr|) 0.000000810449850953 f(x_k) + sum(|constr|) 3.998133198387318700 f(x_0) 0.000000000000000000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 35 GradEv 33 ConstrEv 33 ConJacEv 33 Iter 32 MinorIter 170 CPU time: 0.187500 sec. Elapsed time: 0.187000 sec.