Minwei Kong commited on
Commit
0618bfb
·
verified ·
1 Parent(s): 2bd9bc2

Write Gurobi runtime unconditionally

Browse files

Replace guarded runtime insertion before json.dump with direct runtime assignment in all gurobi_code.py files.

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. adulyasak2015/gurobi_code.py +1 -2
  2. alba2013/gurobi_code.py +1 -2
  3. alfieri2020/gurobi_code.py +1 -2
  4. amaldi2013/gurobi_code.py +1 -2
  5. araujo2015/gurobi_code.py +1 -2
  6. araujo2020/gurobi_code.py +1 -2
  7. archetti2007/gurobi_code.py +1 -2
  8. armbruster2012/gurobi_code.py +1 -2
  9. arslan2021/gurobi_code.py +1 -2
  10. bard2002/gurobi_code.py +1 -2
  11. barnhart2000/gurobi_code.py +1 -2
  12. bayani2024/gurobi_code.py +1 -2
  13. belhoul2014/gurobi_code.py +1 -2
  14. belvaux2000/gurobi_code.py +1 -2
  15. bentert2022/gurobi_code.py +1 -2
  16. bergman2019/gurobi_code.py +1 -2
  17. bertsimas2022/gurobi_code.py +1 -2
  18. bertsimas2024/gurobi_code.py +1 -2
  19. bettinelli2017/gurobi_code.py +1 -2
  20. bierwirth2017/gurobi_code.py +1 -2
  21. bode2012/gurobi_code.py +2 -4
  22. bodur2017/gurobi_code.py +1 -2
  23. boland2019/gurobi_code.py +1 -2
  24. bollapragada2001/gurobi_code.py +1 -2
  25. borndorfer2007/gurobi_code.py +2 -4
  26. bragin2022/gurobi_code.py +1 -2
  27. brandao2016/gurobi_code.py +1 -2
  28. bront2009/gurobi_code.py +1 -2
  29. buchheim2018/gurobi_code.py +1 -2
  30. byeon2022/gurobi_code.py +1 -2
  31. caprara1999/gurobi_code.py +1 -2
  32. carosi2019/gurobi_code.py +1 -2
  33. carvalho1999/gurobi_code.py +1 -2
  34. carvalho2022/gurobi_code.py +1 -2
  35. castro2021/gurobi_code.py +1 -2
  36. chebil2015/gurobi_code.py +1 -2
  37. chebil2019/gurobi_code.py +1 -2
  38. chen1999/gurobi_code.py +1 -2
  39. cherkesly2015/gurobi_code.py +1 -2
  40. colombi2017/gurobi_code.py +1 -2
  41. contreras2011/gurobi_code.py +1 -2
  42. cordeau2006/gurobi_code.py +1 -2
  43. cordeau2014/gurobi_code.py +1 -2
  44. cordeau2019/gurobi_code.py +1 -2
  45. cote2018/gurobi_code.py +1 -2
  46. cote2019/gurobi_code.py +1 -2
  47. cunha2021/gurobi_code.py +1 -2
  48. damcikurt2016/gurobi_code.py +1 -2
  49. dayarian2019/gurobi_code.py +1 -2
  50. degraeve2007/gurobi_code.py +1 -2
adulyasak2015/gurobi_code.py CHANGED
@@ -344,8 +344,7 @@ def solve(instance_path, solution_path, time_limit):
344
  result["x"] = x_sol
345
 
346
  with open(solution_path, 'w') as fp:
347
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
348
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
349
  json.dump(result, fp, indent=2)
350
 
351
  print(f"Objective value: {result['objective_value']}")
 
344
  result["x"] = x_sol
345
 
346
  with open(solution_path, 'w') as fp:
347
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
348
  json.dump(result, fp, indent=2)
349
 
350
  print(f"Objective value: {result['objective_value']}")
alba2013/gurobi_code.py CHANGED
@@ -958,8 +958,7 @@ def solve_dtspms(instance_path, solution_path, time_limit):
958
 
959
  # Write solution
960
  with open(solution_path, 'w') as f:
961
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
962
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
963
  json.dump(result, f, indent=2)
964
 
965
  print(f"\nSolution written to {solution_path}")
 
958
 
959
  # Write solution
