Skip to content

Commit 07b050a

Browse files
authored
Merge pull request #462 from scipopt/partialSol
add createPartialSol
2 parents 69d8cd0 + 36da679 commit 07b050a

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44
### Added
5-
- add more SCIP functions: `getNSols`
5+
- add more SCIP functions: `getNSols`, `createPartialSol`
66

77
### Fixed
88
- consistent handling of filenames for reading/writing

src/pyscipopt/scip.pxd

+1
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ cdef extern from "scip/scip.h":
797797
SCIP_Real SCIPgetSolOrigObj(SCIP* scip, SCIP_SOL* sol)
798798
SCIP_Real SCIPgetSolTransObj(SCIP* scip, SCIP_SOL* sol)
799799
SCIP_RETCODE SCIPcreateSol(SCIP* scip, SCIP_SOL** sol, SCIP_HEUR* heur)
800+
SCIP_RETCODE SCIPcreatePartialSol(SCIP* scip, SCIP_SOL** sol,SCIP_HEUR* heur)
800801
SCIP_RETCODE SCIPsetSolVal(SCIP* scip, SCIP_SOL* sol, SCIP_VAR* var, SCIP_Real val)
801802
SCIP_RETCODE SCIPtrySolFree(SCIP* scip, SCIP_SOL** sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool* stored)
802803
SCIP_RETCODE SCIPtrySol(SCIP* scip, SCIP_SOL* sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool* stored)

src/pyscipopt/scip.pyx

+17
Original file line numberDiff line numberDiff line change
@@ -3939,6 +3939,23 @@ cdef class Model:
39393939
solution = Solution.create(self._scip, _sol)
39403940
return solution
39413941

3942+
def createPartialSol(self, Heur heur = None):
3943+
"""Create a partial primal solution, initialized to unknown values.
3944+
:param Heur heur: heuristic that found the solution (Default value = None)
3945+
3946+
"""
3947+
cdef SCIP_HEUR* _heur
3948+
cdef SCIP_SOL* _sol
3949+
3950+
if isinstance(heur, Heur):
3951+
n = str_conversion(heur.name)
3952+
_heur = SCIPfindHeur(self._scip, n)
3953+
else:
3954+
_heur = NULL
3955+
PY_SCIP_CALL(SCIPcreatePartialSol(self._scip, &_sol, _heur))
3956+
partialsolution = Solution.create(self._scip, _sol)
3957+
return partialsolution
3958+
39423959
def printBestSol(self, write_zeros=False):
39433960
"""Prints the best feasible primal solution."""
39443961
PY_SCIP_CALL(SCIPprintBestSol(self._scip, NULL, write_zeros))

0 commit comments

Comments
 (0)