# # Aggregate Planning Model Example solve on NEOS server (who does not like end;) # set PROD; # Set of products param T > 0; # Time horizon (number of months) param InitWrk >=0; # Initial work force param OTLimit >=0; # Over-time limit in relation to regular time of the labor param Demand{PROD, 1..T} >= 0; # Demand for each product in each period param InvCost{PROD} >= 0; # Inventory cost for each product param StCost{PROD} >= 0; # Stock out cost for each product param PrCost{PROD} >= 0; # Production cost for each product param SubCost{PROD} >= 0; # Subcontracting cost for each product param ProdRate{PROD}>= 0; # Production rate per period for each product param ProdTime{PROD}>= 0; # Time required to produce a unit of a product param InitInv{PROD} >= 0; # Initial Inventory for each product param InitOut{PROD} >= 0; # Initial stock out/backlog for each product param FinInv{PROD} >= 0; # Final Inventory for each product param FinOut{PROD} >= 0; # Final stock out/backlog for each product param FTCost{1..T} >= 0; # Full-time workers cost per period param OTCost{1..T} >= 0; # Over-time cost per period param HCost{1..T} >= 0; # Hiring cost of new labor per period param LCost{1..T} >= 0; # Layoff cost per period var w{0..T} >= 0; # Total numbers of emploees working in each period var h{1..T} >= 0; # Workesrs hired at the beginning of a period var l{1..T} >= 0; # Workers laid off at the beginning of a period var o{1..T} >= 0; # Overtime hours worked in period t var W{p in PROD, t in 1..T} >= 0; # Labor working on product p in month t var P{p in PROD, t in 1..T} >= 0; # Units of product p produced at the end of period t var I{p in PROD, t in 0..T} >= 0; # Inventory of product p at the end of perio t var S{p in PROD, t in 0..T} >= 0; # Units of product p stocked out/backlogged at the end of period t var C{p in PROD, t in 1..T} >= 0; # Units of product p subcontracted for period t var O{p in PROD, t in 1..T} >= 0; # Overtime hours on product p in period t minimize total_cost: sum{t in 1..T} ( FTCost[t]*w[t] + OTCost[t]*o[t] + HCost[t]*h[t] + LCost[t] *l[t] ) + sum{p in PROD, t in 1..T} ( InvCost[p]*I[p,t] + StCost[p]*S[p,t] + PrCost[p]*P[p,t] + SubCost[p]*C[p,t]); subject to workforce{t in 1..T}: w[t] = w[t-1] + h[t] -l[t]; subject to total_workforce{t in 1..T}: w[t] = sum{p in PROD} W[p,t]; subject to capacity{p in PROD, t in 1..T}: P[p,t] <= ProdRate[p]*W[p,t] + O[p,t]/ProdTime[p]; subject to overtime{p in PROD, t in 1..T}: O[p,t] <= OTLimit * W[p,t]; subject to total_overtime{t in 1..T}: o[t] = sum{p in PROD} O[p,t]; subject to inventory_balance{p in PROD, t in 1..T}: I[p,t-1] + P[p,t] + C[p,t] = Demand[p,t] + S[p,t-1] + I[p,t] - S[p,t]; subject to initial_workforce: w[0] = InitWrk; subject to initial_inventory{p in PROD}: I[p,0] = InitInv[p]; subject to initial_stock_out{p in PROD}: S[p,0] = InitOut[p]; subject to final_inventory{p in PROD}: I[p,T] = FinInv[p]; subject to final_stock_out{p in PROD}: S[p,T] = FinOut[p]; # end; data; set PROD := A B; param T := 6; param OTLimit := 48; param InvCost := A 2 B 3; param StCost := A 6 B 8; param PrCost := A 10 B 15; param SubCost := A 35 B 50; param ProdRate := A 480 B 320; param ProdTime := A 0.33 B 0.50; param FTCost := 1 2560 2 2560 3 2560 4 2560 5 2560 6 2560; param OTCost := 1 24 2 24 3 24 4 24 5 24 6 24; param HCost := 1 200 2 200 3 200 4 200 5 200 6 200; param LCost := 1 300 2 300 3 300 4 300 5 300 6 300; param Demand : 1 2 3 4 5 6 := A 1300 1500 2000 1400 2000 1800 B 1000 3000 4000 2000 2000 2200 ; param InitInv := A 50 B 50; param FinInv := A 50 B 50; param InitOut := A 0 B 0; param FinOut := A 0 B 0; param InitWrk = 15; # end; solve; display total_cost; display w; dispaly o; display P; display I; display S; display C;