Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix concurrent solve test #537

Merged
merged 2 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,9 @@ cdef extern from "scip/scip_tree.h":
cdef extern from "scip/scip_var.h":
SCIP_RETCODE SCIPchgVarBranchPriority(SCIP* scip, SCIP_VAR* var, int branchpriority)

cdef extern from "tpi/tpi.h":
int SCIPtpiGetNumThreads()

cdef class Expr:
cdef public terms

Expand Down
8 changes: 6 additions & 2 deletions src/pyscipopt/scip.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3096,8 +3096,12 @@ cdef class Model:
def solveConcurrent(self):
"""Transforms, presolves, and solves problem using additional solvers which emphasize on
finding solutions."""
PY_SCIP_CALL(SCIPsolveConcurrent(self._scip))
self._bestSol = Solution.create(self._scip, SCIPgetBestSol(self._scip))
if SCIPtpiGetNumThreads() == 1:
warnings.warn("SCIP was compiled without task processing interface. Parallel solve not possible - using optimize() instead of solveConcurrent()")
self.optimize()
else:
PY_SCIP_CALL(SCIPsolveConcurrent(self._scip))
self._bestSol = Solution.create(self._scip, SCIPgetBestSol(self._scip))

def presolve(self):
"""Presolve the problem."""
Expand Down
25 changes: 0 additions & 25 deletions tests/test_lp_concurrent.py

This file was deleted.

13 changes: 13 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ def test_model():

assert s.getStatus() == 'unbounded'

def test_solve_concurrent():
s = Model()
x = s.addVar("x", vtype = 'C', obj = 1.0)
y = s.addVar("y", vtype = 'C', obj = 2.0)
c = s.addCons(x + y <= 10.0)
s.setMaximize()
s.solveConcurrent()
assert s.getStatus() == 'optimal'
assert s.getObjVal() == 20.0

def test_multiple_cons_simple():
def assert_conss_eq(a, b):
Expand Down Expand Up @@ -177,4 +186,8 @@ def test_model_ptr():

if __name__ == "__main__":
test_model()
test_solve_concurrent()
test_multiple_cons_simple()
test_multiple_cons_names()
test_multiple_cons_params()
test_model_ptr()