Lindo Systems
    ! Do static analysis of a cantilever truss that looks like:
   
 1__2__3__4
 | /| /| /|
 |/_|/_|/_|
 
The truss is attached vertically and horizontally at node 1 top,
  and attached only horizontally at node 1 bottom.
There are bounds on the allowed tensile and compressive stress
on each member.
We want to maximize the load that can be carried at node n bottom;
! Keywords: Truss design, Statics, Stress analysis;
!    The SETS-based model. To see the equivalent scalar model, 
  click on: Solver | Generate | Display;
sets:
! The set of vertical slices and associated forces;
 vslice : fvrt, ftop, fbot, fdiag;
endsets
data:
!Parameters;
  H = 4; ! Length of each horizontal member;
  V = 3; ! Length of each vertical member;
  vslice = 1..4; ! The set of vertical slices;
  fmax =  370; ! Tension limit on each member;
  fmin = -350; ! Compression limit;
enddata
! Definition of variables:
   For j = 1, 2, ..., n:
    fvrt(j) = tension on vertical member at slice j, < 0 implies compression.
   For j = 1, 2, ..., n-1:
    ftop( j) = tension on the horizontal top member slice j,
    fbot( j) = tension on the horizontal bottom member of slice j,
    fdiag(j) = tension on the diagonal member in slice j,
;
 n = @size( vslice); ! number of vertical members;
 theta = @ATAN2( H, V); ! The angle between the bottom horizontal leg and the diagonal;
! The truss has 2*n nodes. For each node, there are two equations enforcing:
   horizontal forces net to 0, and vertical forces net to 0;
! for slice 1, top;
!  Horizontal forces at top node of 1 must be =;
   [TOPH1] ftop0 = ftop(1);
!  vertical forces at top of node 1 must be =;
   [TOPV1] fvrt0 = fvrt(1);
!  horizontal forces at bottom of 1;
   [BOTH1] fbot0 = fbot(1) + fdiag(1)*@cos( theta);
      @free( fbot0); ! Allow for a compressive force;
!  vertical forces at bottom of 1;
   [BOTV1] fvrt(1) = - fdiag(1)*@sin( theta);
! At intermediate nodes;
   @for( vslice( j) | j #gt# 1 #and# j #lt# n:
!  Horizontal forces at top of j;
     [TOPH]  ftop( j-1) + fdiag(j-1)*@cos(theta) = ftop(j);
!  vertical forces at top of j;
     [TOPV]  fvrt(j) = -fdiag(j-1)*@sin(theta);
!  horizontal forces at bottom of j;
     [BOTH]  fbot(j) + fdiag(j)*@cos(theta)  = fbot(j-1);
!  vertical forces at bottom of j;
     [BOTV] fvrt(j) = - fdiag(j)*@sin( theta);
       );
! For final, rightmost slice;
!  horizontal forces at top of n;
     [TOPHN] ftop( n-1) + fdiag(n-1)*@cos(theta) = 0;
      ftop( n) = 0; ! Member does not exist;
      fdiag( n) = 0; !Member does not exist;
!  vertical forces at top of n;
     [TOPVN] fvrt(n) = - fdiag(n-1)*@sin(theta);
!  horizontal forces at bottom of n;
     [BOTHN] fbot(n-1) = 0;
      fbot( n) = 0; !Member does not exist;
! vertical forces at bottom of n;
     [BOTVN] fvrt( n) = load;
! Tension and compression limits;
    @for( vslice( j):
      @bnd( fmin, ftop( j), fmax);
      @bnd( fmin, fbot( j), fmax);
      @bnd( fmin, fdiag( j), fmax);
      @bnd( fmin, fvrt( j), fmax);
        );
! Maximize the load we can carry;
     max = load;