# Bridge Crane System

ITERATIVE DYNAMIC PROGRAMMING, REIN LUUS

12.4.1 Example 1: Bridge crane system

CHAPMAN & HALL/CRC Monographs and Surveys in Pure and Applied Mathematics

## Problem description

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

subject to:

The initial condition are:

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


## Problem setup

toms t
toms tf

p = tomPhase('p', t, 0, tf, 50);
setPhase(p);

tomStates x1 x2 x3 x4
tomControls u

% Initial guess
% Note: The guess for tf must appear in the list before expression involving t.
x0 = {tf == 8, ...
collocate(u==1-2*t/tf)};

% Box constraints
cbox = {0.1 <= tf <= 100
-1  <= collocate(u) <= 1};

% Boundary constraints
cbnd = {initial({x1 == 0; x2 == 0
x3 == 0; x4 == 0})
final({x1 == 15; x2 == 0
x3 == 0; x4 == 0})};

% ODEs and path constraints
ceq = collocate({
dot(x1) == x2
dot(x2) == u
dot(x3) == x4
dot(x4) == -0.98*x3+0.1*u});

% Objective
objective = tf;


## Solve the problem

options = struct;
options.name = 'Bridge Crane System';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t  = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),solution);
x3 = subs(collocate(x3),solution);
x4 = subs(collocate(x4),solution);
u  = subs(collocate(u),solution);

Problem type appears to be: lpcon
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2010-02-05
=====================================================================================
Problem: ---  1: Bridge Crane System            f_k       8.578933610367174700
sum(|constr|)      0.000000187961517282
f(x_k) + sum(|constr|)      8.578933798328691300
f(x_0)      8.000000000000000000

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

FuncEv    1 ConstrEv   37 ConJacEv   37 Iter   19 MinorIter  497
CPU time: 0.421875 sec. Elapsed time: 0.422000 sec.


## Plot result

subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-',t,x3,'*-',t,x4,'*-');
legend('x1','x2','x3','x4');
title('Bridge Crane System state variables');

subplot(2,1,2)
plot(t,u,'+-');
legend('u');
title('Bridge Crane System control');