960
  with open(solution_path, 'w') as f:
961
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
962
  json.dump(result, f, indent=2)
963
 
964
  print(f"\nSolution written to {solution_path}")
alfieri2020/gurobi_code.py CHANGED
@@ -165,8 +165,7 @@ def solve_gcp_compact(instance_path: str, solution_path: str, time_limit: int):
165
  # Write solution
166
  # ----------------------------------------------------------------
167
  with open(solution_path, "w") as f:
168
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
169
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
170
  json.dump(solution, f, indent=2)
171
 
172
  print(f"Solution written to {solution_path}")
 
165
  # Write solution
166
  # ----------------------------------------------------------------
167
  with open(solution_path, "w") as f:
168
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
169
  json.dump(solution, f, indent=2)
170
 
171
  print(f"Solution written to {solution_path}")
amaldi2013/gurobi_code.py CHANGED
@@ -205,8 +205,7 @@ def solve_min_hcp(instance_path, solution_path, time_limit):
205
 
206
  # Write solution
207
  with open(solution_path, "w") as f:
208
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
209
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
210
  json.dump(result, f, indent=2)
211
 
212
  print(f"Solution written to {solution_path}")
 
205
 
206
  # Write solution
207
  with open(solution_path, "w") as f:
208
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
209
  json.dump(result, f, indent=2)
210
 
211
  print(f"Solution written to {solution_path}")
araujo2015/gurobi_code.py CHANGED
@@ -198,8 +198,7 @@ def main():
198
  result = solve_clst(instance, args.time_limit)
199
 
200
  with open(args.solution_path, 'w') as f:
201
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
202
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
203
  json.dump(result, f, indent=2)
204
 
205
  print(f"Solution written to {args.solution_path}")
 
198
  result = solve_clst(instance, args.time_limit)
199
 
200
  with open(args.solution_path, 'w') as f:
201
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
202
  json.dump(result, f, indent=2)
203
 
204
  print(f"Solution written to {args.solution_path}")
araujo2020/gurobi_code.py CHANGED
@@ -451,8 +451,7 @@ def main():
451
  solution = build_and_solve(instance, args.time_limit)
452
 
453
  with open(args.solution_path, 'w') as f:
454
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
455
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
456
  json.dump(solution, f, indent=2)
457
 
458
  print(f"Solution written to {args.solution_path}")
 
451
  solution = build_and_solve(instance, args.time_limit)
452
 
453
  with open(args.solution_path, 'w') as f:
454
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
455
  json.dump(solution, f, indent=2)
456
 
457
  print(f"Solution written to {args.solution_path}")
archetti2007/gurobi_code.py CHANGED
@@ -540,8 +540,7 @@ def main():
540
  result = solve_vmir_ou(data, args.time_limit)
541
 
542
  with open(args.solution_path, 'w') as f:
543
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
544
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
545
  json.dump(result, f, indent=2, default=str)
546
 
547
  print(f"Solution written to {args.solution_path}")
 
540
  result = solve_vmir_ou(data, args.time_limit)
541
 
542
  with open(args.solution_path, 'w') as f:
543
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
544
  json.dump(result, f, indent=2, default=str)
545
 
546
  print(f"Solution written to {args.solution_path}")
armbruster2012/gurobi_code.py CHANGED
@@ -222,8 +222,7 @@ def main():
222
  result = solve_bisection(instance, args.time_limit)
223
 
224
  with open(args.solution_path, "w") as f:
225
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
226
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
227
  json.dump(result, f, indent=2)
228
 
229
  print(f"Status: {result['status_str']}")
 
222
  result = solve_bisection(instance, args.time_limit)
223
 
224
  with open(args.solution_path, "w") as f:
225
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
226
  json.dump(result, f, indent=2)
227
 
228
  print(f"Status: {result['status_str']}")
arslan2021/gurobi_code.py CHANGED
@@ -188,8 +188,7 @@ def main():
188
  solution = build_and_solve(data, args.time_limit)
189
 
190
  with open(args.solution_path, 'w') as f:
191
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
192
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
193
  json.dump(solution, f, indent=2)
194
 
195
  if solution["objective_value"] is not None:
 
188
  solution = build_and_solve(data, args.time_limit)
189
 
