Skip to content

Commit

Permalink
update to cython 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgen-lentz committed Dec 22, 2023
1 parent d7ce949 commit 5c93cee
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 28 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build==0.7.0
Cython==0.29.35
Cython>=3.0.0
wheel==0.40.0
pyscipopt==4.4.0
pyscipopt>=4.4.0
18 changes: 9 additions & 9 deletions src/pygcgopt/detector.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ cdef wrap_detector_callback_result(Detector detector, PARTIALDEC_DETECTION_DATA*
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])


cdef SCIP_RETCODE PyDetectorFree (SCIP* scip, DEC_DETECTOR* detector):
cdef SCIP_RETCODE PyDetectorFree (SCIP* scip, DEC_DETECTOR* detector) noexcept:
py_detector = get_py_detector(detector)
py_detector.freeDetector()
Py_DECREF(py_detector)
return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorInit (SCIP* scip, DEC_DETECTOR* detector):
cdef SCIP_RETCODE PyDetectorInit (SCIP* scip, DEC_DETECTOR* detector) noexcept:
py_detector = get_py_detector(detector)
py_detector.initDetector()
return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorExit (SCIP* scip, DEC_DETECTOR* detector):
cdef SCIP_RETCODE PyDetectorExit (SCIP* scip, DEC_DETECTOR* detector) noexcept:
py_detector = get_py_detector(detector)
py_detector.exitDetector()
return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorPropagatePartialdec (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result):
cdef SCIP_RETCODE PyDetectorPropagatePartialdec (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) noexcept:
cdef SCIP_CLOCK* clock = start_new_clock(scip)

