# TOMLAB  
# REGISTER (TOMLAB)
# LOGIN  
# myTOMLAB
TOMLAB LOGO

« Previous « Start » Next »

69  Moonlander Example

Arthur Bryson - Dynamic Optimization

69.1  Problem description

Example about landing an object.

Reference: [9]

69.2  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);

69.3  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
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2011-02-05
=====================================================================================
Problem: ---  1: Moon Lander                    f_k       1.420346223923628400
                                       sum(|constr|)      0.000000000118734605
                              f(x_k) + sum(|constr|)      1.420346224042363000
                                              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 1434
CPU time: 0.937500 sec. Elapsed time: 0.984000 sec.

69.4  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');

pngs/moonLander_01.png

« Previous « Start » Next »