Skip to content

Add extra args for includeconshdlr for new SCIP version #785

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

Merged
merged 9 commits into from
Feb 28, 2024
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run tests with coverage
env:
version: 8.0.3
version: 9.0.0

on:
push:
Expand All @@ -23,8 +23,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Integration test

env:
version: 8.0.3
version: 9.0.0

# runs on branches and pull requests; doesn't run on tags.
on:
Expand All @@ -22,8 +22,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: TestPyPI release

env:
version: 8.0.3
version: 9.0.0


# runs only when a release is published, not on drafts
Expand All @@ -17,8 +17,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb

- name: Setup python 3
uses: actions/setup-python@v4
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/update-packages-and-documentation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Test and Release PyPI Package

env:
version: 8.0.3
version: 9.0.0


# runs only when a release is published, not on drafts
Expand Down Expand Up @@ -38,8 +38,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -106,8 +106,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb

- name: Setup python 3
uses: actions/setup-python@v4
Expand Down
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 SCIP function addExprNonlinear
- Add support for Cython 3
- Added methods for getting the names of the current stage and of an event
- Add support for SCIP symmetry graph callbacks in constraint handlers
### Fixed
- Fixed README links
- Fixed outdated time.clock call in gcp.py
Expand Down
24 changes: 24 additions & 0 deletions src/pyscipopt/conshdlr.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ cdef class Conshdlr:
'''calls diving solution enforcement callback of constraint handler, if it exists '''
pass

def consgetpermsymgraph(self):
'''permutation symmetry detection graph getter callback, if it exists '''
pass

def consgetsignedpermsymgraph(self):
'''signed permutation symmetry detection graph getter callback, if it exists '''
pass


# local helper functions for the interface
cdef Conshdlr getPyConshdlr(SCIP_CONSHDLR* conshdlr):
Expand Down Expand Up @@ -452,3 +460,19 @@ cdef SCIP_RETCODE PyConsGetdivebdchgs (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP
success[0] = False
infeasible[0] = False
return SCIP_OKAY

cdef SCIP_RETCODE PyConsGetPermSymGraph (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph,
SCIP_Bool* success) noexcept with gil:
# TODO
PyConshdlr = getPyConshdlr(conshdlr)
PyConshdlr.consgetpermsymgraph()
success[0] = False
return SCIP_OKAY

cdef SCIP_RETCODE PyConsGetSignedPermSymGraph (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph,
SCIP_Bool* success) noexcept with gil:
# TODO
PyConshdlr = getPyConshdlr(conshdlr)
PyConshdlr.consgetsignedpermsymgraph()
success[0] = False
return SCIP_OKAY
5 changes: 5 additions & 0 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ cdef extern from "scip/scip.h":
ctypedef struct FILE:
pass

ctypedef struct SYM_GRAPH:
pass

ctypedef struct SCIP_READER:
pass

Expand Down Expand Up @@ -986,6 +989,8 @@ cdef extern from "scip/scip.h":
SCIP_RETCODE (*consgetvars) (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR** vars, int varssize, SCIP_Bool* success),
SCIP_RETCODE (*consgetnvars) (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, int* nvars, SCIP_Bool* success),
SCIP_RETCODE (*consgetdivebdchgs) (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_DIVESET* diveset, SCIP_SOL* sol, SCIP_Bool* success, SCIP_Bool* infeasible),
SCIP_RETCODE (*consgetpermsymgraph)(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph, SCIP_Bool* success),
SCIP_RETCODE (*consgetsignedpermsymgraph)(SCIP * scip, SCIP_CONSHDLR * conshdlr, SCIP_CONS * cons, SYM_GRAPH * graph, SCIP_Bool * success),
SCIP_CONSHDLRDATA* conshdlrdata)
SCIP_CONSHDLRDATA* SCIPconshdlrGetData(SCIP_CONSHDLR* conshdlr)
SCIP_CONSHDLR* SCIPfindConshdlr(SCIP* scip, const char* name)
Expand Down
2 changes: 1 addition & 1 deletion src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -3780,7 +3780,7 @@ cdef class Model:
PyConsInitsol, PyConsExitsol, PyConsDelete, PyConsTrans, PyConsInitlp, PyConsSepalp, PyConsSepasol,
PyConsEnfolp, PyConsEnforelax, PyConsEnfops, PyConsCheck, PyConsProp, PyConsPresol, PyConsResprop, PyConsLock,
PyConsActive, PyConsDeactive, PyConsEnable, PyConsDisable, PyConsDelvars, PyConsPrint, PyConsCopy,
PyConsParse, PyConsGetvars, PyConsGetnvars, PyConsGetdivebdchgs,
PyConsParse, PyConsGetvars, PyConsGetnvars, PyConsGetdivebdchgs, PyConsGetPermSymGraph, PyConsGetSignedPermSymGraph,
<SCIP_CONSHDLRDATA*>conshdlr))
conshdlr.model = <Model>weakref.proxy(self)
conshdlr.name = name
Expand Down
8 changes: 4 additions & 4 deletions tests/test_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_string():

m.optimize()

assert abs(m.getPrimalbound() - 1.6924910128) < 1.0e-6
assert abs(m.getPrimalbound() - 1.6924910128) < 1.0e-3

# test circle: find circle of smallest radius that encloses the given points
def test_circle():
Expand Down Expand Up @@ -136,9 +136,9 @@ def test_circle():
m.optimize()

bestsol = m.getBestSol()
assert abs(m.getSolVal(bestsol, r) - 5.2543) < 1.0e-3
assert abs(m.getSolVal(bestsol, a) - 6.1230) < 1.0e-3
assert abs(m.getSolVal(bestsol, b) - 5.4713) < 1.0e-3
assert abs(m.getSolVal(bestsol, r) - 5.2543) < 1.0e-2
assert abs(m.getSolVal(bestsol, a) - 6.1230) < 1.0e-2
assert abs(m.getSolVal(bestsol, b) - 5.4713) < 1.0e-2

# test gastrans: see example in <scip path>/examples/CallableLibrary/src/gastrans.c
# of course there is a more pythonic/elegant way of implementing this, probably
Expand Down