190
  with open(args.solution_path, 'w') as f:
191
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
192
  json.dump(solution, f, indent=2)
193
 
194
  if solution["objective_value"] is not None:
bard2002/gurobi_code.py CHANGED
@@ -323,8 +323,7 @@ def build_and_solve(instance_path, solution_path, time_limit):
323
 
324
  # Write solution
325
  with open(solution_path, "w") as f:
326
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
327
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
328
  json.dump(result, f, indent=2)
329
 
330
  print(f"Solution written to {solution_path}")
 
323
 
324
  # Write solution
325
  with open(solution_path, "w") as f:
326
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
327
  json.dump(result, f, indent=2)
328
 
329
  print(f"Solution written to {solution_path}")
barnhart2000/gurobi_code.py CHANGED
@@ -198,8 +198,7 @@ def main():
198
  solution = build_and_solve(data, args.time_limit)
199
 
200
  with open(args.solution_path, "w") as f:
201
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
202
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
203
  json.dump(solution, f, indent=2)
204
 
205
  print(f"Solution written to {args.solution_path}")
 
198
  solution = build_and_solve(data, args.time_limit)
199
 
200
  with open(args.solution_path, "w") as f:
201
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
202
  json.dump(solution, f, indent=2)
203
 
204
  print(f"Solution written to {args.solution_path}")
bayani2024/gurobi_code.py CHANGED
@@ -178,8 +178,7 @@ def main():
178
 
179
  # Write solution
180
  with open(args.solution_path, 'w') as f:
181
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
182
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
183
  json.dump(solution, f, indent=2)
184
 
185
  print(f"Solution written to {args.solution_path}")
 
178
 
179
  # Write solution
180
  with open(args.solution_path, 'w') as f:
181
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
182
  json.dump(solution, f, indent=2)
183
 
184
  print(f"Solution written to {args.solution_path}")
belhoul2014/gurobi_code.py CHANGED
@@ -159,8 +159,7 @@ def solve_lcap(instance_path, solution_path, time_limit):
159
 
160
  # Write solution
161
  with open(solution_path, "w") as f:
162
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
163
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
164
  json.dump(result, f, indent=2)
165
 
166
  print(f"\nSolution written to {solution_path}")
 
159
 
160
  # Write solution
161
  with open(solution_path, "w") as f:
162
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
163
  json.dump(result, f, indent=2)
164
 
165
  print(f"\nSolution written to {solution_path}")
belvaux2000/gurobi_code.py CHANGED
@@ -262,8 +262,7 @@ def solve(instance_path, solution_path, time_limit):
262
  result["objective_value"] = None
263
 
264
  with open(solution_path, 'w') as f:
265
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
266
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
267
  json.dump(result, f, indent=2)
268
 
269
  print(f"Solution written to {solution_path}")
 
262
  result["objective_value"] = None
263
 
264
  with open(solution_path, 'w') as f:
265
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
266
  json.dump(result, f, indent=2)
267
 
268
  print(f"Solution written to {solution_path}")
bentert2022/gurobi_code.py CHANGED
@@ -234,8 +234,7 @@ def main():
234
  solution["vertex_costs"] = {str(v): c for v, c in vertex_costs.items()}
235
 
236
  with open(args.solution_path, 'w') as f:
237
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
238
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
239
  json.dump(solution, f, indent=2)
240
 
241
  if obj_val is not None:
 
234
  solution["vertex_costs"] = {str(v): c for v, c in vertex_costs.items()}
235
 
236
  with open(args.solution_path, 'w') as f:
237
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
238
  json.dump(solution, f, indent=2)
239
 
240
  if obj_val is not None:
bergman2019/gurobi_code.py CHANGED
@@ -149,8 +149,7 @@ def main():
149
  result = solve_qmkp(instance, args.time_limit)
150
 
151
  with open(args.solution_path, "w") as f:
152
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
153
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
154
  json.dump(result, f, indent=2)
155
 
156
  print(f"Objective value: {result['objective_value']}")
 
149
  result = solve_qmkp(instance, args.time_limit)
150
 
151
  with open(args.solution_path, "w") as f:
152
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
153
  json.dump(result, f, indent=2)
154
 
155
  print(f"Objective value: {result['objective_value']}")
