PROPT Moonlander Example
From TomWiki
Jump to navigationJump to search
This page is part of the PROPT Manual. See PROPT Manual. |
Arthur Bryson - Dynamic Optimization
Problem description
Example about landing an object.
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t
toms t_f
p = tomPhase('p', t, 0, t_f, 60);
setPhase(p);
tomStates altitude speed mass
tomControls thrust
% Initial guess
x0 = {t_f == 1.5
icollocate({
altitude == 1-t/t_f
speed == -0.783+0.783*t/t_f
mass == 1-0.99*t/t_f
})
collocate(thrust == 0)};
% Box constraints
cbox = {
0 <= t_f <= 1000
-20 <= icollocate(altitude) <= 20
-20 <= icollocate(speed) <= 20
0.01 <= icollocate(mass) <= 1
0 <= collocate(thrust) <= 1.227};
% Boundary constraints
cbnd = {initial({altitude == 1; speed == -0.783; mass == 1})
final({altitude == 0; speed == 0})};
% ODEs and path constraints
exhaustvelocity = 2.349;
gravity = 1;
ceq = collocate({
dot(altitude) == speed
dot(speed) == -gravity + thrust./mass
dot(mass) == -thrust./exhaustvelocity});
% Objective
objective = integrate(thrust);
Solve the problem
options = struct;
options.name = 'Moon Lander';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
altitude = subs(collocate(altitude),solution);
speed = subs(collocate(speed),solution);
mass = subs(collocate(mass),solution);
thrust = subs(collocate(thrust),solution);
Problem type appears to be: qpcon Time for symbolic processing: 0.14633 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Moon Lander f_k 1.420346223923629700 sum(|constr|) 0.000000000117891076 f(x_k) + sum(|constr|) 1.420346224041520800 f(x_0) 0.000000000000000000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 70 ConJacEv 70 Iter 21 MinorIter 1437 CPU time: 0.312002 sec. Elapsed time: 0.322000 sec.
Plot result
subplot(2,1,1)
plot(t,altitude,'*-',t,speed,'*-',t,mass,'*-');
legend('altitude','speed','mass');
title('Moon Lander state variables');
subplot(2,1,2)
plot(t,thrust,'+-');
legend('thrust');
title('Moon Lander control');