Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions v1/telco_network_recovery/telco_network_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ def _pos_prob(p):
)

print(f"\n Solving (MIP solver: {MIP_SOLVER})...")
_used_solver = MIP_SOLVER
try:
problem.solve(solver=MIP_SOLVER)
except Exception as exc:
Expand All @@ -864,9 +865,17 @@ def _pos_prob(p):
"not found", "disabled", "install")
):
print(f" Gurobi unavailable ({exc}); falling back to solver='highs'.")
_used_solver = "highs"
problem.solve(solver="highs")
else:
raise
# A non-OPTIMAL solve does NOT raise — it returns a status. Catch a
# transient/failed gurobi solve (e.g. OTHER_ERROR on a cold call) here
# and retry on HiGHS so the chain still produces a plan.
if _used_solver == "gurobi" and problem.solve_info().termination_status != "OPTIMAL":
print(f" gurobi returned {problem.solve_info().termination_status}; "
f"retrying with solver='highs'.")
problem.solve(solver="highs")
problem.display()

# Extract selected upgrades. Cast int128 (returned by RAI select) to
Expand Down
Loading