Skip to content

SCIP 10 #1009

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

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

SCIP 10 #1009

Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added support for knapsack constraints
- Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests
- Added SCIP_LOCKTYPE, addVarLocksType(), getNLocksDown(), getNLocksUp(), getNLocksDownType(), getNLocksUpType(), and tests
- Wrapped SCIPprintStatisticsJson
### Fixed
- Raised an error when an expression is used when a variable is required
### Changed
Expand Down
37 changes: 37 additions & 0 deletions src/pyscipopt/iisfinder.pxi
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##@file iisfinder.pxi
#@brief Base class of the Relaxator Plugin
cdef class IISFinder:
cdef public Model model
cdef public str name

def iisfinderfree(self):
'''calls destructor and frees memory of iis finder'''
pass

def iisfinderexec(self):
'''calls execution method of iis finder'''
raise NotImplementedError("iisfinderexec() is a fundamental callback and should be implemented in the derived class")


cdef SCIP_RETCODE PyIISFinderCopy (SCIP* scip, SCIP_IISFINDER* iisfinder) noexcept with gil:
return SCIP_OKAY

cdef SCIP_RETCODE PyIISFinderFree (SCIP* scip, SCIP_IISFINDER* iisfinder) noexcept with gil:
cdef SCIP_IISFINDERDATA* iisfinderdata
iisfinderdata = SCIPIISfinderGetData(iisfinder)
PyRelax = <Relax>iisfinderdata
PyRelax.iisfinderfree()
Py_DECREF(PyRelax)
return SCIP_OKAY

