CO-Bench commited on
Commit
fc707cf
·
verified ·
1 Parent(s): 8e62344

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .DS_Store +0 -0
  2. .gitattributes +88 -0
  3. CFLP/.DS_Store +0 -0
  4. CFLP/config.py +218 -0
  5. CFLP/easy_test_instances/i1000_1.plc +3 -0
  6. CFLP/easy_test_instances/i1000_10.plc +3 -0
  7. CFLP/easy_test_instances/i1000_11.plc +3 -0
  8. CFLP/easy_test_instances/i1000_12.plc +3 -0
  9. CFLP/easy_test_instances/i1000_13.plc +3 -0
  10. CFLP/easy_test_instances/i1000_14.plc +3 -0
  11. CFLP/easy_test_instances/i1000_15.plc +3 -0
  12. CFLP/easy_test_instances/i1000_16.plc +3 -0
  13. CFLP/easy_test_instances/i1000_17.plc +3 -0
  14. CFLP/easy_test_instances/i1000_18.plc +3 -0
  15. CFLP/easy_test_instances/i1000_19.plc +3 -0
  16. CFLP/easy_test_instances/i1000_2.plc +3 -0
  17. CFLP/easy_test_instances/i1000_20.plc +3 -0
  18. CFLP/easy_test_instances/i1000_3.plc +3 -0
  19. CFLP/easy_test_instances/i1000_4.plc +3 -0
  20. CFLP/easy_test_instances/i1000_5.plc +3 -0
  21. CFLP/easy_test_instances/i1000_6.plc +3 -0
  22. CFLP/easy_test_instances/i1000_7.plc +3 -0
  23. CFLP/easy_test_instances/i1000_8.plc +3 -0
  24. CFLP/easy_test_instances/i1000_9.plc +3 -0
  25. CFLP/hard_test_instances/p2000-2000-31.plc +3 -0
  26. CFLP/hard_test_instances/p2000-2000-32.plc +3 -0
  27. CFLP/hard_test_instances/p2000-2000-33.plc +3 -0
  28. CFLP/hard_test_instances/p2000-2000-34.plc +3 -0
  29. CFLP/hard_test_instances/p2000-2000-35.plc +3 -0
  30. CFLP/hard_test_instances/p2000-2000-36.plc +3 -0
  31. CFLP/hard_test_instances/p2000-2000-37.plc +3 -0
  32. CFLP/hard_test_instances/p2000-2000-38.plc +3 -0
  33. CFLP/hard_test_instances/p2000-2000-39.plc +3 -0
  34. CFLP/hard_test_instances/p2000-2000-40.plc +3 -0
  35. CFLP/hard_test_instances/p2000-2000-41.plc +3 -0
  36. CFLP/hard_test_instances/p2000-2000-42.plc +3 -0
  37. CFLP/hard_test_instances/p2000-2000-43.plc +3 -0
  38. CFLP/hard_test_instances/p2000-2000-44.plc +3 -0
  39. CFLP/hard_test_instances/p2000-2000-45.plc +3 -0
  40. CFLP/hard_test_instances/p2000-2000-46.plc +3 -0
  41. CFLP/hard_test_instances/p2000-2000-47.plc +3 -0
  42. CFLP/hard_test_instances/p2000-2000-48.plc +3 -0
  43. CFLP/hard_test_instances/p2000-2000-49.plc +3 -0
  44. CFLP/hard_test_instances/p2000-2000-50.plc +3 -0
  45. CFLP/hard_test_instances/p2000-2000-51.plc +3 -0
  46. CFLP/hard_test_instances/p2000-2000-52.plc +3 -0
  47. CFLP/hard_test_instances/p2000-2000-53.plc +3 -0
  48. CFLP/hard_test_instances/p2000-2000-54.plc +3 -0
  49. CFLP/hard_test_instances/p2000-2000-55.plc +3 -0
  50. CFLP/hard_test_instances/p2000-2000-56.plc +3 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
