Skip to content

Commit b9cde84

Browse files
committed
Switch the solver before it gets created
1 parent ee58405 commit b9cde84

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

switch_model/solve.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,12 @@ def solve(model):
690690
solver = model.solver
691691
solver_manager = model.solver_manager
692692
else:
693+
# If we need warm start switch the solver to our augmented version that supports warm starting
694+
if model.options.warm_start is not None or model.options.save_warm_start:
695+
if model.options.solver != "gurobi":
696+
raise NotImplementedError("Warm start functionality requires --solver gurobi")
697+
model.options.solver = "gurobi_aug"
698+
693699
if model.options.warm_start is not None:
694700
# Method 1 (dual simplex) is required since it supports warm starting.
695701
model.options.solver_method = 1
@@ -745,12 +751,6 @@ def solve(model):
745751
if model.options.warm_start_mip is not None or model.options.warm_start is not None:
746752
solver_args["warmstart"] = True
747753

748-
# If we need warm start switch the solver to our augmented version that supports warm starting
749-
if model.options.warm_start is not None or model.options.save_warm_start:
750-
if model.options.solver != "gurobi":
751-
raise NotImplementedError("Warm start functionality requires --solver gurobi")
752-
model.options.solver = "gurobi_aug"
753-
754754
if model.options.warm_start is not None:
755755
solver_args["read_warm_start"] = os.path.join(model.options.warm_start, "outputs", "warm_start.pickle")
756756

0 commit comments

Comments
 (0)