Skip to content

Commit

Permalink
timeout on gurobi
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Dec 8, 2023
1 parent 031ec8c commit e175e8e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,17 @@ def route_using_cp(
raise RuntimeError("Couldn't route.")


def route_using_ilp(DG, flows):
def route_using_ilp(
DG,
flows,
timeout=600,
):
import gurobipy as gp
from gurobipy import GRB

# Create model object
m = gp.Model()
m.setParam("TimeLimit", timeout)

# Create variable for each edge, for each path
flow_vars = {}
Expand Down Expand Up @@ -500,7 +505,7 @@ def find_paths(self):
if self.routing_solution is None:
DG = build_graph(self.max_col, self.max_row, self.target_model)
if self.use_gurobi:
flow_paths = route_using_ilp(DG, self.flows)
flow_paths = route_using_ilp(DG, self.flows, timeout=self.timeout)
else:
flow_paths = route_using_cp(
DG, self.flows, num_workers=10, timeout=self.timeout
Expand Down

0 comments on commit e175e8e

Please sign in to comment.