cdef SCIP_RETCODE PyRelaxExec (SCIP* scip, SCIP_IISFINDER* iisfinder, SCIP_Real* lowerbound, SCIP_RESULT* result) noexcept with gil:
cdef SCIP_IISFINDERDATA* iisfinderdata
iisfinderdata = SCIPiisfinderGetData(iisfinder)
PyRelax = <Relax>iisfinderdata
result_dict = PyRelax.iisfinderexec()
assert isinstance(result_dict, dict), "iisfinderexec() must return a dictionary."
#TODO
assert False
lowerbound[0] = result_dict.get("lowerbound", <SCIP_Real>lowerbound[0])
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY
7 changes: 4 additions & 3 deletions src/pyscipopt/reader.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ cdef SCIP_RETCODE PyReaderRead (SCIP* scip, SCIP_READER* reader, const char* fil

cdef SCIP_RETCODE PyReaderWrite (SCIP* scip, SCIP_READER* reader, FILE* file,
const char* name, SCIP_PROBDATA* probdata, SCIP_Bool transformed,
SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset,
SCIP_VAR** vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars,
SCIP_VAR** fixedvars, int nfixedvars, int startnvars,
SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset,
SCIP_RATIONAL* objoffsetexact, SCIP_RATIONAL* objscaleexact,
SCIP_VAR** vars, int nvars, int nbinvars, int nintvars, int nimplvars,
int ncontvars, SCIP_VAR** fixedvars, int nfixedvars, int startnvars,
SCIP_CONS** conss, int nconss, int maxnconss, int startnconss,
SCIP_Bool genericnames, SCIP_RESULT* result) noexcept with gil:
cdef SCIP_READERDATA* readerdata = SCIPreaderGetData(reader)
Expand Down
7 changes: 3 additions & 4 deletions src/pyscipopt/relax.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ cdef class Relax:
pass

def relaxexec(self):
'''callls execution method of relaxation handler'''
print("python error in relaxexec: this method needs to be implemented")
return{}

'''calls execution method of relaxation handler'''
print("relaxexec() is a fundamental callback and should be implemented in the derived class")
return {}

cdef SCIP_RETCODE PyRelaxCopy (SCIP* scip, SCIP_RELAX* relax) noexcept with gil:
return SCIP_OKAY
Expand Down
51 changes: 42 additions & 9 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,15 @@ cdef extern from "scip/scip.h":
SCIP_EVENTTYPE SCIP_EVENTTYPE_LHOLEADDED
SCIP_EVENTTYPE SCIP_EVENTTYPE_LHOLEREMOVED
SCIP_EVENTTYPE SCIP_EVENTTYPE_IMPLADDED
SCIP_EVENTTYPE SCIP_EVENTTYPE_TYPECHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_IMPLTYPECHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_PRESOLVEROUND
SCIP_EVENTTYPE SCIP_EVENTTYPE_NODEFOCUSED
SCIP_EVENTTYPE SCIP_EVENTTYPE_NODEFEASIBLE
SCIP_EVENTTYPE SCIP_EVENTTYPE_NODEINFEASIBLE
SCIP_EVENTTYPE SCIP_EVENTTYPE_NODEBRANCHED
SCIP_EVENTTYPE SCIP_EVENTTYPE_NODEDELETE
SCIP_EVENTTYPE SCIP_EVENTTYPE_DUALBOUNDIMPROVED
SCIP_EVENTTYPE SCIP_EVENTTYPE_FIRSTLPSOLVED
SCIP_EVENTTYPE SCIP_EVENTTYPE_LPSOLVED
SCIP_EVENTTYPE SCIP_EVENTTYPE_POORSOLFOUND
Expand Down Expand Up @@ -292,6 +295,7 @@ cdef extern from "scip/scip.h":
SCIP_EVENTTYPE SCIP_EVENTTYPE_LPEVENT
SCIP_EVENTTYPE SCIP_EVENTTYPE_SOLFOUND
SCIP_EVENTTYPE SCIP_EVENTTYPE_SOLEVENT
SCIP_EVENTTYPE SCIP_EVENTTYPE_GAPUPDATED
SCIP_EVENTTYPE SCIP_EVENTTYPE_ROWCHANGED
SCIP_EVENTTYPE SCIP_EVENTTYPE_ROWEVENT

Expand All @@ -304,6 +308,12 @@ cdef extern from "scip/scip.h":
cdef extern from "scip/type_var.h":
SCIP_LOCKTYPE SCIP_LOCKTYPE_MODEL
SCIP_LOCKTYPE SCIP_LOCKTYPE_CONFLICT

ctypedef int SCIP_IMPLINTTYPE
cdef extern from "scip/type_var.h":
SCIP_IMPLINTTYPE SCIP_IMPLINTTYPE_NONE
SCIP_IMPLINTTYPE SCIP_IMPLINTTYPE_WEAK
SCIP_IMPLINTTYPE SCIP_IMPLINTTYPE_STRONG

ctypedef int SCIP_BENDERSENFOTYPE
cdef extern from "scip/type_benders.h":
Expand Down Expand Up @@ -360,6 +370,9 @@ cdef extern from "scip/scip.h":

ctypedef double SCIP_Real

ctypedef struct SCIP_RATIONAL:
pass

ctypedef struct SCIP:
pass

Expand Down Expand Up @@ -426,6 +439,15 @@ cdef extern from "scip/scip.h":
ctypedef struct SCIP_HEURDATA:
pass

ctypedef struct SCIP_IISFINDER:
pass

ctypedef struct SCIP_IISFINDERDATA:
pass

ctypedef struct SCIP_IIS:
pass

ctypedef struct SCIP_RELAX:
pass

Expand Down Expand Up @@ -802,6 +824,11 @@ cdef extern from "scip/scip.h":
int SCIPgetNImplVars(SCIP* scip)
int SCIPgetNContVars(SCIP* scip)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR* var)
SCIP_Bool SCIPvarIsBinary(SCIP_VAR* var)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR* var)
SCIP_Bool SCIPvarIsImpliedIntegral(SCIP_VAR* var)
SCIP_Bool SCIPvarIsNonImpliedIntegral(SCIP_VAR* var)
SCIP_IMPLINTTYPE SCIPvarGetImplType(SCIP_VAR* var)
SCIP_Bool SCIPvarIsOriginal(SCIP_VAR* var)
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR* var)
SCIP_COL* SCIPvarGetCol(SCIP_VAR* var)
Expand Down Expand Up @@ -962,8 +989,9 @@ cdef extern from "scip/scip.h":
SCIP_RETCODE (*readerwrite) (SCIP* scip, SCIP_READER* reader, FILE* file,
const char* name, SCIP_PROBDATA* probdata, SCIP_Bool transformed,
SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset,
SCIP_VAR** vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars,
SCIP_VAR** fixedvars, int nfixedvars, int startnvars,
SCIP_RATIONAL* objoffsetexact, SCIP_RATIONAL* objscaleexact,
SCIP_VAR** vars, int nvars, int nbinvars, int nintvars, int nimplvars,
int ncontvars, SCIP_VAR** fixedvars, int nfixedvars, int startnvars,
SCIP_CONS** conss, int nconss, int maxnconss, int startnconss,
SCIP_Bool genericnames, SCIP_RESULT* result),
SCIP_READERDATA* readerdata)
Expand Down Expand Up @@ -1156,6 +1184,16 @@ cdef extern from "scip/scip.h":
SCIP_HEURTIMING SCIPheurGetTimingmask(SCIP_HEUR* heur)
void SCIPheurSetTimingmask(SCIP_HEUR* heur, SCIP_HEURTIMING timingmask)

