! Keywords: Inventory / Lot Sizing / Marketing / Product Management / Production / Reorder Point / Scheduling / Uncertainty;
! Two Product Capacitated Lotsizing Problem.
!   Yit = 1 if product i is produced in period t,
!   XAst = 1 if demands in periods s through t are 
!     satisfied from production in period s, for product A,
!   XBst = 1 etc. for product B.
 MIN  100 YA1 + 100 YA2 + 150 YA3 + 150 YA4 + 200 YA5
      + 200 YA6 + 30 YB1 + 40 YB2 + 30 YB3 + 55 YB4 
      + 45 YB5 + 45 YB6 + 200 XA11 + 560 XA12 + 1260 XA13 
      + 1620 XA14 + 2720 XA15 + 5520 XA16 + 360 XA22 
      + 1060 XA23 + 1420 XA24 + 2520 XA25 + 5320 XA26 
      + 700 XA33 + 1060 XA34 + 2160 XA35 + 4960 XA36 
      + 320 XA44 + 1320 XA45 + 3920 XA46 + 900 XA55
      + 3300 XA56 + 2000 XA66 + 40 XB11 + 160 XB12 
      + 360 XB13 + 540 XB14 + 740 XB15 + 1055 XB16 
      + 120 XB22 + 320 XB23 + 500 XB24 + 700 XB25 
      + 1015 XB26 + 160 XB33 + 310 XB34 + 485 XB35 
      + 765 XB36 + 150 XB44 + 325 XB45 + 605 XB46
      + 125 XB55 + 335 XB56 + 175 XB66
 subject to
!  For product A:
!  If a production lot was depleted in period i-1 (the - terms),
!     then a production run of some sort must be started in 
!     period i (the  + terms)
     A1)XA11+XA12+XA13+XA14+XA15+XA16=1
     A2) - XA11 + XA22 + XA23 + XA24 + XA25 + XA26 = 0
     A3) - XA12 - XA22 + XA33 + XA34 + XA35 + XA36 = 0
     A4) - XA13 - XA23 - XA33 + XA44 + XA45 + XA46 = 0
     A5) - XA14 - XA24 - XA34 - XA44 + XA55 + XA56 = 0
     A6) - XA15 - XA25 - XA35 - XA45 - XA55 + XA66 = 0
!  The setup forcing constraints for A
 FA1)  YA1 - XA11 - XA12 - XA13 - XA14 - XA15 - XA16 >= 0
 FA2)  YA2 - XA22 - XA23 - XA24 - XA25 - XA26 >=   0
 FA3)  YA3 - XA33 - XA34 - XA35 - XA36 >=    0
 FA4)  YA4 - XA44 - XA45 - XA46 >=    0
 FA5)  YA5 - XA55 - XA56 >=    0
 FA6)  YA6 - XA66 >=    0
!  Same constraints for product B:
     B1) + XB11 + XB12 + XB13 + XB14 + XB15 + XB16 =  + 1
     B2) - XB11 + XB22 + XB23 + XB24 + XB25 + XB26 =  0
     B3) - XB12 - XB22 + XB33 + XB34 + XB35 + XB36 =  0
     B4) - XB13 - XB23 - XB33 + XB44 + XB45 + XB46 =  0
     B5) - XB14 - XB24 - XB34 - XB44 + XB55 + XB56 =  0
     B6) - XB15 - XB25 - XB35 - XB45 - XB55 + XB66 =  0
!  The setup forcing constraints;
 FB1)  YB1 - XB11 - XB12 - XB13 - XB14 - XB15 - XB16 >= 0
 FB2)  YB2 - XB22 - XB23 - XB24 - XB25 - XB26 >=  0
 FB3)  YB3 - XB33 - XB34 - XB35 - XB36 >=  0
 FB4)  YB4 - XB44 - XB45 - XB46 >=   0
 FB5)  YB5 - XB55 - XB56 >=   0
 FB6)  YB6 - XB66 >=   0
!  Here are the capacity constraints for each period;
!   The coefficent of a variable is the associated lotsize;
    CAP1)  40 XA11 + 100 XA12 + 200 XA13 + 240 XA14 
         + 340 XA15 + 540 XA16 + 20 XB11 + 50 XB12 
         + 90 XB13 + 120 XB14  + 145 XB15 + 180 XB16 
         <=  200
    CAP2)  60 XA22 + 160 XA23 + 200 XA24 + 300 XA25 
         + 500 XA26 + 30 XB22 + 70 XB23 + 100 XB24 
         + 125 XB25 + 160 XB26 <=  200
    CAP3)  100 XA33 + 140 XA34 + 240 XA35 + 440 XA36 
         + 40 XB33 + 70 XB34 + 95 XB35 + 130 XB36 <=  200
    CAP4) 40 XA44 + 140 XA45 + 340 XA46 + 30 XB44 
         + 55 XB45 + 90 XB46 <=  200
    CAP5)  100 XA55 + 300 XA56 + 25 XB55 + 60 XB56 
         <=  200
    CAP6)  200 XA66 + 35 XB66 <=  200
 END
 INTEGER 12