# Second AMPL model for the NSC problem set PRODUCTS; param MONTHS; # Number of months in the planning horizon param c {1 .. MONTHS, PRODUCTS}; # c[i,p] = cost of producting one ton of product p in month i param d {1 .. MONTHS,PRODUCTS}; # d[i,p] = tons of product p needed in month i var P {1 .. MONTHS,PRODUCTS} >= 0; # P[i,p] = tons of product p produced in month i var I {0 .. MONTHS,PRODUCTS} >= 0; # I[i,p] = tons of product p in inventory at the end of month i minimize cost: sum{i in 1 .. MONTHS, p in PRODUCTS} (c[i,p]*P[i,p] + 120*I[i,p]); subject to demand {i in 1 .. MONTHS, p in PRODUCTS}: P[i,p] + I[i-1,p] >= d[i,p]; subject to inventory {i in 1 .. MONTHS, p in PRODUCTS}: I[i,p] = P[i,p] + I[i-1,p] - d[i,p]; subject to initial_inventory {p in PRODUCTS}: I[0,p] = 0; subject to final_inventory {p in PRODUCTS}: I[MONTHS,p] >= 1500; subject to max_production {i in 1 .. MONTHS}: sum{p in PRODUCTS} P[i,p] <= 5000;