File tree Expand file tree Collapse file tree 4 files changed +22
-27
lines changed
Expand file tree Collapse file tree 4 files changed +22
-27
lines changed Original file line number Diff line number Diff line change @@ -1681,6 +1681,9 @@ cdef extern from "scip/scip_tree.h":
16811681cdef extern from " scip/scip_var.h" :
16821682 SCIP_RETCODE SCIPchgVarBranchPriority(SCIP* scip, SCIP_VAR* var, int branchpriority)
16831683
1684+ cdef extern from " tpi/tpi.h" :
1685+ int SCIPtpiGetNumThreads()
1686+
16841687cdef class Expr:
16851688 cdef public terms
16861689
Original file line number Diff line number Diff line change @@ -3096,8 +3096,12 @@ cdef class Model:
30963096 def solveConcurrent (self ):
30973097 """ Transforms, presolves, and solves problem using additional solvers which emphasize on
30983098 finding solutions."""
3099- PY_SCIP_CALL(SCIPsolveConcurrent(self ._scip))
3100- self ._bestSol = Solution.create(self ._scip, SCIPgetBestSol(self ._scip))
3099+ if SCIPtpiGetNumThreads() == 1 :
3100+ warnings.warn(" SCIP was compiled without task processing interface. Parallel solve not possible - using optimize() instead of solveConcurrent()" )
3101+ self .optimize()
3102+ else :
3103+ PY_SCIP_CALL(SCIPsolveConcurrent(self ._scip))
3104+ self ._bestSol = Solution.create(self ._scip, SCIPgetBestSol(self ._scip))
31013105
31023106 def presolve (self ):
31033107 """ Presolve the problem."""
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -78,6 +78,15 @@ def test_model():
7878
7979 assert s .getStatus () == 'unbounded'
8080
81+ def test_solve_concurrent ():
82+ s = Model ()
83+ x = s .addVar ("x" , vtype = 'C' , obj = 1.0 )
84+ y = s .addVar ("y" , vtype = 'C' , obj = 2.0 )
85+ c = s .addCons (x + y <= 10.0 )
86+ s .setMaximize ()
87+ s .solveConcurrent ()
88+ assert s .getStatus () == 'optimal'
89+ assert s .getObjVal () == 20.0
8190
8291def test_multiple_cons_simple ():
8392 def assert_conss_eq (a , b ):
@@ -177,4 +186,8 @@ def test_model_ptr():
177186
178187if __name__ == "__main__" :
179188 test_model ()
189+ test_solve_concurrent ()
190+ test_multiple_cons_simple ()
191+ test_multiple_cons_names ()
192+ test_multiple_cons_params ()
180193 test_model_ptr ()
You can’t perform that action at this time.
0 commit comments