# #IIS finder plugin
# SCIP_RETCODE SCIPincludeIISFinder(SCIP* scip,
# const char* name,
# const char* desc,
# int priority,
# SCIP_RETCODE (*iisfindercopy) (SCIP* scip, SCIP_IISFINDER* iisfinder),
# SCIP_RETCODE (*iisfinderfree) (SCIP* scip, SCIP_IISFINDER* iisfinder),
# SCIP_RETCODE (*iisfinderexec) (SCIP_IIS* iis, SCIP_IISFINDER* iisfinder, SCIP_Real timelim, SCIP_Longint nodelim, SCIP_Bool removebounds, SCIP_Bool silent, SCIP_RESULT* result),
# SCIP_IISFINDERDATA* iisfinderdata)

#Relaxation plugin
SCIP_RETCODE SCIPincludeRelax(SCIP* scip,
const char* name,
Expand Down Expand Up @@ -1357,6 +1395,7 @@ cdef extern from "scip/scip.h":

# Statistic Methods
SCIP_RETCODE SCIPprintStatistics(SCIP* scip, FILE* outfile)
SCIP_RETCODE SCIPprintStatisticsJson(SCIP* scip, FILE* file)
SCIP_Longint SCIPgetNNodes(SCIP* scip)
SCIP_Longint SCIPgetNTotalNodes(SCIP* scip)
SCIP_Longint SCIPgetNFeasibleLeaves(SCIP* scip)
Expand Down Expand Up @@ -1429,11 +1468,6 @@ cdef extern from "scip/scip.h":

BMS_BLKMEM* SCIPblkmem(SCIP* scip)

# pub_misc.h
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP** hashmap, BMS_BLKMEM* blkmem, int mapsize)
void SCIPhashmapFree(SCIP_HASHMAP** hashmap)


cdef extern from "scip/tree.h":
int SCIPnodeGetNAddedConss(SCIP_NODE* node)

Expand Down Expand Up @@ -1591,7 +1625,6 @@ cdef extern from "scip/cons_sos1.h":
SCIP_CONS* cons,
SCIP_VAR* var)


cdef extern from "scip/cons_sos2.h":
SCIP_RETCODE SCIPcreateConsSOS2(SCIP* scip,
SCIP_CONS** cons,
Expand Down Expand Up @@ -1689,6 +1722,7 @@ cdef extern from "scip/cons_xor.h":
SCIP_Bool dynamic,
SCIP_Bool removable,
SCIP_Bool stickingatnode)

cdef extern from "scip/scip_cons.h":
SCIP_RETCODE SCIPprintCons(SCIP* scip,
SCIP_CONS* cons,
Expand Down Expand Up @@ -1843,7 +1877,6 @@ cdef extern from "scip/scip_nlp.h":
SCIP_RETCODE SCIPgetNlRowActivityBounds(SCIP* scip, SCIP_NLROW* nlrow, SCIP_Real* minactivity, SCIP_Real* maxactivity)
SCIP_RETCODE SCIPprintNlRow(SCIP* scip, SCIP_NLROW* nlrow, FILE* file)


cdef extern from "scip/cons_cardinality.h":
SCIP_RETCODE SCIPcreateConsCardinality(SCIP* scip,
SCIP_CONS** cons,
Expand Down
Loading