bertsimas2022/gurobi_code.py CHANGED
@@ -259,8 +259,7 @@ def main():
259
  }
260
 
261
  with open(args.solution_path, "w") as fh:
262
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
263
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
264
  json.dump(solution, fh, indent=2)
265
 
266
  print(f"Status : {solution['solver_status_str']}")
 
259
  }
260
 
261
  with open(args.solution_path, "w") as fh:
262
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
263
  json.dump(solution, fh, indent=2)
264
 
265
  print(f"Status : {solution['solver_status_str']}")
bertsimas2024/gurobi_code.py CHANGED
@@ -224,8 +224,7 @@ def main():
224
  result = build_and_solve(data, args.time_limit)
225
 
226
  with open(args.solution_path, "w") as f:
227
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
228
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
229
  json.dump(result, f, indent=2)
230
 
231
  print(f"Solution written to {args.solution_path}")
 
224
  result = build_and_solve(data, args.time_limit)
225
 
226
  with open(args.solution_path, "w") as f:
227
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
228
  json.dump(result, f, indent=2)
229
 
230
  print(f"Solution written to {args.solution_path}")
bettinelli2017/gurobi_code.py CHANGED
@@ -175,8 +175,7 @@ def solve_kpcg(instance_path, solution_path, time_limit):
175
  }
176
 
177
  with open(solution_path, "w") as f:
178
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
179
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
180
  json.dump(result, f, indent=2)
181
 
182
  print(f"Objective value : {objective_value}")
 
175
  }
176
 
177
  with open(solution_path, "w") as f:
178
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
179
  json.dump(result, f, indent=2)
180
 
181
  print(f"Objective value : {objective_value}")
bierwirth2017/gurobi_code.py CHANGED
@@ -249,8 +249,7 @@ def solve_jsptwt(instance_path: str, solution_path: str, time_limit: float) -> N
249
  )
250
 
251
  with open(solution_path, "w") as f:
252
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
253
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
254
  json.dump(solution, f, indent=2)
255
 
256
  print(f"Solution written to {solution_path}")
 
249
  )
250
 
251
  with open(solution_path, "w") as f:
252
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
253
  json.dump(solution, f, indent=2)
254
 
255
  print(f"Solution written to {solution_path}")
bode2012/gurobi_code.py CHANGED
@@ -338,8 +338,7 @@ def solve_carp(instance_path, solution_path, time_limit):
338
  solution["routes"].append(route_info)
339
 
340
  with open(solution_path, "w") as f:
341
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
342
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
343
  json.dump(solution, f, indent=2)
344
  print(f"Solution written to {solution_path}")
345
  print(f"Objective value: {obj_val}")
@@ -350,8 +349,7 @@ def solve_carp(instance_path, solution_path, time_limit):
350
  "status_str": "NO_SOLUTION_FOUND"
351
  }
352
  with open(solution_path, "w") as f:
353
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
354
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
355
  json.dump(solution, f, indent=2)
356
  print("No feasible solution found.")
357
 
 
338
  solution["routes"].append(route_info)
339
 
340
  with open(solution_path, "w") as f:
341
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
342
  json.dump(solution, f, indent=2)
343
  print(f"Solution written to {solution_path}")
344
  print(f"Objective value: {obj_val}")
 
349
  "status_str": "NO_SOLUTION_FOUND"
350
  }
351
  with open(solution_path, "w") as f:
352
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
353
  json.dump(solution, f, indent=2)
354
  print("No feasible solution found.")
355
 
bodur2017/gurobi_code.py CHANGED
@@ -137,8 +137,7 @@ def solve(instance_path, solution_path, time_limit):
137
  }
138
 
139
  with open(solution_path, "w") as f:
140
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
141
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
142
  json.dump(solution, f, indent=2)
143
 
144
  print(f"Objective value: {obj_val}")
 
137
  }
138
 
139
  with open(solution_path, "w") as f:
140
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
141
  json.dump(solution, f, indent=2)
142
 
143
  print(f"Objective value: {obj_val}")
boland2019/gurobi_code.py CHANGED
@@ -337,8 +337,7 @@ def main():
337
  }
338
 
339
  with open(args.solution_path, "w") as f:
340
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
341
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
342
  json.dump(result, f, indent=2)
