! Single product Capacitated lot sizing in LINGO.
  Decide how much to produce each period of a single 
 product so as to
  Minimise setup and holding costs,
 subject to:
  each period:
    satisfying demand,
    not exceeding production capacity,
    not exceeding inventory capacity;
! Keywords: Lot sizing, Capacitated lot sizing, Production planning;
SETS:
  TIME:
   DEM,  ! Demand each time period;
   MAKE, ! Amount to produce each period;
   INV,  ! Amount in inventory at end of period;
   Y;    ! = 1 if anything is produced in period, else 0;
 ENDSETS
DATA: TIME = 1..15; PCAP = 200; ! Production Capacity per period; ICAP = 100; ! Inventory upper limit each period; SC = 280 ; ! Setup cost to produce > 0 in a period; HC = 2 ; ! Holding cost per unit; DEM = 40 60 130 0 100 200 111 210 5 121 30 30 30 5 5; ! Demands; ! Assume initial inventory is 0; ENDDATA !------------------------------------; ! The straightforward formulation; ! The objective; MIN = SCOST + ICOST; SCOST = @SUM( TIME(t): SC*Y(t)); ICOST = @SUM( TIME(t): HC*INV(t)); ! Inventory balance constraints; MAKE(1) = DEM(1) + INV(1); ! Period 1 starts with 0 inventory; @FOR( TIME(t) | t #GT# 1: ! Subsequent periods; INV(t-1) + MAKE(t) = DEM(t) + INV(t); ); @FOR( TIME(t): ! Inventory capacity; INV(t) <= ICAP; ! Production capacity and setup forcing; MAKE(t) <= @SMIN( PCAP, @SUM( TIME(s) | s #GE# t: DEM(s)))*Y(t); ! Make the Y's binary (0 or 1); @BIN( Y(t)); );