# single-item capacitated lot-sizing # example from YouTube video # Hakeem-Ur- Rehman # "Capacity Lot-Sizing Problem Using IBM ILOG OPL CPlex | OPL Cplex Studio | LP-and-Fix Heuristic" # https://www.youtube.com/watch?v=egoLovPYEm0 param T > 0; # number of periods param s {1..T} >= 0; # fix production costs (setup costs) param p {1..T} >= 0; # variable production cost (unit costs) param c {1..T} >= 0; # prodction capacity param d {1..T} >= 0; # demand per period param h {1..T} >= 0; # variable holding costs (unit costs) var q {t in 1..T} >= 0; # qantity to produce var i {t in 0..T} >= 0; # inventory level var z {t in 1..T} binary; # production on/off minimize totalcost: sum {t in 1..T} (s[t]*z[t] + h[t]*i[t] + p[t]*q[t]); subject to balance {t in 1..T}: i[t-1]+q[t]-d[t]=i[t]; subject to p_on{t in 1..T}: q[t]<=c[t]*z[t]; subject to i_0: i[0]=0; subject to i_T: i[T]=0; solve; printf "\n"; printf "\n//Input data for Online Solver at https://www.lutanho.net/plt/lotsize.html"; printf "\n//I u_0 y_0 y_I\n"; printf "%5d; 0; 0; 0;",T; printf "\nstartup x_min fix var x_max demand y_min fix var y_max\n"; printf{t in 1..T} " 0; 0,%4d,%3d,%4d;%5d; 0, 0,%3d, 9999;\n", s[t], p[t], c[t], d[t], h[t]; printf "\n--------------------------------------------------------------------"; printf "\nTotal Cost: %10g\n", totalcost; printf "\n"; data; param T := 20; param d := 1 12, 2 6, 3 20, 4 5, 5 7, 6 25, 7 0, 8 5, 9 5, 10 21, 11 9, 12 5, 13 27, 14 0, 15 5, 16 20, 17 5, 18 10, 19 5, 20 25; param c := 1 20, 2 15, 3 5, 4 30, 5 20, 6 20, 7 21, 8 10, 9 10, 10 5, 11 0, 12 12, 13 20, 14 5, 15 20, 16 5, 17 40, 18 20, 19 10, 20 20; param s := 1 25, 2 30, 3 40, 4 20, 5 80, 6 80,7 150, 8 30, 9 45, 10 60, 11 30, 12 90, 13 80,14 150, 15 25, 16 20, 17 30, 18 40, 19 20, 20 80; param h := 1 6, 2 5, 3 4, 4 5, 5 6, 6 9, 7 9, 8 6, 9 5, 10 4, 11 5, 12 6, 13 9, 14 9, 15 6, 16 5, 17 4, 18 5, 19 6, 20 9; param p := 1 5, 2 3, 3 7, 4 2, 5 1, 6 10, 7 15, 8 2, 9 1, 10 5, 11 1, 12 10, 13 15, 14 2, 15 1, 16 10, 17 1, 18 5, 19 1, 20 10; end;