343
 
344
  print(f"Found {len(pareto_front)} non-dominated points in {elapsed:.2f}s")
 
337
  }
338
 
339
  with open(args.solution_path, "w") as f:
340
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
341
  json.dump(result, f, indent=2)
342
 
343
  print(f"Found {len(pareto_front)} non-dominated points in {elapsed:.2f}s")
bollapragada2001/gurobi_code.py CHANGED
@@ -369,8 +369,7 @@ def main():
369
  print(f" Bar {ba['bar_id']}: area = {ba['area']}")
370
 
371
  with open(args.solution_path, "w") as f:
372
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
373
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
374
  json.dump(result, f, indent=2)
375
  print(f"\nSolution written to {args.solution_path}")
376
 
 
369
  print(f" Bar {ba['bar_id']}: area = {ba['area']}")
370
 
371
  with open(args.solution_path, "w") as f:
372
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
373
  json.dump(result, f, indent=2)
374
  print(f"\nSolution written to {args.solution_path}")
375
 
borndorfer2007/gurobi_code.py CHANGED
@@ -341,8 +341,7 @@ def main():
341
  print("ERROR: No feasible lines found.")
342
  solution = {"objective_value": None, "status": "infeasible", "error": "No lines enumerated"}
343
  with open(args.solution_path, 'w') as f:
344
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
345
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
346
  json.dump(solution, f, indent=2)
347
  return
348
 
@@ -544,8 +543,7 @@ def main():
544
  print("No feasible solution found.")
545
 
546
  with open(args.solution_path, 'w') as outf:
547
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
548
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
549
  json.dump(solution, outf, indent=2)
550
  print(f"Solution written to {args.solution_path}")
551
 
 
341
  print("ERROR: No feasible lines found.")
342
  solution = {"objective_value": None, "status": "infeasible", "error": "No lines enumerated"}
343
  with open(args.solution_path, 'w') as f:
344
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
345
  json.dump(solution, f, indent=2)
346
  return
347
 
 
543
  print("No feasible solution found.")
544
 
545
  with open(args.solution_path, 'w') as outf:
546
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
547
  json.dump(solution, outf, indent=2)
548
  print(f"Solution written to {args.solution_path}")
549
 
bragin2022/gurobi_code.py CHANGED
@@ -109,8 +109,7 @@ def main():
109
 
110
  # Write solution
111
  with open(args.solution_path, "w") as f:
112
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
113
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
114
  json.dump(solution, f, indent=2)
115
 
116
  print(f"Status: {model.Status}")
 
109
 
110
  # Write solution
111
  with open(args.solution_path, "w") as f:
112
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
113
  json.dump(solution, f, indent=2)
114
 
115
  print(f"Status: {model.Status}")
brandao2016/gurobi_code.py CHANGED
@@ -431,8 +431,7 @@ def main():
431
  }
432
 
433
  with open(args.solution_path, "w") as f:
434
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
435
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
436
  json.dump(solution, f, indent=2)
437
 
438
  print(f"Solution written to {args.solution_path}")
 
431
  }
432
 
433
  with open(args.solution_path, "w") as f:
434
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
435
  json.dump(solution, f, indent=2)
436
 
437
  print(f"Solution written to {args.solution_path}")
bront2009/gurobi_code.py CHANGED
@@ -516,8 +516,7 @@ def main():
516
  }
517
 
518
  with open(args.solution_path, 'w') as f:
519
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
520
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
521
  json.dump(solution, f, indent=2)
522
 
523
  print(f"\nSolution saved to {args.solution_path}")
 
516
  }
517
 
518
  with open(args.solution_path, 'w') as f:
519
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
520
  json.dump(solution, f, indent=2)
521
 
522
  print(f"\nSolution saved to {args.solution_path}")
buchheim2018/gurobi_code.py CHANGED
@@ -169,8 +169,7 @@ def main():
169
  result = build_and_solve(data, args.time_limit)
170
 
171
  with open(args.solution_path, "w") as f:
172
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
173
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
174
  json.dump(result, f, indent=2)
175
 
176
  print(f"Solution written to {args.solution_path}")
 
169
  result = build_and_solve(data, args.time_limit)
170
 
171
  with open(args.solution_path, "w") as f:
