#single-item multi module capacitated lot-sizing param T0:=0; # 0, 18, 37 # period before start period (inventory=0) param T1:=1; # 1, 19, 38 # first period to calculate param T2:=18; # 18, 37, 60 # last period to calculate (inventory=0) param T:=60; # number of periods of data param prod_setup_cost1 {1..T} >= 0; # fix production costs (setup costs) module 1 param prod_setup_cost2 {1..T} >= 0; # fix production costs (setup costs) module 2 param prod_unit_cost {1..T} >= 0; # variable production cost (unit costs) module 1 & 2 param prod_capacity1 {1..T}:=960; # production capacity module 1 param prod_capacity2 {1..T}:=1970; # production capacity module 2 param demand{1..T} >= 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 T1..T2} binary; # production on/off module 1 var x1 {t in T1..T2} >=0; # qantity to produce module 1 var u2 {t in T1..T2} binary; # production on/off module 2 var x2 {t in T1..T2} >=0; # qantity to produce module 2 var y {t in T0..T2} >=0; # inventory level minimize totalcost: sum {t in T1..T2} (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[T0]=0; subject to balance {t in T1..T2}: y[t]=y[t-1]+x1[t]+x2[t]-demand[t]; subject to u_cap1{t in T1..T2}: x1[t]<=u1[t]*prod_capacity1[t]; subject to u_cap2{t in T1..T2}: x2[t]<=u2[t]*prod_capacity2[t]; #subject to v_on{t in T1..T2}: y[t]<=storage_capacity[t]; #faster without subject to y_T: y[T2]=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;",(T2-T0); printf "\nstartup x_min fix var x_max fix var x_max demand y_min fix var y_max\n"; printf{t in T1..T2} " 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 501, 2 515, 3 467, 4 459, 5 411, 6 474, 7 591, 8 418, 9 497, 10 478, 11 434, 12 425, 13 596, 14 452, 15 545, 16 481, 17 409, 18 497, 19 529, 20 465, 21 585, 22 524, 23 422, 24 437, 25 520, 26 513, 27 586, 28 563, 29 544, 30 426, 31 553, 32 485, 33 451, 34 566, 35 563, 36 432, 37 449, 38 568, 39 474, 40 517, 41 516, 42 406, 43 556, 44 530, 45 468, 46 411, 47 497, 48 508, 49 525, 50 507, 51 552, 52 477, 53 568, 54 525, 55 550, 56 487, 57 580, 58 481, 59 415, 60 497; param prod_unit_cost := 1 0.92, 2 0.9, 3 0.67, 4 0.85, 5 0.89, 6 0.53, 7 0.6, 8 0.96, 9 0.55, 10 0.75, 11 0.61, 12 0.83, 13 0.68, 14 0.72, 15 0.55, 16 0.77, 17 0.87, 18 0.89, 19 0.57, 20 0.55, 21 0.82, 22 0.6, 23 0.69, 24 0.79, 25 0.81, 26 0.66, 27 0.79, 28 0.71, 29 0.88, 30 0.77, 31 0.78, 32 0.57, 33 0.7, 34 0.68, 35 0.85, 36 0.93, 37 0.63, 38 0.52, 39 0.81, 40 0.92, 41 0.51, 42 1, 43 0.85, 44 0.68, 45 0.53, 46 0.75, 47 0.91, 48 0.94, 49 0.71, 50 0.79, 51 0.79, 52 0.6, 53 0.91, 54 0.84, 55 0.92, 56 0.57, 57 0.52, 58 0.97, 59 0.77, 60 0.93; param prod_setup_cost1 := 1 2888, 2 3133, 3 2905, 4 2931, 5 2876, 6 3130, 7 3036, 8 2921, 9 2971, 10 2964, 11 3021, 12 2861, 13 3050, 14 3106, 15 3043, 16 3020, 17 2902, 18 2883, 19 3035, 20 3133, 21 3121, 22 3055, 23 3036, 24 2973, 25 2896, 26 3083, 27 2882, 28 2891, 29 3146, 30 2975, 31 2864, 32 2923, 33 2876, 34 2865, 35 2924, 36 2925, 37 3103, 38 2900, 39 2922, 40 2927, 41 2879, 42 2899, 43 2981, 44 3062, 45 3085, 46 3130, 47 2954, 48 2992, 49 2907, 50 2951, 51 3073, 52 2948, 53 3019, 54 2972, 55 3028, 56 3086, 57 2898, 58 3074, 59 3055, 60 2938; param prod_setup_cost2 := 1 5986, 2 5915, 3 5904, 4 6141, 5 5974, 6 6037, 7 5871, 8 6031, 9 6040, 10 5877, 11 5988, 12 5860, 13 5938, 14 5934, 15 5916, 16 5886, 17 6092, 18 5943, 19 6093, 20 6167, 21 6178, 22 6004, 23 6077, 24 6023, 25 6027, 26 5896, 27 6054, 28 6089, 29 6064, 30 5872, 31 6171, 32 6129, 33 6151, 34 5882, 35 5982, 36 6147, 37 5954, 38 5947, 39 5855, 40 6091, 41 5911, 42 5913, 43 5861, 44 5918, 45 5904, 46 6084, 47 6190, 48 6052, 49 6039, 50 6042, 51 5954, 52 5998, 53 5868, 54 5851, 55 6058, 56 6014, 57 6184, 58 6096, 59 6101, 60 6196; end;