Chain : Hanging Chain


  • Neculai Andrei, Nonlinear Optimization Applications Using the GAMS Technology,Springer Optimization and Its Applications, Model Chain (5.28) in chapter Applications of Mechanical Engineering , 2013

Category : GAMS NOA library

Mainfile : chain.gms

   Find the chain (of uniform density) of length L suspended between two
   points with minimal potential energy.

   This model is from the COPS benchmarking suite.

   The number of intervals for the discretization can be specified using
   the command line parameter --nh. COPS performance tests have been
   reported for nh = 50, 100, 200, 400

   Tested with nh=3000, 4000, 5000;     May 26, 2005

   Neculai Andrei, "Models, Test Problems and Applications for
   Mathematical Programming". Technical Press, Bucharest, 2003.
   Application A7, page 350.

   Dolan, E D, and More, J J, Benchmarking Optimization Software with COPS.
   Tech. rep., Mathematics and Computer Science Division, 2000.

   Cesari, L, Optimization - Theory and Applications. Springer Verlag, 1983.

$if     set n  $set nh %n%
$if not set nh $set nh 400

set nh /i0 * i%nh%/;


scalars L  length of the suspended chain      / 4 /
        a  height of the chain at t=0 (left)  / 1 /
        b  height of the chain at t=1 (left)  / 3 /
        tf ODEs defined in [0 tf]             / 1 /
        h  uniform interval length
        n  number of subintervals

if (b>a, tmin = 0.25 else tmin = 0.75);
n = card(nh) - 1;
h = tf/n;

  x(i)   height of the chain
  u(i)   derivative of x
  energy potential energy ;

x.fx('i0')    = a;
x.fx('i%nh%') = b;

x.l(i) = 4*abs(b-a)*((ord(i)-1)/n)*(0.5*((ord(i)-1)/n) - tmin) + a;
u.l(i) = 4*abs(b-a)*(((ord(i)-1)/n) - tmin);

equations obj, x_eqn(i), length_eqn ;

obj.. energy =e=
       0.5*h*sum(nh(i+1), x(i)*sqrt(1+sqr(u(i))) +

x_eqn(i+1).. x(i+1) =e= x(i) + 0.5*h*(u(i)+u(i+1));

length_eqn.. 0.5*h*sum(nh(i+1), sqrt(1+sqr(u(i))) +
                                sqrt(1+sqr(u(i+1)))) =e= L;

model chain /all/;
$iftheni x%mode%==xbook
$onecho >minos.opt
  superbasics limit = 5000

$onecho >bench.opt
 solvers conopt knitro minos.1


option nlp=bench

solve chain using nlp minimizing energy;
$iftheni x%mode%==xbook
file res /chain.dat/;
put res
loop(i, put x.l(i):10:5, put/)

*------------ January 26, 2011
* For nh=1000 I obtained the following results:
* CONOPT:  20 iterations,   2.654 seconds,  vfo=5.0685102
* KNITRO:  8  iterations,   0.380 seconds,  vfo=5.06850999
* MINOS : 202 iterations,  73.145 seconds,  vfo=5.068510

* End Hanging Chain