Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added tests for `getObjVal()` and `getVal()`
- Added `addConsLinear()` to add linear constraints from variables and coefficients without building an expression
- Added `SCIP_BOUNDTYPE` and `SCIP_BOUNDCHGTYPE` enums
- Added missing SCIP constants: `SCIP_EVENTTYPE.TYPECHANGED`/`IMPLTYPECHANGED`, `SCIP_PROPTIMING.NONE`/`ALWAYS`, `SCIP_PRESOLTIMING.FINAL`/`ALWAYS`/`MAX`, `SCIP_HEURTIMING.NONE`/`AFTERNODE`/`AFTERPLUNGE`, `SCIP_RESULT.DELAYNODE`, `SCIP_ROWORIGINTYPE.CONSHDLR`
### Fixed
- Fixed `MatrixVariable.varMayRound()` rounding direction
- Fixed `lotsizing_lazy` example: lock the handler's variables in `conslock` so presolve cannot aggregate them away (#1252)
Expand All @@ -17,6 +18,7 @@
- Fixed `getDualsolKnapsack()` and `getDualfarkasKnapsack()` returning 0 for original constraints, and the handler check in `getVarsAnd()` that could never fail
### Changed
- Replaced SCIP constant classes with `IntEnum` and `IntFlag`, including enum return values and type annotations (#1286).
- Speed up enum-returning getters and plugin callbacks with precomputed lookup tables
- Replaced `format()` with f-strings in examples
- Refactor general expression conversion into per-class `to_scip_expr` recursion
- Made expression fields read-only to prevent accidental runtime modification
Expand Down
4 changes: 2 additions & 2 deletions src/pyscipopt/benders.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ cdef SCIP_RETCODE PyBendersPresubsolve (SCIP* scip, SCIP_BENDERS* benders, SCIP_
solution = None
else:
solution = Solution.create(scip, sol)
enfotype = PY_SCIP_BENDERSENFOTYPE(type)
enfotype = _ENUMS[PY_SCIP_BENDERSENFOTYPE][type]
result_dict = PyBenders.benderspresubsolve(solution, enfotype, checkint)
infeasible[0] = result_dict.get("infeasible", False)
auxviol[0] = result_dict.get("auxviol", False)
Expand Down Expand Up @@ -179,7 +179,7 @@ cdef SCIP_RETCODE PyBendersPostsolve (SCIP* scip, SCIP_BENDERS* benders, SCIP_SO
solution = None
else:
solution = Solution.create(scip, sol)
enfotype = PY_SCIP_BENDERSENFOTYPE(type)
enfotype = _ENUMS[PY_SCIP_BENDERSENFOTYPE][type]
mergecandidates = []
for i in range(nmergecands):
mergecandidates.append(mergecands[i])
Expand Down
2 changes: 1 addition & 1 deletion src/pyscipopt/benderscut.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cdef SCIP_RETCODE PyBenderscutExec (SCIP* scip, SCIP_BENDERS* benders, SCIP_BEND
solution = None
else:
solution = Solution.create(scip, sol)
enfotype = PY_SCIP_BENDERSENFOTYPE(type)
enfotype = _ENUMS[PY_SCIP_BENDERSENFOTYPE][type]
result_dict = PyBenderscut.benderscutexec(solution, probnumber, enfotype)
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY
10 changes: 5 additions & 5 deletions src/pyscipopt/conshdlr.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ cdef SCIP_RETCODE PyConsProp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** c
constraints = []
for i in range(nconss):
constraints.append(getPyCons(conss[i]))
result_dict = PyConshdlr.consprop(constraints, nusefulconss, nmarkedconss, PY_SCIP_PROPTIMING(proptiming))
result_dict = PyConshdlr.consprop(constraints, nusefulconss, nmarkedconss, _ENUMS[PY_SCIP_PROPTIMING][proptiming])
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY

Expand All @@ -353,8 +353,8 @@ cdef SCIP_RETCODE PyConsPresol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS**
result_dict["nupgdconss"] = nupgdconss[0]
result_dict["nchgcoefs"] = nchgcoefs[0]
result_dict["nchgsides"] = nchgsides[0]
result_dict["result"] = PY_SCIP_RESULT(result[0])
PyConshdlr.conspresol(constraints, nrounds, PY_SCIP_PRESOLTIMING(presoltiming),
result_dict["result"] = _ENUMS[PY_SCIP_RESULT][result[0]]
PyConshdlr.conspresol(constraints, nrounds, _ENUMS[PY_SCIP_PRESOLTIMING][presoltiming],
nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict)
result[0] = result_dict["result"]
Expand All @@ -379,10 +379,10 @@ cdef SCIP_RETCODE PyConsResprop (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS*
cdef SCIP_RETCODE PyConsLock (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_LOCKTYPE locktype, int nlockspos, int nlocksneg) noexcept with gil:
PyConshdlr = getPyConshdlr(conshdlr)
if cons == NULL:
PyConshdlr.conslock(None, PY_SCIP_LOCKTYPE(locktype), nlockspos, nlocksneg)
PyConshdlr.conslock(None, _ENUMS[PY_SCIP_LOCKTYPE][locktype], nlockspos, nlocksneg)
else:
PyCons = getPyCons(cons)
PyConshdlr.conslock(PyCons, PY_SCIP_LOCKTYPE(locktype), nlockspos, nlocksneg)
PyConshdlr.conslock(PyCons, _ENUMS[PY_SCIP_LOCKTYPE][locktype], nlockspos, nlocksneg)
return SCIP_OKAY

cdef SCIP_RETCODE PyConsActive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons) noexcept with gil:
Expand Down
4 changes: 2 additions & 2 deletions src/pyscipopt/lp.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ cdef class LP:

PY_SCIP_CALL(SCIPlpiGetBase(self.lpi, c_cstat, c_rstat))

cstat = [PY_SCIP_BASESTAT(c_cstat[i]) for i in range(ncols)]
rstat = [PY_SCIP_BASESTAT(c_rstat[i]) for i in range(nrows)]
cstat = [_ENUMS[PY_SCIP_BASESTAT][c_cstat[i]] for i in range(ncols)]
rstat = [_ENUMS[PY_SCIP_BASESTAT][c_rstat[i]] for i in range(nrows)]

free(c_rstat)
free(c_cstat)
Expand Down
2 changes: 1 addition & 1 deletion src/pyscipopt/presol.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ cdef SCIP_RETCODE PyPresolExec (SCIP* scip, SCIP_PRESOL* presol, int nrounds, SC
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
result_dict = PyPresol.presolexec(nrounds, PY_SCIP_PRESOLTIMING(presoltiming))
result_dict = PyPresol.presolexec(nrounds, _ENUMS[PY_SCIP_PRESOLTIMING][presoltiming])
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
nfixedvars[0] += result_dict.get("nnewfixedvars", 0)
naggrvars[0] += result_dict.get("nnewaggrvars", 0)
Expand Down
8 changes: 4 additions & 4 deletions src/pyscipopt/propagator.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ cdef SCIP_RETCODE PyPropPresol (SCIP* scip, SCIP_PROP* prop, int nrounds, SCIP_P
result_dict["nupgdconss"] = nupgdconss[0]
result_dict["nchgcoefs"] = nchgcoefs[0]
result_dict["nchgsides"] = nchgsides[0]
result_dict["result"] = PY_SCIP_RESULT(result[0])
PyProp.proppresol(nrounds, PY_SCIP_PRESOLTIMING(presoltiming),
result_dict["result"] = _ENUMS[PY_SCIP_RESULT][result[0]]
PyProp.proppresol(nrounds, _ENUMS[PY_SCIP_PRESOLTIMING][presoltiming],
nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict)
result[0] = result_dict["result"]
Expand All @@ -138,7 +138,7 @@ cdef SCIP_RETCODE PyPropExec (SCIP* scip, SCIP_PROP* prop, SCIP_PROPTIMING propt
cdef SCIP_PROPDATA* propdata
propdata = SCIPpropGetData(prop)
PyProp = <Prop>propdata
returnvalues = PyProp.propexec(PY_SCIP_PROPTIMING(proptiming))
returnvalues = PyProp.propexec(_ENUMS[PY_SCIP_PROPTIMING][proptiming])
result_dict = returnvalues
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY
Expand All @@ -154,7 +154,7 @@ cdef SCIP_RETCODE PyPropResProp (SCIP* scip, SCIP_PROP* prop, SCIP_VAR* infervar
#TODO: parse bdchgidx?

PyProp = <Prop>propdata
returnvalues = PyProp.propresprop(confvar, inferinfo, PY_SCIP_BOUNDTYPE(boundtype), relaxedbd)
returnvalues = PyProp.propresprop(confvar, inferinfo, _ENUMS[PY_SCIP_BOUNDTYPE][boundtype], relaxedbd)
result_dict = returnvalues
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY
12 changes: 12 additions & 0 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ cdef extern from "scip/scip.h":
SCIP_RESULT SCIP_FOUNDSOL
SCIP_RESULT SCIP_SUSPENDED
SCIP_RESULT SCIP_SUCCESS
SCIP_RESULT SCIP_DELAYNODE

ctypedef int SCIP_STATUS
cdef extern from "scip/type_stat.h":
Expand Down Expand Up @@ -165,13 +166,18 @@ cdef extern from "scip/scip.h":
SCIP_PROPTIMING SCIP_PROPTIMING_DURINGLPLOOP
SCIP_PROPTIMING SCIP_PROPTIMING_AFTERLPLOOP
SCIP_PROPTIMING SCIP_PROPTIMING_AFTERLPNODE
SCIP_PROPTIMING SCIP_PROPTIMING_NONE
SCIP_PROPTIMING SCIP_PROPTIMING_ALWAYS

ctypedef unsigned long SCIP_PRESOLTIMING
cdef extern from "scip/type_timing.h":
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_NONE
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_FAST
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_MEDIUM
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_EXHAUSTIVE
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_FINAL
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_ALWAYS
SCIP_PRESOLTIMING SCIP_PRESOLTIMING_MAX

ctypedef unsigned long SCIP_HEURTIMING
cdef extern from "scip/type_timing.h":
Expand All @@ -186,6 +192,9 @@ cdef extern from "scip/scip.h":
SCIP_HEURTIMING SCIP_HEURTIMING_BEFOREPRESOL
SCIP_HEURTIMING SCIP_HEURTIMING_DURINGPRESOLLOOP
SCIP_HEURTIMING SCIP_HEURTIMING_AFTERPROPLOOP
SCIP_HEURTIMING SCIP_HEURTIMING_NONE
SCIP_HEURTIMING SCIP_HEURTIMING_AFTERNODE
SCIP_HEURTIMING SCIP_HEURTIMING_AFTERPLUNGE

ctypedef int SCIP_EXPR
cdef extern from "scip/type_expr.h":
Expand Down Expand Up @@ -257,6 +266,8 @@ cdef extern from "scip/scip.h":
SCIP_EVENTTYPE SCIP_EVENTTYPE_VARFIXED
SCIP_EVENTTYPE SCIP_EVENTTYPE_VARUNLOCKED
SCIP_EVENTTYPE SCIP_EVENTTYPE_OBJCHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_TYPECHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_IMPLTYPECHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_GLBCHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_GUBCHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_LBTIGHTENED
Expand Down Expand Up @@ -360,6 +371,7 @@ cdef extern from "scip/scip.h":
ctypedef int SCIP_ROWORIGINTYPE
cdef extern from "scip/type_lp.h":
SCIP_ROWORIGINTYPE SCIP_ROWORIGINTYPE_UNSPEC
SCIP_ROWORIGINTYPE SCIP_ROWORIGINTYPE_CONSHDLR
SCIP_ROWORIGINTYPE SCIP_ROWORIGINTYPE_CONS
SCIP_ROWORIGINTYPE SCIP_ROWORIGINTYPE_SEPA
SCIP_ROWORIGINTYPE SCIP_ROWORIGINTYPE_REOPT
Expand Down
Loading
Loading