172
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
173
  json.dump(result, f, indent=2)
174
 
175
  print(f"Solution written to {args.solution_path}")
byeon2022/gurobi_code.py CHANGED
@@ -1184,8 +1184,7 @@ def solve_and_output(m, solution_path):
1184
  print("WARNING: No feasible solution found.")
1185
 
1186
  with open(solution_path, "w") as f:
1187
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
1188
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
1189
  json.dump(result, f, indent=2)
1190
 
1191
  print(f"Solution written to {solution_path}")
 
1184
  print("WARNING: No feasible solution found.")
1185
 
1186
  with open(solution_path, "w") as f:
1187
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
1188
  json.dump(result, f, indent=2)
1189
 
1190
  print(f"Solution written to {solution_path}")
caprara1999/gurobi_code.py CHANGED
@@ -116,8 +116,7 @@ def solve_qkp(instance_path: str, solution_path: str, time_limit: float) -> None
116
  }
117
 
118
  with open(solution_path, "w") as f:
119
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
120
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
121
  json.dump(solution, f, indent=2)
122
 
123
 
 
116
  }
117
 
118
  with open(solution_path, "w") as f:
119
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
120
  json.dump(solution, f, indent=2)
121
 
122
 
carosi2019/gurobi_code.py CHANGED
@@ -600,8 +600,7 @@ def main():
600
  solution = solve_ittvs(instance, args.time_limit)
601
 
602
  with open(args.solution_path, 'w') as f:
603
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
604
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
605
  json.dump(solution, f, indent=2, default=str)
606
 
607
  print(f"Solution written to: {args.solution_path}")
 
600
  solution = solve_ittvs(instance, args.time_limit)
601
 
602
  with open(args.solution_path, 'w') as f:
603
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
604
  json.dump(solution, f, indent=2, default=str)
605
 
606
  print(f"Solution written to: {args.solution_path}")
carvalho1999/gurobi_code.py CHANGED
@@ -285,8 +285,7 @@ def solve(instance_path, solution_path, time_limit):
285
  result["mip_gap"] = model.MIPGap if model.SolCount > 0 else None
286
 
287
  with open(solution_path, "w") as f:
288
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
289
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
290
  json.dump(result, f, indent=2)
291
 
292
  print(f"Solution written to {solution_path}")
 
285
  result["mip_gap"] = model.MIPGap if model.SolCount > 0 else None
286
 
287
  with open(solution_path, "w") as f:
288
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
289
  json.dump(result, f, indent=2)
290
 
291
  print(f"Solution written to {solution_path}")
carvalho2022/gurobi_code.py CHANGED
@@ -454,8 +454,7 @@ def main():
454
  result = build_and_solve(data, args.time_limit)
455
 
456
  with open(args.solution_path, 'w') as f:
457
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
458
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
459
  json.dump(result, f, indent=2)
460
 
461
  print(f"Solution written to {args.solution_path}")
 
454
  result = build_and_solve(data, args.time_limit)
455
 
456
  with open(args.solution_path, 'w') as f:
457
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
458
  json.dump(result, f, indent=2)
459
 
460
  print(f"Solution written to {args.solution_path}")
castro2021/gurobi_code.py CHANGED
@@ -170,8 +170,7 @@ def main():
170
  result = build_and_solve(data, args.time_limit)
171
 
172
  with open(args.solution_path, 'w') as f:
173
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
174
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
175
  json.dump(result, f, indent=2)
176
 
177
  print(f"Solution written to {args.solution_path}")
 
170
  result = build_and_solve(data, args.time_limit)
171
 
172
  with open(args.solution_path, 'w') as f:
173
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
174
  json.dump(result, f, indent=2)
175
 
176
  print(f"Solution written to {args.solution_path}")
chebil2015/gurobi_code.py CHANGED
@@ -108,8 +108,7 @@ def solve_kps(instance_path, solution_path, time_limit):
108
  solution["objective_value"] = objective_value
109
 
110
  with open(solution_path, "w") as f:
111
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
112
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
113
  json.dump(solution, f, indent=2)
114
 
115
  print(f"Objective value: {objective_value}")
 
108
  solution["objective_value"] = objective_value
109
 
110
  with open(solution_path, "w") as f:
