$title Mighty Steel example option limcol=0; set months/Jul, Aug, Sep, Oct, Nov, Dec/; parameter sales(months) / Jul 4, Aug 8, Sep 16, Oct 12, Nov 6, Dec 4/; * scale to get units instead of thousands units sales(months) = 1000 * sales(months); scalar increaseProduction "cost per unit to increase production" /0.50/ decreaseProduction "cost per unit to decrease production" /0.25/ initialProduction "production in June" /4000/ initialInventory "inventory at end of June" /2000/ maxInventory "maximum inventory level" /10000/ ; variable production(months) "production in each month" productionIncrease(months) "increase in production over previous month" productionDecrease(months) "decrease in production over previous month" inventory(months) " inventory at end of month" cost ; positive variables production, productionIncrease, productionDecrease; equation EQincrease(months) "define production increase" EQdecrease(months) "define production decrease" EQinventory(months) "define inventory at end of month" objective "define cost"; EQincrease(months).. productionIncrease(months) =g= production(months) - production(months-1) - initialProduction$(ord(months)=1); EQdecrease(months).. productionDecrease(months) =g= production(months-1) + initialProduction$(ord(months)=1) - production(months); EQinventory(months).. inventory(months) =e= inventory(months-1) + initialInventory$(ord(months)=1) + production(months) - sales(months); objective.. cost =e= sum(months, productionIncrease(months)*increaseProduction) + sum(months, productionDecrease(months)*decreaseProduction); * set upper and lower bounds on inventory inventory.lo(months) = 0; inventory.up(months) = maxInventory; model mightysteel/EQincrease, EQdecrease, EQinventory, objective/; solve mightysteel using lp minimizing cost;