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

« Previous « Start » Next »

14  The Brachistochrone Problem

This problem was formulated by Johann Bernoulli, in Acta Eruditorum, June 1696

14.1  Problem description

"Given two points A and B in a vertical plane, what is the curve traced out by a point acted on only by gravity, which starts at A and reaches B in the shortest time."

In this example, we solve the problem numerically for A = (0,0) and B = (10,-3), and an initial speed of zero.

The mechanical system is modelled as follows:

dx
dt
 = v sin(θ) 
dy
dt
 = −v cos(θ) 
dv
dt
 = g cos(θ) 


where (x,y) is the coordinates of the point, v is the velocity, and theta is the angle between the direction of movement and the vertical.

Reference: [6]

14.2  Problem setup

toms t
toms t_f
p = tomPhase('p', t, 0, t_f, 20);
setPhase(p);

tomStates x y v
tomControls theta

% Initial guess
% Note: The guess for t_f must appear in the list before expression involving t.
x0 = {t_f == 10
    icollocate({
    v == t
    x == v*t/2
    y == -1
    })
    collocate(theta==0.1)};

% Box constraints
cbox = {0.1 <= t_f <= 100
    0 <= icollocate(v)
    0 <= collocate(theta) <= pi};

% Boundary constraints
cbnd = {initial({x == 0; y == 0; v == 0})
    final({x == 10; y == -3})};

% ODEs and path constraints
g = 9.81;
ceq = collocate({
    dot(x) == v.*sin(theta)
    dot(y) == -v.*cos(theta)
    dot(v) == g*cos(theta)});

% Objective
objective = t_f;

14.3  Solve the problem

options = struct;
options.name = 'Brachistochrone';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
x     = subs(collocate(x),solution);
y     = subs(collocate(y),solution);
v     = subs(collocate(v),solution);
theta = subs(collocate(theta),solution);
t =     subs(collocate(t),solution);
Problem type appears to be: lpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2011-02-05
=====================================================================================
Problem: ---  1: Brachistochrone                f_k       1.878940329113843100
                                       sum(|constr|)      0.000000174716635746
                              f(x_k) + sum(|constr|)      1.878940503830478900
                                              f(x_0)     10.000000000000000000

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

FuncEv    1 ConstrEv  834 ConJacEv  834 Iter  224 MinorIter  826
CPU time: 1.484375 sec. Elapsed time: 1.500000 sec.

14.4  Plot the result

To obtain the brachistochrone curve, we plot y versus x.

subplot(3,1,1)
plot(x, y);

subplot(3,1,2)
plot(t, v);

% We can also plot theta vs. t.
subplot(3,1,3)
plot(t, theta)

pngs/brachistochrone_01.png

« Previous « Start » Next »