Skip to content

Commit 74b396d

Browse files
author
Christoph Graczyk
committed
add createPartialSol
1 parent 69d8cd0 commit 74b396d

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,6 +3939,24 @@ 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+
3945+
:param Heur heur: heuristic that found the solution (Default value = None)
3946+
3947+
"""
3948+
cdef SCIP_HEUR* _heur
3949+
cdef SCIP_SOL* _sol
3950+
3951+
if isinstance(heur, Heur):
3952+
n = str_conversion(heur.name)
3953+
_heur = SCIPfindHeur(self._scip, n)
3954+
else:
3955+
_heur = NULL
3956+
PY_SCIP_CALL(SCIPcreatePartialSol(self._scip, &_sol, _heur))
3957+
partialsolution = Solution.create(self._scip, _sol)
3958+
return partialsolution
3959+
39423960
def printBestSol(self, write_zeros=False):
39433961
"""Prints the best feasible primal solution."""
39443962
PY_SCIP_CALL(SCIPprintBestSol(self._scip, NULL, write_zeros))

0 commit comments

Comments
 (0)