! 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 SETSbased 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, ..., n1:
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( j1) + fdiag(j1)*@COS(theta) = ftop(j);
! vertical forces at top of j;
[TOPV] fvrt(j) = fdiag(j1)*@SIN(theta);
! horizontal forces at bottom of j;
[BOTH] fbot(j) + fdiag(j)*@COS(theta) = fbot(j1);
! 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( n1) + fdiag(n1)*@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(n1)*@SIN(theta);
! horizontal forces at bottom of n;
[BOTHN] fbot(n1) = 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;