py_detector = get_py_detector(detector)
Expand All @@ -104,7 +104,7 @@ cdef SCIP_RETCODE PyDetectorPropagatePartialdec (SCIP* scip, DEC_DETECTOR* detec

return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorFinishPartialdec (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result):
cdef SCIP_RETCODE PyDetectorFinishPartialdec (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) noexcept:
cdef SCIP_CLOCK* clock = start_new_clock(scip)

py_detector = get_py_detector(detector)
Expand All @@ -117,7 +117,7 @@ cdef SCIP_RETCODE PyDetectorFinishPartialdec (SCIP* scip, DEC_DETECTOR* detector

return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorPostprocessPartialdec (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result):
cdef SCIP_RETCODE PyDetectorPostprocessPartialdec (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) noexcept:
cdef SCIP_CLOCK* clock = start_new_clock(scip)

py_detector = get_py_detector(detector)
Expand All @@ -130,19 +130,19 @@ cdef SCIP_RETCODE PyDetectorPostprocessPartialdec (SCIP* scip, DEC_DETECTOR* det

return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorSetParamAggressive (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result):
cdef SCIP_RETCODE PyDetectorSetParamAggressive (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) noexcept:
py_detector = get_py_detector(detector)
result_dict = py_detector.setParamAggressive() or {}
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorSetParamDefault (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result):
cdef SCIP_RETCODE PyDetectorSetParamDefault (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) noexcept:
py_detector = get_py_detector(detector)
result_dict = py_detector.setParamDefault() or {}
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
return SCIP_OKAY

cdef SCIP_RETCODE PyDetectorSetParamFast (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result):
cdef SCIP_RETCODE PyDetectorSetParamFast (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) noexcept:
py_detector = get_py_detector(detector)
result_dict = py_detector.setParamFast() or {}
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
Expand Down
44 changes: 35 additions & 9 deletions src/pygcgopt/gcg.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,33 @@ cdef extern from "gcg/gcg.h":
int nnewpartialdecs
double detectiontime

SCIP_RETCODE DECincludeDetector(SCIP* scip, const char* name, const char decchar, const char* description, int freqCallRound, int maxCallRound, int minCallRound, int freqCallRoundOriginal, int maxCallRoundOriginal, int minCallRoundOriginal, int priority, SCIP_Bool enabled, SCIP_Bool enabledFinishing, SCIP_Bool enabledPostprocessing, SCIP_Bool skip, SCIP_Bool usefulRecall, DEC_DETECTORDATA *detectordata, SCIP_RETCODE (*freeDetector) (SCIP* scip, DEC_DETECTOR* detector), SCIP_RETCODE (*initDetector) (SCIP* scip, DEC_DETECTOR* detector), SCIP_RETCODE (*exitDetector) (SCIP* scip, DEC_DETECTOR* detector), SCIP_RETCODE (*propagatePartialdecDetector) (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result), SCIP_RETCODE (*finishPartialdecDetector) (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result), SCIP_RETCODE (*postprocessPartialdecDetector) (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result), SCIP_RETCODE (*setParamAggressiveDetector) (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result), SCIP_RETCODE (*setParamDefaultDetector) (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result), SCIP_RETCODE (*setParamFastDetector) (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result))
SCIP_RETCODE DECincludeDetector(
SCIP* scip, const char* name,
const char decchar,
const char* description,
int freqCallRound,
int maxCallRound,
int minCallRound,
int freqCallRoundOriginal,
int maxCallRoundOriginal,
int minCallRoundOriginal,
int priority,
SCIP_Bool enabled,
SCIP_Bool enabledFinishing,
SCIP_Bool enabledPostprocessing,
SCIP_Bool skip,
SCIP_Bool usefulRecall,
DEC_DETECTORDATA *detectordata,
SCIP_RETCODE (*freeDetector) (SCIP* scip, DEC_DETECTOR* detector) noexcept,
SCIP_RETCODE (*initDetector) (SCIP* scip, DEC_DETECTOR* detector) noexcept,
SCIP_RETCODE (*exitDetector) (SCIP* scip, DEC_DETECTOR* detector) noexcept,
SCIP_RETCODE (*propagatePartialdecDetector) (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) noexcept,
SCIP_RETCODE (*finishPartialdecDetector) (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) noexcept,
SCIP_RETCODE (*postprocessPartialdecDetector) (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) noexcept,
SCIP_RETCODE (*setParamAggressiveDetector) (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) noexcept,
SCIP_RETCODE (*setParamDefaultDetector) (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) noexcept,
SCIP_RETCODE (*setParamFastDetector) (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) noexcept
)

DEC_DETECTORDATA* DECdetectorGetData(DEC_DETECTOR* detector)

Expand Down Expand Up @@ -103,14 +129,14 @@ cdef extern from "gcg/pricer_gcg.h":
int priority,
SCIP_Bool heurenabled,
SCIP_Bool exactenabled,
SCIP_RETCODE (*solverupdate) (SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged, SCIP_Bool consschanged),
SCIP_RETCODE (*solversolve) (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status),
SCIP_RETCODE (*solveheur) (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status),
SCIP_RETCODE (*solverfree) (SCIP* scip, GCG_SOLVER* solver),
SCIP_RETCODE (*solverinit) (SCIP* scip, GCG_SOLVER* solver),
SCIP_RETCODE (*solverexit) (SCIP* scip, GCG_SOLVER* solver),
SCIP_RETCODE (*solverinitsol) (SCIP* scip, GCG_SOLVER* solver),
SCIP_RETCODE (*solverexitsol) (SCIP* scip, GCG_SOLVER* solver),
SCIP_RETCODE (*solverupdate) (SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged, SCIP_Bool consschanged) noexcept,
SCIP_RETCODE (*solversolve) (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status) noexcept,
SCIP_RETCODE (*solveheur) (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status) noexcept,
SCIP_RETCODE (*solverfree) (SCIP* scip, GCG_SOLVER* solver) noexcept,
SCIP_RETCODE (*solverinit) (SCIP* scip, GCG_SOLVER* solver) noexcept,
SCIP_RETCODE (*solverexit) (SCIP* scip, GCG_SOLVER* solver) noexcept,
SCIP_RETCODE (*solverinitsol) (SCIP* scip, GCG_SOLVER* solver) noexcept,
SCIP_RETCODE (*solverexitsol) (SCIP* scip, GCG_SOLVER* solver) noexcept,
GCG_SOLVERDATA* solverdata
)
GCG_SOLVER** GCGpricerGetSolvers(SCIP* scip)
Expand Down
16 changes: 8 additions & 8 deletions src/pygcgopt/pricing_solver.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,45 @@ cdef PricingSolver get_py_pricing_solver(GCG_SOLVER* pricingSolver):
return py_pricing_solver


cdef SCIP_RETCODE PyPricingSolverFree (SCIP* scip, GCG_SOLVER* solver):
cdef SCIP_RETCODE PyPricingSolverFree (SCIP* scip, GCG_SOLVER* solver) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricing_solver.freeSolver()
Py_DECREF(py_pricing_solver)
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverInit (SCIP* scip, GCG_SOLVER* solver):
cdef SCIP_RETCODE PyPricingSolverInit (SCIP* scip, GCG_SOLVER* solver) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricing_solver.initSolver()
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverExit (SCIP* scip, GCG_SOLVER* solver):
cdef SCIP_RETCODE PyPricingSolverExit (SCIP* scip, GCG_SOLVER* solver) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricing_solver.exitSolver()
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverInitSol (SCIP* scip, GCG_SOLVER* solver):
cdef SCIP_RETCODE PyPricingSolverInitSol (SCIP* scip, GCG_SOLVER* solver) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricing_solver.initSolution()
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverExitSol (SCIP* scip, GCG_SOLVER* solver):
cdef SCIP_RETCODE PyPricingSolverExitSol (SCIP* scip, GCG_SOLVER* solver) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricing_solver.exitSolution()
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverUpdate (SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged, SCIP_Bool consschanged):
cdef SCIP_RETCODE PyPricingSolverUpdate (SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged, SCIP_Bool consschanged) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricingprob = GCGPricingModel.create(pricingprob)
py_pricing_solver.updateSolver(py_pricingprob, probnr, varobjschanged, varbndschanged, consschanged)
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverSolve (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status):
cdef SCIP_RETCODE PyPricingSolverSolve (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricingprob = GCGPricingModel.create(pricingprob)
result_dict = py_pricing_solver.solve(py_pricingprob, probnr, dualsolconv)
Expand All @@ -83,7 +83,7 @@ cdef SCIP_RETCODE PyPricingSolverSolve (SCIP* scip, SCIP* pricingprob, GCG_SOLVE
return SCIP_OKAY


cdef SCIP_RETCODE PyPricingSolverSolveHeur (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status):
cdef SCIP_RETCODE PyPricingSolverSolveHeur (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status) noexcept:
py_pricing_solver = get_py_pricing_solver(solver)
py_pricingprob = GCGPricingModel.create(pricingprob)
result_dict = py_pricing_solver.solveHeuristic(py_pricingprob, probnr, dualsolconv)
Expand Down

0 comments on commit 5c93cee

Please sign in to comment.