Lindo Systems

! A Product Mix problem.
! Decide how much to produce of a set of products,
given how much we have of various resources, and
how much each product uses of each resource, so as to
maximize profit contribution;
!Keywords: Product mix, setup cost, fixed cost;
SETS:
   PRODUCT: PROFIT, SETUP, QUANTITY, BUILD;
   RESOURCE: AVAILABLE;
   RXP( RESOURCE, PRODUCT): USAGE;
ENDSETS
DATA:
  PRODUL = 400; ! Upper limit on products of each kind produced;
! The products we might produce and fixed/setup cost if produced;
  PRODUCT PROFIT SETUP =
  ROCKET   30     35
  METEOR   45     20
  STREAK   24     60
  COMET    26     70
  JET      24     75
  BIPLANE  30     30;  

! The resources and their availabilities; 
  RESOURCE = STEEL COPPER PLASTIC RUBBER  GLASS  PAINT; 
  AVAILABLE=   800   1160    1780   1050   1360   1240;
      USAGE =    1      4       0       4     2      0
                 4      5       3       0     1      0
                 0      3       8       0     1      0
                 2      0       1       2     1      5
                 2      4       2       2     2      4
                 1      4       1       4     3      4;
ENDDATA

! Maximize profit contribution minus setup costs;
MAX = @SUM( PRODUCT( p): 
 PROFIT( p) * QUANTITY( p) - SETUP( p) * BUILD( p));

! Cannot use more of resource r than is available;
@FOR( RESOURCE( r):
  @SUM( PRODUCT( p): 
     USAGE( r, p) * QUANTITY( p)) <= AVAILABLE( r);
    );

! Limits on production of each product;
@FOR( PRODUCT( p):
  QUANTITY( p) <= PRODUL * BUILD( p);
  @BIN( BUILD( p)); ! Build is a binary variable;
  @GIN( QUANTITY( p)); ! Quantity is a general integer variable;
   );