.gitattributes CHANGED
@@ -57,3 +57,91 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ CFLP/easy_test_instances/i1000_1.plc filter=lfs diff=lfs merge=lfs -text
61
+ CFLP/easy_test_instances/i1000_10.plc filter=lfs diff=lfs merge=lfs -text
62
+ CFLP/easy_test_instances/i1000_11.plc filter=lfs diff=lfs merge=lfs -text
63
+ CFLP/easy_test_instances/i1000_12.plc filter=lfs diff=lfs merge=lfs -text
64
+ CFLP/easy_test_instances/i1000_13.plc filter=lfs diff=lfs merge=lfs -text
65
+ CFLP/easy_test_instances/i1000_14.plc filter=lfs diff=lfs merge=lfs -text
66
+ CFLP/easy_test_instances/i1000_15.plc filter=lfs diff=lfs merge=lfs -text
67
+ CFLP/easy_test_instances/i1000_16.plc filter=lfs diff=lfs merge=lfs -text
68
+ CFLP/easy_test_instances/i1000_17.plc filter=lfs diff=lfs merge=lfs -text
69
+ CFLP/easy_test_instances/i1000_18.plc filter=lfs diff=lfs merge=lfs -text
70
+ CFLP/easy_test_instances/i1000_19.plc filter=lfs diff=lfs merge=lfs -text
71
+ CFLP/easy_test_instances/i1000_2.plc filter=lfs diff=lfs merge=lfs -text
72
+ CFLP/easy_test_instances/i1000_20.plc filter=lfs diff=lfs merge=lfs -text
73
+ CFLP/easy_test_instances/i1000_3.plc filter=lfs diff=lfs merge=lfs -text
74
+ CFLP/easy_test_instances/i1000_4.plc filter=lfs diff=lfs merge=lfs -text
75
+ CFLP/easy_test_instances/i1000_5.plc filter=lfs diff=lfs merge=lfs -text
76
+ CFLP/easy_test_instances/i1000_6.plc filter=lfs diff=lfs merge=lfs -text
77
+ CFLP/easy_test_instances/i1000_7.plc filter=lfs diff=lfs merge=lfs -text
78
+ CFLP/easy_test_instances/i1000_8.plc filter=lfs diff=lfs merge=lfs -text
79
+ CFLP/easy_test_instances/i1000_9.plc filter=lfs diff=lfs merge=lfs -text
80
+ CFLP/hard_test_instances/p2000-2000-31.plc filter=lfs diff=lfs merge=lfs -text
81
+ CFLP/hard_test_instances/p2000-2000-32.plc filter=lfs diff=lfs merge=lfs -text
82
+ CFLP/hard_test_instances/p2000-2000-33.plc filter=lfs diff=lfs merge=lfs -text
83
+ CFLP/hard_test_instances/p2000-2000-34.plc filter=lfs diff=lfs merge=lfs -text
84
+ CFLP/hard_test_instances/p2000-2000-35.plc filter=lfs diff=lfs merge=lfs -text
85
+ CFLP/hard_test_instances/p2000-2000-36.plc filter=lfs diff=lfs merge=lfs -text
86
+ CFLP/hard_test_instances/p2000-2000-37.plc filter=lfs diff=lfs merge=lfs -text
87
+ CFLP/hard_test_instances/p2000-2000-38.plc filter=lfs diff=lfs merge=lfs -text
88
+ CFLP/hard_test_instances/p2000-2000-39.plc filter=lfs diff=lfs merge=lfs -text
89
+ CFLP/hard_test_instances/p2000-2000-40.plc filter=lfs diff=lfs merge=lfs -text
90
+ CFLP/hard_test_instances/p2000-2000-41.plc filter=lfs diff=lfs merge=lfs -text
91
+ CFLP/hard_test_instances/p2000-2000-42.plc filter=lfs diff=lfs merge=lfs -text
92
+ CFLP/hard_test_instances/p2000-2000-43.plc filter=lfs diff=lfs merge=lfs -text
93
+ CFLP/hard_test_instances/p2000-2000-44.plc filter=lfs diff=lfs merge=lfs -text
94
+ CFLP/hard_test_instances/p2000-2000-45.plc filter=lfs diff=lfs merge=lfs -text
95
+ CFLP/hard_test_instances/p2000-2000-46.plc filter=lfs diff=lfs merge=lfs -text
96
+ CFLP/hard_test_instances/p2000-2000-47.plc filter=lfs diff=lfs merge=lfs -text
97
+ CFLP/hard_test_instances/p2000-2000-48.plc filter=lfs diff=lfs merge=lfs -text
98
+ CFLP/hard_test_instances/p2000-2000-49.plc filter=lfs diff=lfs merge=lfs -text
99
+ CFLP/hard_test_instances/p2000-2000-50.plc filter=lfs diff=lfs merge=lfs -text
100
+ CFLP/hard_test_instances/p2000-2000-51.plc filter=lfs diff=lfs merge=lfs -text
101
+ CFLP/hard_test_instances/p2000-2000-52.plc filter=lfs diff=lfs merge=lfs -text
102
+ CFLP/hard_test_instances/p2000-2000-53.plc filter=lfs diff=lfs merge=lfs -text
103
+ CFLP/hard_test_instances/p2000-2000-54.plc filter=lfs diff=lfs merge=lfs -text
104
+ CFLP/hard_test_instances/p2000-2000-55.plc filter=lfs diff=lfs merge=lfs -text
105
+ CFLP/hard_test_instances/p2000-2000-56.plc filter=lfs diff=lfs merge=lfs -text
106
+ CFLP/hard_test_instances/p2000-2000-57.plc filter=lfs diff=lfs merge=lfs -text
107
+ CFLP/hard_test_instances/p2000-2000-58.plc filter=lfs diff=lfs merge=lfs -text
108
+ CFLP/hard_test_instances/p2000-2000-59.plc filter=lfs diff=lfs merge=lfs -text
109
+ CFLP/hard_test_instances/p2000-2000-60.plc filter=lfs diff=lfs merge=lfs -text
110
+ MDS/easy_test_instances/exact_057.gr filter=lfs diff=lfs merge=lfs -text
111
+ MDS/easy_test_instances/exact_063.gr filter=lfs diff=lfs merge=lfs -text
112
+ MDS/easy_test_instances/exact_066.gr filter=lfs diff=lfs merge=lfs -text
113
+ MDS/easy_test_instances/exact_072.gr filter=lfs diff=lfs merge=lfs -text
114
+ MDS/easy_test_instances/exact_075.gr filter=lfs diff=lfs merge=lfs -text
115
+ MDS/easy_test_instances/exact_088.gr filter=lfs diff=lfs merge=lfs -text
116
+ MDS/easy_test_instances/exact_093.gr filter=lfs diff=lfs merge=lfs -text
117
+ MDS/easy_test_instances/exact_097.gr filter=lfs diff=lfs merge=lfs -text
118
+ MDS/hard_test_instances/heuristic_003.gr filter=lfs diff=lfs merge=lfs -text
119
+ MDS/hard_test_instances/heuristic_015.gr filter=lfs diff=lfs merge=lfs -text
120
+ MDS/hard_test_instances/heuristic_016.gr filter=lfs diff=lfs merge=lfs -text
121
+ MDS/hard_test_instances/heuristic_017.gr filter=lfs diff=lfs merge=lfs -text
122
+ MDS/hard_test_instances/heuristic_019.gr filter=lfs diff=lfs merge=lfs -text
123
+ MDS/hard_test_instances/heuristic_026.gr filter=lfs diff=lfs merge=lfs -text
124
+ MDS/hard_test_instances/heuristic_036.gr filter=lfs diff=lfs merge=lfs -text
125
+ MDS/hard_test_instances/heuristic_037.gr filter=lfs diff=lfs merge=lfs -text
126
+ MDS/hard_test_instances/heuristic_042.gr filter=lfs diff=lfs merge=lfs -text
127
+ MDS/hard_test_instances/heuristic_044.gr filter=lfs diff=lfs merge=lfs -text
128
+ MDS/hard_test_instances/heuristic_049.gr filter=lfs diff=lfs merge=lfs -text
129
+ MDS/hard_test_instances/heuristic_059.gr filter=lfs diff=lfs merge=lfs -text
130
+ MDS/hard_test_instances/heuristic_060.gr filter=lfs diff=lfs merge=lfs -text
131
+ MDS/hard_test_instances/heuristic_065.gr filter=lfs diff=lfs merge=lfs -text
132
+ MDS/hard_test_instances/heuristic_066.gr filter=lfs diff=lfs merge=lfs -text
133
+ MDS/hard_test_instances/heuristic_067.gr filter=lfs diff=lfs merge=lfs -text
134
+ MDS/hard_test_instances/heuristic_074.gr filter=lfs diff=lfs merge=lfs -text
135
+ MDS/hard_test_instances/heuristic_077.gr filter=lfs diff=lfs merge=lfs -text
136
+ MDS/hard_test_instances/heuristic_078.gr filter=lfs diff=lfs merge=lfs -text
137
+ MDS/hard_test_instances/heuristic_097.gr filter=lfs diff=lfs merge=lfs -text
138
+ MIS/easy_test_instances/C2000.5.mis filter=lfs diff=lfs merge=lfs -text
139
+ MIS/easy_test_instances/C4000.5.mis filter=lfs diff=lfs merge=lfs -text
140
+ MIS/easy_test_instances/keller6.mis filter=lfs diff=lfs merge=lfs -text
141
+ STP/easy_test_instances/G106a.stp filter=lfs diff=lfs merge=lfs -text
142
+ STP/easy_test_instances/G305a.stp filter=lfs diff=lfs merge=lfs -text
143
+ STP/easy_test_instances/G306a.stp filter=lfs diff=lfs merge=lfs -text
144
+ STP/easy_test_instances/G307a.stp filter=lfs diff=lfs merge=lfs -text
145
+ TSP/hard_test_instances/E10M.0 filter=lfs diff=lfs merge=lfs -text
146
+ TSP/hard_test_instances/E1M.0 filter=lfs diff=lfs merge=lfs -text
147
+ TSP/hard_test_instances/E3M.0 filter=lfs diff=lfs merge=lfs -text
CFLP/.DS_Store ADDED
Binary file (6.15 kB). View file
 
