# One Dimensional Rocket Ascent

User's Guide for DIRCOL

Problem 2.3 One-dimensional ascent of a rocket

## Problem Formulation

Find tCut over t in [0; tF ] to minimize

subject to:

% Copyright (c) 2007-2008 by Tomlab Optimization Inc.


## Problem setup

toms t
toms tCut tp2
p1 = tomPhase('p1', t, 0, tCut, 20);
p2 = tomPhase('p2', t, tCut, tp2, 20);

tf = tCut+tp2;

x1p1 = tomState(p1,'x1p1');
x2p1 = tomState(p1,'x2p1');
x1p2 = tomState(p2,'x1p2');
x2p2 = tomState(p2,'x2p2');

% Initial guess
x0 = {tCut==10
tf==15
icollocate(p1,{x1p1 == 50*tCut/10;x2p1 == 0;})
icollocate(p2,{x1p2 == 50+50*t/100;x2p2 == 0;})};

% Box constraints
cbox = {
1  <= tCut <= tf-0.00001
tf <= 100
0  <= icollocate(p1,x1p1)
0  <= icollocate(p1,x2p1)
0  <= icollocate(p2,x1p2)
0  <= icollocate(p2,x2p2)};

% Boundary constraints
cbnd = {initial(p1,{x1p1 == 0;x2p1 == 0;})
final(p2,x1p2 == 100)};

% ODEs and path constraints
a = 2; g = 1;
ceq = {collocate(p1,{
dot(p1,x1p1) == x2p1
dot(p1,x2p1) == a-g})
collocate(p2,{
dot(p2,x1p2) == x2p2
dot(p2,x2p2) == -g})};

% Objective
objective = tCut;

final(p1,x2p1) == initial(p2,x2p2)};


## Solve the problem

options = struct;
options.name = 'One Dim Rocket';
constr = {cbox, cbnd, ceq, link};
solution = ezsolve(objective, constr, x0, options);

Problem type appears to be: lpcon
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2010-02-05
=====================================================================================
Problem: ---  1: One Dim Rocket                 f_k       9.999998166162908900
sum(|constr|)      0.000733735140223408
f(x_k) + sum(|constr|)     10.000731901303132000
f(x_0)     10.000000000000000000

Solver: snopt.  EXIT=0.  INFORM=1.
SNOPT 7.2-5 NLP code
Optimality conditions satisfied

FuncEv    1 ConstrEv   10 ConJacEv   10 Iter    8 MinorIter   87
CPU time: 0.031250 sec. Elapsed time: 0.032000 sec.


## Plot result

t = [subs(collocate(p1,t),solution);subs(collocate(p2,t),solution)];
x1 = subs(collocate(p1,x1p1),solution);
x1 = [x1;subs(collocate(p2,x1p2),solution)];
x2 = subs(collocate(p1,x2p1),solution);
x2 = [x2;subs(collocate(p2,x2p2),solution)];

figure(1)
plot(t,x1,'*-',t,x2,'*-');
legend('x1','x2');
title('One Dim Rocket state variables');