111
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
112
  json.dump(solution, f, indent=2)
113
 
114
  print(f"Objective value: {objective_value}")
chebil2019/gurobi_code.py CHANGED
@@ -138,8 +138,7 @@ def main():
138
  solution = solve_kps(instance, args.time_limit)
139
 
140
  with open(args.solution_path, "w") as f:
141
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
142
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
143
  json.dump(solution, f, indent=2)
144
 
145
  print(f"Solution written to {args.solution_path}")
 
138
  solution = solve_kps(instance, args.time_limit)
139
 
140
  with open(args.solution_path, "w") as f:
141
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
142
  json.dump(solution, f, indent=2)
143
 
144
  print(f"Solution written to {args.solution_path}")
chen1999/gurobi_code.py CHANGED
@@ -619,8 +619,7 @@ def main():
619
 
620
  # Write solution
621
  with open(args.solution_path, 'w') as f:
622
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
623
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
624
  json.dump(result, f, indent=2)
625
 
626
  print(f"\nSolution written to: {args.solution_path}")
 
619
 
620
  # Write solution
621
  with open(args.solution_path, 'w') as f:
622
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
623
  json.dump(result, f, indent=2)
624
 
625
  print(f"\nSolution written to: {args.solution_path}")
cherkesly2015/gurobi_code.py CHANGED
@@ -451,8 +451,7 @@ def main():
451
  print("No feasible solution found.")
452
 
453
  with open(args.solution_path, "w") as f:
454
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
455
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
456
  json.dump(solution, f, indent=2)
457
  print(f"Solution saved to: {args.solution_path}")
458
 
 
451
  print("No feasible solution found.")
452
 
453
  with open(args.solution_path, "w") as f:
454
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
455
  json.dump(solution, f, indent=2)
456
  print(f"Solution saved to: {args.solution_path}")
457
 
colombi2017/gurobi_code.py CHANGED
@@ -389,8 +389,7 @@ def main():
389
  result = solve_dprpp_ic(instance, args.time_limit)
390
 
391
  with open(args.solution_path, 'w') as f:
392
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
393
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
394
  json.dump(result, f, indent=2)
395
 
396
  print(f"Objective value: {result['objective_value']}")
 
389
  result = solve_dprpp_ic(instance, args.time_limit)
390
 
391
  with open(args.solution_path, 'w') as f:
392
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
393
  json.dump(result, f, indent=2)
394
 
395
  print(f"Objective value: {result['objective_value']}")
contreras2011/gurobi_code.py CHANGED
@@ -201,8 +201,7 @@ def main():
201
  result = solve_chlpsa(instance, args.time_limit)
202
 
203
  with open(args.solution_path, 'w') as f:
204
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
205
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
206
  json.dump(result, f, indent=2)
207
 
208
  print(f"Solution written to {args.solution_path}")
 
201
  result = solve_chlpsa(instance, args.time_limit)
202
 
203
  with open(args.solution_path, 'w') as f:
204
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
205
  json.dump(result, f, indent=2)
206
 
207
  print(f"Solution written to {args.solution_path}")
cordeau2006/gurobi_code.py CHANGED
@@ -396,8 +396,7 @@ def build_and_solve(instance_path, solution_path, time_limit):
396
 
397
  # Write solution
398
  with open(solution_path, "w") as f:
399
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
400
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
401
  json.dump(result, f, indent=2)
402
 
403
  print(f"Solution written to {solution_path}")
 
396
 
397
  # Write solution
398
  with open(solution_path, "w") as f:
399
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
400
  json.dump(result, f, indent=2)
401
 
402
  print(f"Solution written to {solution_path}")
cordeau2014/gurobi_code.py CHANGED
@@ -1143,8 +1143,7 @@ def solve_tdtsp(instance_path, solution_path, time_limit):
1143
  # 8. Write solution
1144
  # ------------------------------------------------------------------
1145
  with open(solution_path, 'w') as f:
1146
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
1147
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
1148
  json.dump(result, f, indent=2)
1149
  print(f"\nSolution written to: {solution_path}")
1150
 
 
1143
  # 8. Write solution
1144
  # ------------------------------------------------------------------
1145
  with open(solution_path, 'w') as f:
1146
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
1147
  json.dump(result, f, indent=2)
