13 A NLP (non-linear) Model (chain)

Run LPL Code  ,  PDF Document

The class of non-linear models is too diverse to be covered, too diverse in the sense of solution methods. Only one example is given here. Implemented in LPL, it is send to the solver Knitro to be solved. The following is the problem of a hanging chain.

Problem

Find the function y = f(x) of a hanging chain (of uniform density) of length L suspended between the two points (xa,ya) and (xb,yb) where (xa < xb and L > xb - xa) with minimal potential energy. See [2] and [4].

In physics and geometry, the curve of an idealized hanging chain or cable under its own weight when supported only at its ends is called a catenary. Galileo mistakenly conjectured that the curve was a parabola. Later Bernoulli and others proved that it is a hyperbolic cosine. Catenaries are used in a variety of application: An inverse catenary is the ideal shape of a freestanding arch of constant thickness. (See also in Wikipedia under “Catenary”.)

Modeling Steps

The formula for potential energy is E = ghm where h is the height, m is the mass and g is a gravitational constant. As a function the height h is y and the mass m is proportional to the arc length of the chain. Hence, the model is to minimize the potential energy E under the condition of the chain length L:

           ∫
             xb   ∘  -----′2-
min            y ⋅   1 + y  dx
            xa∫  xb ∘ -------
subjectto           1 + y′2 dx = L
               xa

Explanation: It is easy to see that in a small horizontal interval Δx of the function y = f(x) and the corresponding Δy interval, the arc length of the function is:

                ∘ ------------   ∘ -----------
∘ -----------     Δx2     Δy2           Δy  2
  Δx2  + Δy2  =   ----2 + ---2-=   1 + (----)Δx
                  Δx      Δx            Δx

With Δx 0 the length of the arc of the function y = f(x) between xa and xb is then given by:

∫   ∘  ----------     ∫
  xb       dx- 2        xb ∘ -----′2
       1 + ( dy) dx =        1 + y  dx
 xa                    xa

To implement the problem in LPL, we need to discretizise the problem in say n vertical small intervals of width Δx = (xb - xa)∕n. Let I = {0,,n} and let xi = xa(1 - i)∕n + xb i∕n be the starting x-coordinate of the interval i, and let yi = f(xi). Then the function y = f(x) in an interval i can be approximated by the mid-point in that interval :

 xi-+-xi-1   yi +-yi-1
(    2     ,    2    )   forall i ∈ {1,...,n}

The derivative yat interval i can be approximated by :

ydoti = (yi - yi-1)∕Δx   forall i ∈ {1,...,n}

Finally the arc length is approximated by :

∘ ----------
  1 + ydot2i Δx    forall i ∈ {1,...,n }

Note that the mass m is proportionl to the arc length (since the chain has uniform density), and the gravitational constant does not influence the form of the function. So, it can be dropped. With this hints the model can be easily constructed as follows:


Listing 11: The Main Model implemented in LPL [10]
model chain "A NLP (non-linear) Model"; 
  parameter n := 50; 
  set i := 0..n  "number of intervals for the discretization"; 
  parameter 
    L  := 10   "length of the suspended chain"; 
    xa := 0    "left x coordinate"; 
    ya := 0    "height (y) of the chain at left"; 
    xb := 5    "right x coordinate"; 
    yb := 1    "height (y) of the chain at right" ; 
    dx   := (xb-xa)/n  "interval"; 
    x{i} := xa+dx*i    "x-coor of chain"; 
  variable 
    y{i}      "hanging height"; 
    ydot{i}   "derivative of y"; 
  constraint 
    YDOT{i|i>0}: y[i] - y[i-1] = dx*ydot[i]; 
    LE: sum{i|i>0} Sqrt(1+ydot[i]^2)*dx = L; 
    ST: y[0]=ya and y[n]=yb; 
  minimize energy: sum{i|i>0} (y[i]+y[i-1])/2 * Sqrt(1+ydot[i]^2)*dx; 
  model output1; 
    set k:=0..10; 
    parameter X:=1; Y:=10; --scale 
      x1:=400/X; y1:=300/Y; -- draw rect (0,0) to (x1,y1) 
      xmin:=0; xmax:=xb; ymin:=-5; ymax:=0; 
      Xt{k}:=xmin+(xmax-xmin)/(#k-1)*k; Yt{k}:=ymin+(ymax-ymin)/(#k-1)*k;; 
    x{i}:=x*x1/Abs(xmax-xmin); y{i}:=y*y1/-(ymax-ymin); 
    Draw.Scale(X,Y); 
    Draw.DefFont('Verdana',8); 
    Draw.Line(0,0,0,y1); 
    {k} Draw.Line(x1/10*k,y1,x1/10*k,y1+10/Y); 
    {k} Draw.Text(Round(Xt,-1)&'',x1/10*k-7/X,y1+20/Y); 
    Draw.Line(0,y1,x1,y1); 
    {k} Draw.Line(-10/X,y1-y1/10*k,0,y1-y1/10*k); 
    {k} Draw.Text(Round(Yt,-1)&'',-25/X,y1-y1/10*k+3/Y); 
    {i|i>0} Draw.Line(x[i-1],y[i-1],x[i],y[i]); 
  end 
end

Solution

The hanging chain of length L = 10 between the points (xa,ya) = (0, 0) and (xb,yb) = (5, 0) is drawn in figure 3. This figure is generated by the model output.


PIC

Figure 3: A Hanging Chain