Reputation: 1
# SETS set B; # Candidate central kitchens set S; # Schools set C; # Categories class set K; # Set of commodities set N; # Set of nutrients set Y; # Set of groups set G {Y} within K; # Set of food groups # PARAMETERS param daily_budget; param fixed_cost {B}; # Fixed cost for each central kitchen param capacity {B}; # Capacity of each central kitchen param demand {S}; # Demand per school per time period param trans_cost; # Distribution cost from central kitchen to schools per kilometer param handling_cost; # Handling cost for each central kitchen param nutrient_value {K, N}; # Nutritional value of each commodity per nutrient type param nutrient_requirement {N, C}; # Nutritional requirement per nutrient and time period param cost_commodity {K}; # Cost per commodity param distance{S, B}; # jarak antar sekolah ke central kitchen dalam kilometer param processing_cost {Y}; # Biaya pemrosesan makanan di setiap central kitchen tiap group # VARIABLES var y {B} binary; # 1 if central kitchen is built at location, 0 otherwise var z {S, B} binary; # 1 if school s is served by central kitchen b var x {S, B} >= 0 integer; # Quantity of food delivered to school s from central kitchen b var unfulfilled_demand {S} >= 0; # Permintaan yang tidak terpenuhi di setiap sekolah var ratio_commodity {K} >= 0; # Ratio of commodities var shortfall {N} >= 0; var overshoot {N} >= 0; #var shortfall_indicator {N} binary; # OBJECTIVE FUNCTION # 1. Minimize total cost minimize total_cost: sum {b in B} fixed_cost[b] * y[b] + # Biaya tetap membuka central kitchen sum {b in B, s in S} trans_cost * distance[s, b] * x[s, b] + # Biaya distribusi makanan sum {b in B, s in S} handling_cost * x[s, b] + # Biaya penanganan saat delivery sum {k in K} cost_commodity[k] * ratio_commodity[k] * sum {s in S, b in B} x[s, b]; # Biaya bahan makanan # CONSTRAINTS # 1. Capacity constraint s.t. Capacity_Constraint {b in B}: sum {s in S} x[s, b] <= capacity[b] * y[b]; # 2. Demand fulfillment s.t. Demand_Fulfillment {s in S}: sum {b in B} x[s, b] + unfulfilled_demand[s] = demand[s]; # 3. Binary connection s.t. Binary_Connection {s in S, b in B}: x[s, b] <= demand[s] * z[s, b]; # 4. Serve only if open s.t. Serve_Only_If_Open {s in S, b in B}: z[s, b] <= y[b]; # Minimum delivery constraint #s.t. Min_Delivery {s in S, b in B}: # x[s, b] >= 0; s.t. Min_Distribution {s in S}: sum {b in B} x[s, b] >= demand[s] * 0.7; # Setidaknya 70% permintaan dipenuhi # 5. Nutrient optimization constraint s.t. Food_Basket_Optimize {n in N, c in C}: sum {k in K} nutrient_value[k, n] * ratio_commodity[k] * sum {s in S, b in B} x[s, b] >= nutrient_requirement[n, c]; # 6. Supplied nutrient constraint s.t. Supplied_Nutrient {n in N, c in C}: sum {k in K} nutrient_value[k, n] * ratio_commodity[k] * sum {s in S, b in B} x[s, b] = nutrient_requirement[n, c] * (1 - shortfall[n] + overshoot[n]); # 7. Unique service constraint s.t. Unique_Service {s in S}: sum {b in B} z[s, b] = 1; # 8. Min one service per central kitchen s.t. Min_One_Service_Per_CK {b in B}: y[b] <= sum {s in S} z[s, b]; # Budget constraint s.t. Budget_Constraint: sum {b in B} fixed_cost[b] * y[b] + sum {b in B, s in S} trans_cost * distance[s, b] * x[s, b] + sum {b in B, s in S} handling_cost * x[s, b] + sum {k in K} cost_commodity[k] * ratio_commodity[k] * sum {s in S, b in B} x[s, b] <= daily_budget; s.t. Ratio_Group1 : # Makanan pokok (33%) sum {k in G[1]} ratio_commodity[k] = 0.33 * sum {k in K} ratio_commodity[k]; s.t. Ratio_Group2 : # Lauk pauk (17%) sum {k in G[2]} ratio_commodity[k] = 0.17 * sum {k in K} ratio_commodity[k]; s.t. Ratio_Group3 : # Sayuran (33%) sum {k in G[3]} ratio_commodity[k] = 0.33 * sum {k in K} ratio_commodity[k]; s.t. Ratio_Group4 : # Buah (17%) sum {k in G[4]} ratio_commodity[k] = 0.17 * sum {k in K} ratio_commodity[k]; # SETS set B := FB1 FB2 FB3 FB4 FB5; # Candidate central kitchens set S := SD01 SD02 SD03 SD04 SD05 SD06 SD07 SD08 SD09 SD10 SD11 SD12 SD13 SD14 SD15 SD16 SD17 SD18 SD19 SD20 SD21 SDITPJHI SDITDARUN SDITNAMALIYAH SDITNILMI SMP13 SMP19 SMP23 SMP8 SMPDARUN SMPITALAZHAR SMPPJHI SMA7 SMAITALAZHAR SMK5 SMKSADZKIYA SMKSDUTAB; # Schools set C := SD SMP SMA; # Time periods (misalnya 5 periode waktu) set K := Apple, Bananna, Beef, BeefLiver, Carrot, Cassava, CassavaLeaf, Chicken, ChickenEgg, ChickenLiver, CoconutMilk, Corn, DuckEgg, FrenchBean, FreshMilk, KidneyBean, LongBean, Manggo, Melon, MilkFish, Mungbean, Mushrooms, Orange, Papaya, Pineapple, Potato, QuailEgg, Rambutan, Rice, Shrimp, SnakeFruit, Spinach, Tomato, Watercress, WaterMelon, WaterSpinach, Yam, KembungFish, PatinFish, LeleFish, GabusFish, TongkolFish, TunaFish, TeriFish, Cauliflower, DragonFruit, Pears, SiamesePumpkin, Broccoli; set N := Water, Energy, Protein, Fat, Carbohydrate, Fibre, Calcium, Iron, Zinc, VitA, VitB1, VitB2, VitB3, VitB6, VitB12, VitC, VitD, Folate; set Y := 1, 2, 3, 4; set G [1] := Cassava, Potato, Rice, Yam; #merah - makanan pokok set G [2] := Beef, BeefLiver, Chicken, ChickenEgg, ChickenLiver, DuckEgg, FreshMilk, MilkFish, QuailEgg, Shrimp, KembungFish, PatinFish, LeleFish, GabusFish, TongkolFish, TunaFish, TeriFish; #biru - lauk pauk set G [3] := Carrot, CassavaLeaf, CoconutMilk, Corn, FrenchBean, KidneyBean, LongBean, Mungbean, Mushrooms, Spinach, Tomato, Watercress, WaterSpinach, Cauliflower, SiamesePumpkin, Broccoli; #kuning - sayuran dan buah - buahan set G [4] := Apple, Bananna, Manggo, Melon, Orange, Papaya, Pineapple, Rambutan, SnakeFruit, DragonFruit, Pears, WaterMelon; # PARAMETERS param daily_budget := 5000000000; param fixed_cost := FB1 125000 FB2 125000 FB3 70000 FB4 200000 FB5 50000; param capacity := FB1 3000 FB2 2000 FB3 3000 FB4 2500 FB5 1000; param demand := SD01 581 SD02 524 SD03 386 SD04 195 SD05 851 SD06 720 SD07 164 SD08 78 SD09 126 SD10 390 SD11 530 SD12 998 SD13 320 SD14 56 SD15 418 SD16 101 SD17 285 SD18 280 SD19 350 SD20 361 SD21 343 SDITPJHI 257 SDITDARUN 79 SDITNAMALIYAH 87 SDITNILMI 307 SMP13 635 SMP19 727 SMP23 615 SMP8 1215 SMPDARUN 73 SMPITALAZHAR 210 SMPPJHI 80 SMA7 1055 SMAITALAZHAR 23 SMK5 1272 SMKSADZKIYA 434 SMKSDUTAB 210; # Demand per school per time period param distance : FB1 FB2 FB3 FB4 FB5 := SD01 5.4 0.95 3.6 9.5 13 SD02 8.8 4.9 0.2 5.8 9.4 SD03 11 6.9 2.19 3.8 7.4 SD04 15 12 6.8 0.91 3.4 SD05 0.74 3.1 7.8 14 17 SD06 3.5 0.81 5.7 12 15 SD07 14 9.7 4.7 1.2 4.9 SD08 18 14 9.6 3.7 0.02 SD09 15 12 6.5 0.69 3.3 SD10 4.4 0.95 4.5 10 14 SD11 6.2 2.12 3.5 9.4 13 SD12 0.61 4.3 9 15 19 SD13 4.8 0.85 4.5 10 14 SD14 21 17 13 6.8 3.17 SD15 6.9 3 1.91 7.9 12 SD16 17 13 7.9 1.9 4.5 SD17 12 7.8 3.1 2.85 6.5 SD18 9.9 6.1 1.39 5.2 8.8 SD19 6.2 2.3 3.7 9.6 13 SD20 5.1 1.41 4.8 11 14 SD21 6.9 4.20 8.8 15 18 SDITPJHI 1.63 3.9 8.6 15 18 SDITDARUN 15 11 6.3 1.1 4.8 SDITNAMALIYAH 0.74 4.5 9.26 15.16 18.82 SDITNILMI 0.86 3.5 8.2 14 18 SMP13 13 8.7 4 2.5 6.2 SMP19 9.7 5.7 1.1 5.4 9.1 SMP23 3.6 3.5 8.1 14 18 SMP8 4.0 0.25 4.9 11 15 SMPDARUN 15 11 6.3 1.1 4.8 SMPITALAZHAR 13 9.1 4.4 1.5 5.2 SMPPJHI 1.63 3.9 8.6 15 18 SMA7 7.6 3.7 1.8 7.8 11 SMAITALAZHAR 2.9 5.0 9.7 15.9 19.4 SMK5 10 6.3 1.6 7.1 11 SMKSADZKIYA 7.8 3.8 2.1 8.1 12 SMKSDUTAB 15 11 6 0.85 4.5; param trans_cost:= 1500; param handling_cost := 5000; param processing_cost := G1 500 G2 700 G3 400 G4 200; param nutrient_value : Water Energy Protein Fat Carbohydrate Fibre Calcium Iron Zinc VitA VitB1 VitB2 VitB3 VitB6 VitB12 VitC VitD Folate:= Apple 84.1 68 0.3 0.4 14.9 2 6 0.3 0.02 4.79 0.04 0.01 0.1 0.041 0 5 0 5.46 Bananna 72.9 112 1 0.8 24.3 1.9 20 0.2 0.2 6.08 0.05 0.11 0.1 0.367 0 9 0 23 Beef 66 201 18.8 14 0 0 11 2.8 3.64 167.5 0.08 0.21 6.5 0.44 3.05 0 0 4.9 BeefLiver 69.7 132 19.7 3.2 6 0 7 6.6 4 14153.5 0.26 0.96 5.4 1.08 59.3 31 1 290 Carrot 89.9 43 1 0.6 7.9 1 45 1 0.2 477.96 0.04 0.04 1 0.138 0 18 0 19 Cassava 61.4 156 1 0.3 36.8 0.9 77 1.1 0.1 0 0.06 0.12 0.5 0.088 0 31 0 27 CassavaLeaf 84.4 68 6.2 1.1 7.1 2.4 166 1.3 2.6 455.58 0.04 0.1 1.8 0.34 0 103 0 0 Chicken 55.9 298 18.2 25 0 0 14 1.5 1.5 246.625 0.08 0.16 8.1 0.35 0.31 0 0 4 ChickenEgg 74.3 150 12.4 10.8 0.7 0 86 3 1.1 66.29 0.12 0.38 0.2 0.143 1.29 0 1 143 ChickenLiver 53.4 261 27.4 16.1 1.6 0 118 15.8 0.5 6127.667 0.64 2.94 4.11 0.853 16.58 0 0 588 CoconutMilk 54.9 348 4.2 34.3 5.6 0 14 1.9 1.1 0 0.02 0 0.4 0.05 0 2 0 0 Corn 70.3 131 3.3 1.3 25.1 2.8 2 0.6 0.5 0 0.2 0.1 1.6 0.1 0 6 0 42 DuckEgg 67.7 187 10.9 12.4 7.9 0 64 5.4 1.8 197.1 1.62 0.03 0.1 0.25 5.4 0 5 80 FrenchBean 89.6 45 2.4 0.3 7.2 1.9 101 0.7 0.4 81 0.05 0.4 2.8 0.06 0 11 0 399 FreshMilk 88.1 67 3.2 3.9 4.8 0 115 0.1 0.4 55 0 0.2 0.1 0.1 0.4 1 0 8 KidneyBean 57.2 180 11 2.2 28 2.1 293 3.7 2.9 0.42 0.15 0.34 2.3 0.32 0 0 0 130 LongBean 12.2 364 17.3 1.5 68.6 3.2 163 6.9 0.4 12 0.57 0.21 8.4 0.06 0 2 0 62 Manggo 87.4 55 0.7 0.2 11.2 2.7 13 0.2 0.1 723.33 0.08 0.02 0.5 0.134 0 30 0 43 Melon 83.8 36 0.6 0.4 7.2 0.5 0 0 0 0 0 0 10 0 0 0.1 0 21 MilkFish 45.3 296 17.1 20.3 11.3 0 1422 1.9 0 22.67 0.14 0 0 0 0 69.09 0 16 Mungbean 15.5 347 22.9 1.5 56.8 7.5 223 7.5 2.7 16.17 0.46 0.15 1.5 0.1 0 10 0 625 Mushrooms 93.7 41 3.8 0.6 0.9 8.2 3 1.7 0.1 0 0.1 0.14 0.2 0.1 0 5 2 17 Orange 87.2 53 0.9 0.2 11.2 1.4 33 0.4 0.22 9.79 0.08 0.03 0.2 0.06 0 49 0 30 Papaya 86.7 53 0.5 0.1 12.2 0.5 23 1.7 0.1 228 0.04 0.05 0.3 0.019 0 78 0 53.65 Pineapple 88.9 46 0.6 0.3 9.9 0.6 22 0.9 0.1 4.58 0.02 0.05 0.2 0.11 0 22 0 18 Potato 83.4 65 2.1 0.2 13.5 0.5 63 0.7 0.4 0 0.09 0.07 1.3 0.20 0 21 0 16.5 QuailEgg 79.8 112 10.7 7 1.6 0 65 3.5 1.47 163.33 0.13 0.65 0.1 0.15 1.58 0 5 49 Rambutan 80.5 79 0.9 0.1 18.1 1.1 16 0.5 0.1 0 0 0.06 0.4 0.1 0 58 0 8 Rice 56.7 174 3 0.3 39.8 0 25 0.4 1.2 0 0.05 0.02 0.7 0.02 0 0 0 23 Shrimp 75 86 21 0.2 0.1 0 136 8 1.3 18.33 0.01 0.39 3.6 0.1 1.19 0 3 3 SnakeFruit 78 87 0.4 0.1 20.9 0.4 28 4.2 0 4 0.04 0.2 2.4 1 0 2 0 0 Spinach 94.5 20 0.9 0.4 2.9 0.7 166 3.5 0.6 96 0.04 0.1 1 0.54 0 41 0 194 Tomato 92.9 32 1.3 0.5 4.7 1.5 8 0.6 0.2 108.71 0.06 0.06 0.4 0.08 0 34 0 29 Watercress 93.3 24 3.1 0.2 2.2 0.7 95 2.4 0.1 204 0.09 0.13 0.7 0.13 0 56 0 9 WaterMelon 92.1 3.2 0.5 0.2 6.9 0.3 7 0.2 0.1 21.25 0.05 0.04 0.2 0.045 0 6 0 3 WaterSpinach 91.0 40 3.4 0.7 3.9 2 67 2.3 0.5 345 0.07 0.36 2 0.10 0 17 0 57 Yam 69.6 118 1.5 0.2 28 4.1 17 0.5 0.24 7 0.112 0.032 0.552 0.293 0 17.1 0 23 KembungFish 73.5 111 19.04 0.9 4.8 0 68 7.3 0.6 0 0.03 0.2 7.3 0.05 12 0 16.1 1 PatinFish 74.4 132 17 6.6 1.1 0 31 1.6 8 0 0.2 0.03 1.7 0.116 4.1 0 9 10 LeleFish 80.36 95 16 2.82 0 0 14 0.25 0.25 70 0.21 0.072 1.907 0.116 4.1 0.7 12.5 10 GabusFish 79.6 80 16.2 0.5 2.6 0 170 0.1 0.4 335 0.4 0.2 0.1 0 4.1 0 4.6 10 TongkolFish 74.4 100 13.7 1.5 8 0 92 1.7 1.6 181 0.35 0.03 6.6 0.12 12 0 0 5.18 TunaFish 62.3 132 28.2 1.29 0 0 37 1.6 1.05 18 0.24 0.25 8.65 1 0 0 82 5.18 TeriFish 73.37 131 29 10 0 0 232 4.63 2.44 12 0.055 0.256 14.024 0.143 0.62 0 69 13 Cauliflower 92.2 25 1.28 0.1 5.8 3.4 40 0.47 0.18 5 0.4 0.1 0.51 0.18 0 48.2 0 43 DragonFruit 84 57 0.36 0.14 15.2 3.1 9 0.18 0.1 1 0.012 0.026 0.16 0.029 0 4.3 0 4.04 Pears 84.1 63 0.38 0.16 15.1 3.1 8 0.17 0.07 1 0.012 0.026 0.16 0.029 0 4.3 0 4.04 SiamesePumpkin 94.24 19 0.8 0.1 4.5 1.7 17 0.3 0.74 0 0.025 0.029 0.47 0.076 0 7.7 0 93 Broccoli 89.3 34 2.82 0.37 6.64 2.6 47 0.73 0.41 31 0.071 0.12 0.64 0.18 0 89.2 0 65; param nutrient_requirement : SD SMP SMA:= Water 1850 2100 2300 Energy 2000 2400 2650 Protein 55 70 75 Fat 65 80 85 Carbohydrate 300 350 400 Fibre 28 34 70 Calcium 1200 1200 1200 Iron 8 11 11 Zinc 8 11 11 VitA 600 600 700 VitB1 1.1 1.2 1.2 VitB2 1.3 1.3 1.3 VitB3 12 16 16 VitB6 1.3 1.3 1.3 VitB12 3.5 4.0 4.0 VitC 50 75 90 VitD 15 15 15 Folate 400 400 400; param cost_commodity := Apple 4000 Bananna 1000 Beef 15000 BeefLiver 10000 Carrot 3000 Cassava 2000 CassavaLeaf 1500 Chicken 7000 ChickenEgg 2000 ChickenLiver 5000 CoconutMilk 3000 Corn 8000 DuckEgg 3000 FrenchBean 5000 FreshMilk 10000 KidneyBean 5000 LongBean 3000 Manggo 3500 Melon 1500 MilkFish 5000 Mungbean 4000 Mushrooms 5000 Orange 7000 Papaya 3000 Pineapple 2000 Potato 3500 QuailEgg 5000 Rambutan 5000 Rice 1200 Shrimp 10000 SnakeFruit 2000 Spinach 4000 Tomato 1000 Watercress 8000 WaterMelon 1500 WaterSpinach 1000 Yam 1200 KembungFish 3500 PatinFish 3000 LeleFish 3000 GabusFish 6000 TongkolFish 3000 TunaFish 5000 TeriFish 2000 Cauliflower 1500 DragonFruit 2000 Pears 2500 SiamesePumpkin 600 Broccoli 3000;
# Reset and load files
reset;
# Load the model and data files
model budget.mod;
data budget.dat;
# Set solver
option solver gurobi;
# Solve the problem
solve;
# Option to omit zero rows in output
option omit_zero_rows 1;
# Display key decision variables
display y, z, x, unfulfilled_demand, ratio_commodity;Gurobi 12.0.0: Gurobi 12.0.0: infeasible or unbounded problem. Set dualreductions=0 or iis=1 for definitive answer.
0 simplex iterations
suffix unbdd OUT;
suffix dunbdd OUT;
y [*] :=
;
: z x :=
;
: unfulfilled_demand ratio_commodity :=
;
Upvotes: 0
Views: 47
Reputation: 21597
In your model, the first 4 categories of constraints can't be infeasible (all 0 except unfulfilled_demand is a feasible solution). The model can't be unbounded since you have nonnegative costs multiplied by nonnegative variables. That leaves only the minimum distribution and nutrient requirements as culprits. I would add penalty variables like unfulfilled_demand you have in the Demand Fulfillment constraints and see with high costs to identify the problem.
sum {b in B} x[s, b] + distribution_shortfall[s] >= demand[s] * 0.7;
sum {k in K} nutrient_value[k, n] * ratio_commodity[k] * sum {s in S, b in B} x[s, b] + nutrient_shortfall[n, c] >= nutrient_requirement[n, c]
It may be a good idea to keep these extra variables in the model because they will help you identify the source of infeasibility in cases where the data is bad. One positive side-effect of building optimization models is that they help identify bad data in a way that standard data integrity constraints can't. Optimization models will often exploit bad data to give unreasonably good solutions, or report infeasibility like in your case.
Upvotes: 0
Reputation: 77
Using iis is definitively a good choice if the solver you are using has that option.
Quick suggestion, have you tried dropping constraints to figure out which one is not being satisfied? (I assume it's infeasibility not unbound problem). Constraints like Demand Fulfillment, Minimum distribution and Nutrient requirements might have data that produce this infeasibility. Without them, a trivial solution would be possible, right?
Any solver output or data for the problem?
Upvotes: 1