1148
  print(f"\nSolution written to: {solution_path}")
1149
 
cordeau2019/gurobi_code.py CHANGED
@@ -277,8 +277,7 @@ def main():
277
  "results": results,
278
  }
279
  with open(sol_path, "w") as f:
280
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
281
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
282
  json.dump(solution, f, indent=2)
283
  print(f"\nSolution written to {sol_path}")
284
 
 
277
  "results": results,
278
  }
279
  with open(sol_path, "w") as f:
280
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
281
  json.dump(solution, f, indent=2)
282
  print(f"\nSolution written to {sol_path}")
283
 
cote2018/gurobi_code.py CHANGED
@@ -234,8 +234,7 @@ def solve_and_output(model, z, solution_path):
234
  result["mip_gap"] = model.MIPGap if model.SolCount > 0 else None
235
 
236
  with open(solution_path, 'w') as f:
237
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
238
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
239
  json.dump(result, f, indent=2)
240
 
241
 
 
234
  result["mip_gap"] = model.MIPGap if model.SolCount > 0 else None
235
 
236
  with open(solution_path, 'w') as f:
237
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
238
  json.dump(result, f, indent=2)
239
 
240
 
cote2019/gurobi_code.py CHANGED
@@ -898,8 +898,7 @@ def solve(args):
898
 
899
  # Save solution
900
  with open(args.solution_path, "w") as f:
901
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
902
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
903
  json.dump(result, f, indent=2)
904
 
905
  print(f"Status: {result['status']}")
 
898
 
899
  # Save solution
900
  with open(args.solution_path, "w") as f:
901
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
902
  json.dump(result, f, indent=2)
903
 
904
  print(f"Status: {result['status']}")
cunha2021/gurobi_code.py CHANGED
@@ -194,8 +194,7 @@ def solve(instance_path: str, solution_path: str, time_limit: float):
194
  result["objective_value"] = None
195
 
196
  with open(solution_path, "w") as f:
197
- if isinstance(result, dict) and "objective_value" in result and "runtime" not in result:
198
- result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
199
  json.dump(result, f, indent=2)
200
 
201
  return result
 
194
  result["objective_value"] = None
195
 
196
  with open(solution_path, "w") as f:
197
+ result["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
198
  json.dump(result, f, indent=2)
199
 
200
  return result
damcikurt2016/gurobi_code.py CHANGED
@@ -268,8 +268,7 @@ def main():
268
  }
269
 
270
  with open(args.solution_path, "w") as f:
271
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
272
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
273
  json.dump(solution, f, indent=2)
274
 
275
  print(f"Objective value: {solution['objective_value']}")
 
268
  }
269
 
270
  with open(args.solution_path, "w") as f:
271
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
272
  json.dump(solution, f, indent=2)
273
 
274
  print(f"Objective value: {solution['objective_value']}")
dayarian2019/gurobi_code.py CHANGED
@@ -804,8 +804,7 @@ def main():
804
  solution = solve_cprp(instance, args.time_limit)
805
 
806
  with open(args.solution_path, 'w') as f:
807
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
808
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
809
  json.dump(solution, f, indent=2)
810
 
811
  print(f"\nSolution written to: {args.solution_path}")
 
804
  solution = solve_cprp(instance, args.time_limit)
805
 
806
  with open(args.solution_path, 'w') as f:
807
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
808
  json.dump(solution, f, indent=2)
809
 
810
  print(f"\nSolution written to: {args.solution_path}")
degraeve2007/gurobi_code.py CHANGED
@@ -150,8 +150,7 @@ def solve_clst(instance_path: str, solution_path: str, time_limit: float) -> Non
150
 
151
  # Write solution
152
  with open(solution_path, "w") as f:
153
- if isinstance(solution, dict) and "objective_value" in solution and "runtime" not in solution:
154
- solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
155
  json.dump(solution, f, indent=2)
156
 
157
  print(f"Status: {solution['status_name']}")
 
150
 
151
  # Write solution
152
  with open(solution_path, "w") as f:
153
+ solution["runtime"] = time.time() - _GUROBI_CODE_START_TIME
 
154
  json.dump(solution, f, indent=2)
155
 
156
  print(f"Status: {solution['status_name']}")