proc optmodel; set Period = {1,2,3,4,5,6,7,8,9,10,11,12}; set Period_with_Zero = {0,1,2,3,4,5,6,7,8,9,10,11,12}; number Capacity = 99999; number Demand{Period} = [200 150 100 50 50 100 150 200 200 250 300 250]; number HoldingCost = 1; number SetupCost = 500; number M = sum{t in Period}Demand[t]; var QuantityProduced{Period} >= 0; var Inventory{Period_with_Zero} >= 0; var Production{Period} binary; minimize TotalCost = /*Setup Cost*/ sum{t in Period}(SetupCost*Production[t]) + /*Inventory Holding Cost*/ sum{t in Period}(HoldingCost*Inventory[t]) ; con StartingInventory: Inventory[0]=0; con ManufacturingCapacity{t in Period}: QuantityProduced[t]<=Capacity; con FlowConservation{t in Period}: QuantityProduced[t]-Demand[t]+Inventory[t-1]-Inventory[t]=0; con LinkingConstraint{t in Period}:QuantityProduced[t]-M*Production[t]<=0; solve; print TotalCost Production QuantityProduced; quit;