Skip to content

Commit 020801d

Browse files
committed
Switch the solver before it gets created
1 parent 3d55efa commit 020801d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

switch_model/solve.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,14 @@ def solve(model):
879879
solver = model.solver
880880
solver_manager = model.solver_manager
881881
else:
882+
# If we need warm start switch the solver to our augmented version that supports warm starting
883+
if model.options.warm_start is not None or model.options.save_warm_start:
884+
if model.options.solver != "gurobi":
885+
raise NotImplementedError(
886+
"Warm start functionality requires --solver gurobi"
887+
)
888+
model.options.solver = "gurobi_aug"
889+
882890
if model.options.warm_start is not None:
883891
# Method 1 (dual simplex) is required since it supports warm starting.
884892
model.options.solver_method = 1
@@ -940,14 +948,6 @@ def solve(model):
940948
if model.options.warm_start_mip is not None or model.options.warm_start is not None:
941949
solver_args["warmstart"] = True
942950

943-
# If we need warm start switch the solver to our augmented version that supports warm starting
944-
if model.options.warm_start is not None or model.options.save_warm_start:
945-
if model.options.solver != "gurobi":
946-
raise NotImplementedError(
947-
"Warm start functionality requires --solver gurobi"
948-
)
949-
model.options.solver = "gurobi_aug"
950-
951951
if model.options.warm_start is not None:
952952
solver_args["read_warm_start"] = os.path.join(
953953
model.options.warm_start, "outputs", "warm_start.pickle"

0 commit comments

Comments
 (0)