#single-item multi module capacitated lot-sizing param T:=20; # number of periods to calculate param T2:=40; # number of periods of data param prod_setup_cost1 {1..T2} >= 0; # fix production costs (setup costs) module 1 param prod_setup_cost2 {1..T2} >= 0; # fix production costs (setup costs) module 2 param prod_unit_cost {1..T2} >= 0; # variable production cost (unit costs) module 1 & 2 param prod_capacity1 {1..T}:=670; # production capacity module 1 param prod_capacity2 {1..T}:=1280; # production capacity module 2 param demand{1..T2} >= 0; # demand per period param storage_unit_cost {1..T}:=0.05; # variable holding costs (unit costs) param storage_capacity {1..T}:=9999; # storage capacity var u1 {t in 1..T} binary; # production on/off module 1 var x1 {t in 1..T} >=0; # qantity to produce module 1 var u2 {t in 1..T} binary; # production on/off module 2 var x2 {t in 1..T} >=0; # qantity to produce module 2 var y {t in 0..T} >=0; # inventory level minimize totalcost: sum {t in 1..T} (u1[t]*prod_setup_cost1[t] + x1[t]*prod_unit_cost[t] + u2[t]*prod_setup_cost2[t] + x2[t]*prod_unit_cost[t] + y[t]*storage_unit_cost[t]); subject to y_0: y[0]=0; subject to balance {t in 1..T}: y[t]=y[t-1]+x1[t]+x2[t]-demand[t]; subject to u_cap1{t in 1..T}: x1[t]<=u1[t]*prod_capacity1[t]; subject to u_cap2{t in 1..T}: x2[t]<=u2[t]*prod_capacity2[t]; #subject to v_on{t in 1..T}: y[t]<=storage_capacity[t]; #faster: #183.8 secs vs 192.3 secs subject to y_T: y[T]=0; solve; printf "\n"; printf "\n//Input data for Online Solver at https://www.lutanho.net/plt/lotsize_mcm.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 fix var x_max demand y_min fix var y_max\n"; printf{t in 1..T} " 0; %3d, %3d,%2d,%3d,%3d,%2d,%3d; %3d; 0,%3d,%3d, %3d;\n", (0),(prod_setup_cost1[t]*100), (prod_unit_cost[t]*100), prod_capacity1[t], (prod_setup_cost2[t]*100), (prod_unit_cost[t]*100), prod_capacity2[t], demand[t], (0), (storage_unit_cost[t]*100), storage_capacity[t]; printf "\n---------------------------------------------------------"; printf "\nTotal Cost: %10g\n", totalcost; printf "\n"; data; param demand := 1 571, 2 495, 3 592, 4 488, 5 427, 6 561, 7 459, 8 537, 9 506, 10 471, 11 508, 12 541, 13 538, 14 594, 15 556, 16 480, 17 532, 18 435, 19 495, 20 548, 21 560, 22 402, 23 585, 24 546, 25 446, 26 450, 27 557, 28 551, 29 454, 30 534, 31 501, 32 454, 33 527, 34 498, 35 592, 36 423, 37 440, 38 403, 39 549, 40 424; param prod_unit_cost := 1 0.58, 2 0.71, 3 0.88, 4 0.53, 5 0.71, 6 0.84, 7 0.63, 8 0.84, 9 0.51, 10 0.92, 11 0.96, 12 0.8, 13 0.64, 14 0.74, 15 0.6, 16 0.63, 17 0.91, 18 0.96, 19 0.81, 20 0.54, 21 0.52, 22 0.65, 23 0.82, 24 0.89, 25 0.59, 26 0.62, 27 0.77, 28 0.93, 29 0.56, 30 0.85, 31 0.88, 32 0.97, 33 0.84, 34 0.92, 35 0.83, 36 0.56, 37 0.84, 38 0.97, 39 0.75, 40 1; param prod_setup_cost1 := 1 2979, 2 2905, 3 2920, 4 2937, 5 3086, 6 3100, 7 2867, 8 3002, 9 2885, 10 3093, 11 2895, 12 3016, 13 2930, 14 2884, 15 3134, 16 2911, 17 2958, 18 3137, 19 3088, 20 3044, 21 2915, 22 2877, 23 3083, 24 2965, 25 2970, 26 2904, 27 3020, 28 2870, 29 3069, 30 3046, 31 3133, 32 2980, 33 3056, 34 3035, 35 3000, 36 2951, 37 3114, 38 2928, 39 3096, 40 3003; param prod_setup_cost2 := 1 6066, 2 6059, 3 6177, 4 5906, 5 6191, 6 5899, 7 6001, 8 6124, 9 6069, 10 6173, 11 5873, 12 5999, 13 5901, 14 5896, 15 5881, 16 6125, 17 5936, 18 6042, 19 6118, 20 6086, 21 6112, 22 6119, 23 6194, 24 5961, 25 6130, 26 6141, 27 6184, 28 6164, 29 5863, 30 6145, 31 6064, 32 5947, 33 6012, 34 5980, 35 5974, 36 6051, 37 5921, 38 6001, 39 6057, 40 6007; end;