CFLP/config.py ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DESCRIPTION = '''The Capacitated Facility Location Problem aims to determine which facilities to open and how to allocate portions of customer demands among these facilities in order to minimize total costs. Given a set of potential facility locations, each with a fixed opening cost and capacity limit, and a set of customers with individual demands and associated assignment costs to each facility, the objective is to decide which facilities to open and how to distribute each customer's demand among these open facilities. The allocation must satisfy the constraint that the sum of portions assigned to each customer equals their total demand, and that the total demand allocated to any facility does not exceed its capacity. The optimization seeks to minimize the sum of fixed facility opening costs and the total assignment costs. However, if any solution violates these constraints (i.e., a customer’s demand is not fully satisfied or a warehouse’s capacity is exceeded), then an infitiely large cost is given.'''
2
+
3
+
4
+ def solve(**kwargs):
5
+ """
6
+ Solves the Capacitated Facility Location Problem.
7
+
8
+ Input kwargs:
9
+ - n (int): Number of facilities
10
+ - m (int): Number of customers
11
+ - capacities (list): A list of capacities for each facility
12
+ - fixed_cost (list): A list of fixed costs for each facility
13
+ - demands (list): A list of demands for each customer
14
+ - trans_costs (list of list): A 2D list of transportation costs, where trans_costs[i][j] represents
15
+ the cost of allocating the entire demand of customer j to facility i
16
+
17
+ Note: The input structure should match the output of load_data function.
18
+
19
+ Evaluation Metric:
20
+ The objective is to minimize the total cost, computed as:
21
+ (Sum of fixed costs for all open facilities)
22
+ + (Sum of transportation costs for customer demand allocated from facilities to customers)
23
+ For each customer, the sum of allocations from all facilities must equal the customer's demand.
24
+ For each facility, the total allocated demand across all customers must not exceed its capacity.
25
+ If a solution violates any of these constraints, the solution is considered infeasible and no score is provided.
26
+
27
+ Returns:
28
+ A dictionary with the following keys:
29
+ 'total_cost': (float) The computed objective value (cost) if the solution is feasible;
30
+ otherwise, no score is provided.
31
+ 'facilities_open': (list of int) A list of n integers (0 or 1) indicating whether each facility is closed or open.
32
+ 'assignments': (list of list of float) A 2D list (m x n) where each entry represents the amount of customer i's demand supplied by facility j.
33
+ """
34
+ ## placeholder. You do not need to write anything here.
35
+ # Your function must yield multiple solutions over time, not just return one solution
36
+ # Use Python's yield keyword repeatedly to produce a stream of solutions
37
+ # Each yielded solution should be better than the previous one
38
+ while True:
39
+ yield {
40
+ "total_cost": 0.0,
41
+ "facilities_open": [0] * kwargs["n"],
42
+ "assignments": [[0.0] * kwargs["n"] for _ in range(kwargs["m"])]
43
+ }
44
+
45
+
46
+ def load_data(input_path):
47
+ """Read Capacitated Facility Location Problem instance from a file.
48
+
49
+ New format:
50
+ n, m (n=facilities, m=customers)
51
+ b1, f1 (capacity and fixed cost of facility 1)
52
+ b2, f2
53
+ ...
54
+ bn, fn
55
+ d1, d2, d3, ..., dm (customer demands)
56
+ c11, c12, c13, ..., c1m (allocation costs for facility 1 to all customers)
57
+ c21, c22, c23, ..., c2m
58
+ ...
59
+ cn1, cn2, cn3, ..., cnm
60
+ """
61
+ # Read all numbers from the file
62
+ with open(input_path, 'r') as f:
63
+ content = f.read()
64
+ # Extract all numbers, ignoring whitespace and empty lines
65
+ all_numbers = [num for num in content.split() if num.strip()]
66
+
67
+ pos = 0 # Position in the numbers list
68
+
69
+ # Parse dimensions: n (facilities), m (customers)
70
+ n = int(all_numbers[pos])
71
+ pos += 1
72
+ m = int(all_numbers[pos])
73
+ pos += 1
74
+
75
+ # Parse facility data: capacity, fixed cost
76
+ capacities = []
77
+ fixed_costs = []
78
+ for _ in range(n):
79
+ if pos + 1 < len(all_numbers):
80
+ capacities.append(float(all_numbers[pos]))
81
+ pos += 1
82
+ fixed_costs.append(float(all_numbers[pos]))
83
+ pos += 1
84
+
85
+ # Parse customer demands
86
+ demands = []
87
+ for _ in range(m):
88
+ if pos < len(all_numbers):
89
+ demands.append(float(all_numbers[pos]))
90
+ pos += 1
91
+
92
+ # Parse transportation costs
93
+ trans_costs = []
94
+ for _ in range(n):
95
+ facility_costs = []
96
+ for _ in range(m):
97
+ if pos < len(all_numbers):
98
+ facility_costs.append(float(all_numbers[pos]))
99
+ pos += 1
100
+ trans_costs.append(facility_costs)
101
+
102
+ # Verify that we have the expected amount of data
103
+ expected_numbers = 2 + 2 * n + m + n * m
104
+ if len(all_numbers) < expected_numbers:
105
+ print(f"Warning: File might be incomplete. Expected {expected_numbers} numbers, found {len(all_numbers)}.")
106
+
107
+ case = {"n": m, "m": m, "capacities": capacities, "fixed_cost": fixed_costs, "demands": demands,
108
+ 'trans_costs': trans_costs}
109
+
110
+ return [case]
111
+
112
+
113
+ def eval_func(n, m, capacities, fixed_cost, demands, trans_costs, facilities_open, assignments, **kwargs):
114
+ """
115
+ Evaluates the solution for the Capacitated facility Location Problem with Splittable Customer Demand,
116
+ using a weighted average cost for each customer.
117
+
118
+ For each customer:
119
+ - The sum of allocations across facilities must equal the customer's demand.
120
+ - The assignment cost is computed as the weighted average of the per-unit costs,
121
+ i.e., for each facility i, the fraction of demand allocated from i multiplied by its cost.
122
+ - No positive allocation is allowed for a facility that is closed.
123
+
124
+ Additionally, for each facility:
125
+ - The total allocated demand must not exceed its capacity.
126
+
127
+ The total cost is computed as:
128
+ (Sum of fixed costs for all open facilities)
129
+ + (Sum over customers of the weighted average assignment cost)
130
+
131
+ Input Parameters:
132
+ - n: Number of facilities (int)
133
+ - m: Number of customers (int)
134
+ - capacities: List of capacities for each facility (list of float)
135
+ - fixed_cost: List of fixed costs for each facility (list of float)
136
+ - demands: List of demands for each customer (list of float)
137
+ - trans_costs: List of lists representing transportation costs from facilities to customers
138
+ - facilities_open: List of n integers (0 or 1) indicating whether each facility is closed or open
139
+ - assignments: List of m lists (each of length n) where assignments[j][i] represents the amount of
140
+ customer j's demand allocated to facility i
141
+ - kwargs: Other parameters (not used here)
142
+
143
+ Returns:
144
+ A floating-point number representing the total cost if the solution is feasible.
145
+
146
+ Raises:
147
+ Exception: If any of the following conditions are violated:
148
+ - The sum of allocations for any customer does not equal its demand.
149
+ - Any positive allocation is made to a closed facility.
150
+ - Any facility's total allocated demand exceeds its capacity.
151
+ """
152
+ computed_total_cost = 0.0
153
+
154
+ # Add fixed costs for open facilities.
155
+ for i in range(n):
156
+ if facilities_open[i] == 1:
157
+ computed_total_cost += fixed_cost[i]
158
+
159
+ # Evaluate assignment cost for each customer as a weighted average.
160
+ for j in range(m):
161
+ customer_demand = demands[j]
162
+ allocated_amount = sum(assignments[j])
163
+ if abs(allocated_amount - customer_demand) > 1e-6:
164
+ raise Exception(
165
+ f"Customer {j} demand violation: total assigned amount {allocated_amount} does not equal demand {customer_demand}."
166
+ )
167
+ weighted_cost = 0.0
168
+ for i in range(n):
169
+ allocation = assignments[j][i]
170
+ if allocation < 0:
171
+ raise Exception(
172
+ f"Customer {j} has a negative allocation {allocation} for facility {i}."
173
+ )
174
+ if allocation > 0 and facilities_open[i] != 1:
175
+ raise Exception(
176
+ f"Customer {j} has allocation {allocation} for facility {i}, which is closed."
177
+ )
178
+ # Compute fraction of the customer's demand supplied from facility i.
179
+ fraction = allocation / customer_demand if customer_demand > 0 else 0.0
180
+ weighted_cost += fraction * trans_costs[i][j]
181
+ # Add the weighted cost (applied once per customer).
182
+ computed_total_cost += weighted_cost
183
+
184
+ # Compute total demand allocated to each facility and check capacity constraints.
185
+ assigned_demand = [0.0] * n
186
+ for i in range(n):
187
+ for j in range(m):
188
+ assigned_demand[i] += assignments[j][i]
189
+ for i in range(n):
190
+ if assigned_demand[i] > capacities[i] + 1e-6:
191
+ excess = assigned_demand[i] - capacities[i]
192
+ raise Exception(
193
+ f"Facility {i} exceeds its capacity by {excess} units."
194
+ )
195
+
196
+ return computed_total_cost
197
+
198
+
199
+ def norm_score(results):
200
+ optimal_scores = {'easy_test_instances/i1000_10.plc': [27186.996215], 'easy_test_instances/i1000_1.plc': [49509.816283], 'easy_test_instances/i1000_11.plc': [22180.338324], 'easy_test_instances/i1000_13.plc': [22648.245244], 'easy_test_instances/i1000_17.plc': [21188.891031], 'easy_test_instances/i1000_14.plc': [22312.017885], 'easy_test_instances/i1000_18.plc': [20713.433821], 'easy_test_instances/i1000_16.plc': [21331.816412], 'easy_test_instances/i1000_15.plc': [22627.627082], 'easy_test_instances/i1000_19.plc': [20537.451973], 'easy_test_instances/i1000_12.plc': [22160.396492], 'easy_test_instances/i1000_20.plc': [21560.863859], 'easy_test_instances/i1000_3.plc': [47202.64124], 'easy_test_instances/i1000_5.plc': [50743.542247], 'easy_test_instances/i1000_2.plc': [50688.099361], 'easy_test_instances/i1000_6.plc': [27823.848194], 'easy_test_instances/i1000_4.plc': [48868.545165], 'easy_test_instances/i1000_7.plc': [27252.327368], 'easy_test_instances/i1000_9.plc': [26857.093992], 'easy_test_instances/i1000_8.plc': [27375.377404]}
201
+ optimal_scores = optimal_scores | {'hard_test_instances/p2000-2000-34.plc': [1916455.670809467], 'hard_test_instances/p2000-2000-39.plc': [1153261.587371967], 'hard_test_instances/p2000-2000-36.plc': [1139219.595105013], 'hard_test_instances/p2000-2000-32.plc': [1953642.449903901], 'hard_test_instances/p2000-2000-33.plc': [1918045.972964212], 'hard_test_instances/p2000-2000-37.plc': [1136995.540252458], 'hard_test_instances/p2000-2000-31.plc': [1929201.669659948], 'hard_test_instances/p2000-2000-38.plc': [1149261.691855482], 'hard_test_instances/p2000-2000-35.plc': [1899636.376243865], 'hard_test_instances/p2000-2000-40.plc': [1154591.397009221], 'hard_test_instances/p2000-2000-41.plc': [751876.874001226], 'hard_test_instances/p2000-2000-42.plc': [749780.77133064], 'hard_test_instances/p2000-2000-43.plc': [763162.335598751], 'hard_test_instances/p2000-2000-44.plc': [787097.341066275], 'hard_test_instances/p2000-2000-45.plc': [762175.878180943], 'hard_test_instances/p2000-2000-46.plc': [281246.845669752], 'hard_test_instances/p2000-2000-47.plc': [272707.740258233], 'hard_test_instances/p2000-2000-49.plc': [274280.626885327], 'hard_test_instances/p2000-2000-48.plc': [276216.104935007], 'hard_test_instances/p2000-2000-50.plc': [274298.079036553], 'hard_test_instances/p2000-2000-58.plc': [158310.511106569], 'hard_test_instances/p2000-2000-57.plc': [157319.490628803], 'hard_test_instances/p2000-2000-51.plc': [194138.93227269], 'hard_test_instances/p2000-2000-60.plc': [155528.26183311], 'hard_test_instances/p2000-2000-56.plc': [161350.609996602], 'hard_test_instances/p2000-2000-59.plc': [158712.647978297], 'hard_test_instances/p2000-2000-52.plc': [194518.3], 'hard_test_instances/p2000-2000-53.plc': [195329.6], 'hard_test_instances/p2000-2000-54.plc': [198441.2], 'hard_test_instances/p2000-2000-55.plc': [196469.246795541]}
202
+ optimal_scores = optimal_scores | {'valid_instances/cflp_corn_n100_m100_r5.0_11.txt': [17769.328224917], 'valid_instances/cflp_corn_n100_m100_r5.0_18.txt': [17840.680486713], 'valid_instances/cflp_corn_n100_m100_r5.0_19.txt': [16677.981827268], 'valid_instances/cflp_corn_n100_m100_r5.0_17.txt': [17536.698901833], 'valid_instances/cflp_corn_n100_m100_r5.0_1.txt': [17769.059032386], 'valid_instances/cflp_corn_n100_m100_r5.0_4.txt': [18555.250515996], 'valid_instances/cflp_corn_n100_m100_r5.0_15.txt': [17787.11820802], 'valid_instances/cflp_corn_n100_m100_r5.0_2.txt': [17458.209008233], 'valid_instances/cflp_corn_n100_m100_r5.0_3.txt': [18172.936618284], 'valid_instances/cflp_corn_n100_m100_r5.0_7.txt': [17305.736933955], 'valid_instances/cflp_corn_n100_m100_r5.0_10.txt': [18264.241302152], 'valid_instances/cflp_corn_n100_m100_r5.0_9.txt': [16846.038360034], 'valid_instances/cflp_corn_n100_m100_r5.0_20.txt': [18174.252379047], 'valid_instances/cflp_corn_n100_m100_r5.0_6.txt': [17316.344512835], 'valid_instances/cflp_corn_n100_m100_r5.0_5.txt': [17202.336476137], 'valid_instances/cflp_corn_n100_m100_r5.0_13.txt': [18670.213542081], 'valid_instances/cflp_corn_n100_m100_r5.0_16.txt': [18594.255562191], 'valid_instances/cflp_corn_n100_m100_r5.0_8.txt': [16122.550826763], 'valid_instances/cflp_corn_n100_m100_r5.0_12.txt': [18496.120911648], 'valid_instances/cflp_corn_n100_m100_r5.0_14.txt': [18890.400869194]}
203
+
204
+ normed = {}
205
+ for case, (scores, error_message) in results.items():
206
+ if case not in optimal_scores:
207
+ continue # Skip if there's no optimal score defined.
208
+ optimal_list = optimal_scores[case]
209
+ normed_scores = []
210
+ # Compute normalized score for each index.
211
+ for idx, score in enumerate(scores):
212
+ if isinstance(score, (int, float)):
213
+ normed_scores.append(1 - abs(score - optimal_list[idx]) / max(score, optimal_list[idx]))
214
+ else:
215
+ normed_scores.append(score)
216
+ normed[case] = (normed_scores, error_message)
217
+
218
+ return normed
CFLP/easy_test_instances/i1000_1.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcdc6cd8ea3a8c06c94f6afd736d41589560fa7b04fa2a549e2ecc4da4c5b17d
3
+ size 11999793
CFLP/easy_test_instances/i1000_10.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:323a618f71e7f4d907a582ef7515a43e55672799f70f6f4f8089a9ed49f8c112
3
+ size 12047862
CFLP/easy_test_instances/i1000_11.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:effeacc00c836b5b7f7def445ee53624fb6c3894948cced84a70de51c30aacd4
3
+ size 12039720
CFLP/easy_test_instances/i1000_12.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e1ba8504d4218c727972f171a77fed1c3302d19e589437f5296b57471fda4d1
3
+ size 12031654
CFLP/easy_test_instances/i1000_13.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b421dc38304efcba0b69d4cc152fc308852455f3b265a18f9e3303c560b7f44a
3
+ size 12057589
CFLP/easy_test_instances/i1000_14.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a082d135a78d7b4e3da15994122ea5130ad3b3d16aef881fc4e733e0f34424e
3
+ size 12037811
CFLP/easy_test_instances/i1000_15.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c5007f393aa51b980195c3bc2ab15bef5460e031ea33fe6e4f56b2858eacc43
3
+ size 12067949
CFLP/easy_test_instances/i1000_16.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f46ee3e099e933c621416e889cebc769c65c2c5e244851bd65de5b00f5ffe8b
3
+ size 11970779
CFLP/easy_test_instances/i1000_17.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd4f802cb5d24ddccf209139d7630f013ef25ded032a23afeccde3674ee485da
3
+ size 12055998
CFLP/easy_test_instances/i1000_18.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:061054f4469f1261b849afc59192bc782c87643dc225c7afc18bc9d7f7393890
3
+ size 12056330
CFLP/easy_test_instances/i1000_19.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6210a0f34411f645a22b88d30511eea322e7a6636d589e46f83cc26692e513e7
3
+ size 12053526
CFLP/easy_test_instances/i1000_2.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d867223571246c922e6aa02ef81c1e2e6ca39789c6f7a8313194abbbbb02b8b
3
+ size 12033901
CFLP/easy_test_instances/i1000_20.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7257eae6b223b98bf523239b188a0c22fe9bfd4c647fd64e489439f4fef839c5
3
+ size 12060673
CFLP/easy_test_instances/i1000_3.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee48c47060344a6f7f64ea7259fcaa09e47f04fc476b139df63cf6975162d4ba
3
+ size 12090504
CFLP/easy_test_instances/i1000_4.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b857a8d2e05d95e5ef54d7cb336ef07022e482ed3362b4e7a63a7a982dbdd097
3
+ size 12032861
CFLP/easy_test_instances/i1000_5.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:780966a4101f82d7aa3caa41732a51745f3edbc5a35a3afb1c96a2c4e2b99f09
3
+ size 12068533
CFLP/easy_test_instances/i1000_6.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53f92c7027fb2f17fa5d6d60f5fd77a57790dfb4b82aa25eac12e0e819f6d3ed
3
+ size 12087217
CFLP/easy_test_instances/i1000_7.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38194a0edad865aeaa2c5d2ab26e8c513b4e9195e2136a8b1af181c7f3db6a29
3
+ size 12034443
CFLP/easy_test_instances/i1000_8.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b779505335a332ed98d337179e94d7fa23dcddc6e7c73532721e23659fea7ce4
3
+ size 12028972
CFLP/easy_test_instances/i1000_9.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:570679dc5d37cd45d8593ab08c9ae6d263e8ccd937669fa9f629bc8ba34fc258
3
+ size 11984555
CFLP/hard_test_instances/p2000-2000-31.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00c4a12569026fdba5e069a7e7ed4daa7cff6f692e9d69097990e0242175168f
3
+ size 51307887
CFLP/hard_test_instances/p2000-2000-32.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2f30494f8e85982e3144194bd14924ade4551df42044c74390002af9c5fc8d5
3
+ size 51339346
CFLP/hard_test_instances/p2000-2000-33.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6398c9c008f99a5d1e5c89e7711c977008ca8810a5be7f4cd984d28e5c5392a8
3
+ size 51224525
CFLP/hard_test_instances/p2000-2000-34.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98fad64475f40730a67ad59c52eb7ffc8907e4ba4bb2b6240b2d20c5d844f6eb
3
+ size 51233346
CFLP/hard_test_instances/p2000-2000-35.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89331e1e29fbd309a17628aac10ab4b49290aed1364a6ffc4a9d1df4a458a175
3
+ size 51234292
CFLP/hard_test_instances/p2000-2000-36.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b8936e1273d50d9d0038cdd762777b93424c1e3f66d4a3d0b203fa01ad11f18
3
+ size 51270902
CFLP/hard_test_instances/p2000-2000-37.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdc54d10113c24e7ba14b06b12272f59301614b481909e0290f7a08be457d914
3
+ size 51339198
CFLP/hard_test_instances/p2000-2000-38.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d827aef603b0e201ac6491779623d0d095fe6bee0fcbf75aee5c5195f1db57f
3
+ size 51224708
CFLP/hard_test_instances/p2000-2000-39.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b648299acecc965d792cc67a95a63d652630bab5847397b6c7446c20a563fb8f
3
+ size 51309366
CFLP/hard_test_instances/p2000-2000-40.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5a857b1e0d0ce3717e82034db75c05382880991994ce0855ad0f15a0146e11b
3
+ size 51354988
CFLP/hard_test_instances/p2000-2000-41.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a8590ce8bf22f16d96c8e07fc10968ddae16ae1c164eb1fda671d183750e2df
3
+ size 51323405
CFLP/hard_test_instances/p2000-2000-42.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:053cccd088e7e13e1eb264aa5d5997a482986ded3d90c6aa97deab45adccf92a
3
+ size 51233541
CFLP/hard_test_instances/p2000-2000-43.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f5260eacb67725a5537a4d90eb0dd4628d0a9790c9d69116857f1dc8e9469cf
3
+ size 51314871
CFLP/hard_test_instances/p2000-2000-44.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a51edc7e30463ba04d08760d8e392d0666eadf733485f5d7998a4462dda358ae
3
+ size 51309830
CFLP/hard_test_instances/p2000-2000-45.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b54318c3179007edb3c4f873a03a63afbc2d1ad584c01b0eb643ebb163b0d258
3
+ size 51298407
CFLP/hard_test_instances/p2000-2000-46.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:440a1bff5e3112f3c4b2472b08a03fc37cfc85f06439df739636809e2ea09445
3
+ size 51371163
CFLP/hard_test_instances/p2000-2000-47.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6571c67f6668996682b7687cfcfa9289adbc01c01d8f46018c309840445a4c83
3
+ size 51233004
CFLP/hard_test_instances/p2000-2000-48.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d188b9a7b9279ea80d262b7871bdf39cb87b1334b4743b315ab33964e41bd56
3
+ size 51172921
CFLP/hard_test_instances/p2000-2000-49.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71c3ed5995aebe27638fed1fcc67ced637fe4ee7b70aa9e64d47fc0c9bf37fec
3
+ size 51237867
CFLP/hard_test_instances/p2000-2000-50.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6155e0dd597148faaf397035dca40060fc3457a943471d06b5950a13158b4037
3
+ size 51268394
CFLP/hard_test_instances/p2000-2000-51.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:048d069413187c08e8a2bfd034ae8da23ab81d537bea9f8b552a4d7532dbc8bc
3
+ size 51313237
CFLP/hard_test_instances/p2000-2000-52.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68a7badee6fb3d536a9ca03bbee42205c65a01afe46f9ab47def84924fc7d103
3
+ size 51230618
CFLP/hard_test_instances/p2000-2000-53.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb7c57a7ff91718ab12b7621594480c00e5cc37e66f46db7d92a0f0337c9b7c4
3
+ size 51245240
CFLP/hard_test_instances/p2000-2000-54.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:856be15eb96c367bca181211ec47d7eed6c0437b3f23ac805de2a0eeb3269dde
3
+ size 51319470
CFLP/hard_test_instances/p2000-2000-55.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c200dfaf125842e211a38c43c4b0285b4a556429d83c9135677e9e36f36398a
3
+ size 51327045
CFLP/hard_test_instances/p2000-2000-56.plc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1946d27fa335f18467e8089fb56e1c9675095a70719b161fd8579a0ddd555123
3
+ size 51333963