Skip to content
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

Version 0.4.0 #29

Merged
merged 47 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3305089
init consclassifier
jurgen-lentz Feb 9, 2022
3bd2056
add classify parameter transformed
jurgen-lentz Feb 9, 2022
a132c77
update classify
jurgen-lentz Feb 9, 2022
44e1196
init varclassifier
jurgen-lentz Feb 11, 2022
5b0f94e
fix pygcgopt warnings
jurgen-lentz Feb 11, 2022
942c945
add VarPart functions
jurgen-lentz Feb 12, 2022
63c00b6
add header for VarPartition and ConsPartition
jurgen-lentz Feb 12, 2022
5fd69dd
start cleaning class ConsPart
jurgen-lentz Feb 12, 2022
3bcb319
add some docstrings to ConsPart methods
jurgen-lentz Feb 12, 2022
1644c3f
add methods of VarPart
jurgen-lentz Feb 13, 2022
fff3a4d
Create gitlab-mirror.yml
jurgen-lentz Feb 13, 2022
b1be319
add more docstrings
jurgen-lentz Feb 13, 2022
2c15d44
add more docstrings
jurgen-lentz Feb 13, 2022
327bc43
add more docstrings
jurgen-lentz Feb 14, 2022
2ecb0a2
more documentation
jurgen-lentz Feb 17, 2022
bf12ad5
add more docstrings
jurgen-lentz Feb 19, 2022
e1f5261
clean detprobdata methods
jurgen-lentz Feb 21, 2022
32aec1c
add docstrings to class DetProbData
jurgen-lentz Feb 21, 2022
e51d1ec
fix bug in VarPart
jurgen-lentz Feb 21, 2022
2e94137
add score plugin
jurgen-lentz Jun 3, 2022
cf5f4cd
more score functions
jurgen-lentz Jun 3, 2022
974f7f2
improve test
jurgen-lentz Jun 7, 2022
965a9c7
improve tests
jurgen-lentz Jun 14, 2022
061e675
Merge remote-tracking branch 'origin/classifier' into alpha
jurgen-lentz Jul 3, 2022
a710a2b
Merge branch 'alpha' into score-plugin
jurgen-lentz Jul 3, 2022
4174412
Merge pull request #12 from scipopt/score-plugin
jurgen-lentz Jul 3, 2022
ab5654a
add methods and use GCG instead of DEC
jurgen-lentz Feb 26, 2023
5084118
improve test and add some methods
jurgen-lentz Mar 11, 2023
a3cb774
improve decomposition
jurgen-lentz Mar 30, 2023
4b7eec3
improve partdecomp
jurgen-lentz Apr 1, 2023
a77fbbc
add more improvements
jurgen-lentz Apr 2, 2023
085a6e8
new ci init
jurgen-lentz Apr 2, 2023
dbe7916
move action
jurgen-lentz Apr 2, 2023
bf65379
append documentation
jurgen-lentz Apr 2, 2023
5721330
cleaning decomposition
jurgen-lentz Apr 2, 2023
7c56619
improve varclassifier and start with test
jurgen-lentz Apr 3, 2023
a9a11f2
improve consclassifier
jurgen-lentz Apr 3, 2023
b2dd016
fix bugs
jurgen-lentz Apr 3, 2023
885c35d
classifier test first version
jurgen-lentz Apr 4, 2023
5690673
improve setup.py
jurgen-lentz Jul 29, 2023
a45d7bc
comment methods
jurgen-lentz Jul 29, 2023
cd4a641
update install.md for windows
jurgen-lentz Jul 29, 2023
8196a27
pass classifier test
jurgen-lentz Jul 29, 2023
9d8d804
Merge branch 'master' into alpha
jurgen-lentz Feb 27, 2024
a8bd9cc
init version 0.5.0
jurgen-lentz Feb 27, 2024
03c09ff
improve scipoptsuite download
jurgen-lentz Feb 28, 2024
b67b649
use 0.4.0
jurgen-lentz Feb 29, 2024
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
6 changes: 3 additions & 3 deletions .github/actions/setup-scipoptsuite-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
version:
description: "SCIPOptSuite version to install"
required: true
default: "8.1.0"
default: "9.0.0"

runs:
using: "composite"
Expand All @@ -17,6 +17,6 @@ runs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --timestamping --directory-prefix=$HOME https://scipopt.org/download/release/SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu.deb
sudo apt-get install -y ~/SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{inputs.version}}" | tr -d '.')/SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ inputs.version }}-Linux-ubuntu20.deb
shell: bash
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
### Changed
### Removed

## v0.4.0
### Added
* added support for Windows
* added score plugin type
* added constraint classifier plugin type
* added variable classifier plugin type
* added class ConsPart
* added class VarPart
* added tests for score and classifier

## v0.3.1
### Update
* support cython 3.0.0
Expand Down
15 changes: 11 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Note that the latest PyGCGOpt version is usually only compatible with the latest

|SCIP| PySCIPOpt | GCG | PyGCGOpt
|----|----|----|----|
9.0 | | 3.6.0 | 0.4.0 |
8.1 | 4.4 | 3.5.5 | 0.3.0 |
8.0 | 4.0 | 3.5.0 | 0.1.0 |
7.0 | 3.x | - | - |
Expand All @@ -27,7 +28,7 @@ Note that the latest PyGCGOpt version is usually only compatible with the latest
4.0 | 1.2, 1.1 | - | - |
3.2 | 1.0 | - | - |

We recommend installing PyGCGOpt and its Python dependencies in a [Python virtual environment](https://docs.python.org/3/tutorial/venv.html). In short, you can create a virtual environment and activate it with the following commands on Linux and macOS:
We recommend installing PyGCGOpt and its Python dependencies in a [Python virtual environment](https://docs.python.org/3/tutorial/venv.html). In short, you can create a virtual environment and activate it with the following commands on Linux, macOS and Windows:
```
python3.9 -m venv venv
source venv/bin/activate
Expand All @@ -48,14 +49,18 @@ To install the SCIPOptSuite from source, you need to [install SCIP and GCG using
As an example, from the root directory of the source distribution of the SCIPOptSuite, you can run the following commands to build and install locally:
```
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DSHARED=on -DCMAKE_INSTALL_PREFIX=./install -DGCG_DEV_BUILD=on -DZIMPL=OFF -DIPOPT=OFF -DPAPILO=OFF
cmake .. -DCMAKE_BUILD_TYPE=Debug -DSHARED=on -DCMAKE_INSTALL_PREFIX=./install -DGCG_DEV_BUILD=ON -DZIMPL=OFF -DIPOPT=OFF -DPAPILO=OFF
make -j4 && make install
```

If SCIP and GCG are not installed in the global path, you need to specify the install location using the environment variable `SCIPOPTDIR` before you can install PySCIPOpt and PyGCGOpt:

`export SCIPOPTDIR=<path_to_install_dir>`

- On Linux and macOS:\
`export SCIPOPTDIR=<path_to_install_dir>`
- On Windows:\
`set SCIPOPTDIR=<path_to_install_dir>` (**cmd**, **Cmder**, **WSL**)\
`$Env:SCIPOPTDIR = "<path_to_install_dir>"` (**powershell**)

`SCIPOPTDIR` needs to have a subdirectory `lib` that contains the
library, e.g. `libscip.so` and `libgcg.so` (for Linux) and a subdirectory `include` that
contains the corresponding header files:
Expand All @@ -78,6 +83,8 @@ To make the shared libraries available at runtime for PySCIPOpt and PyGCGOpt, yo
`export LD_LIBRARY_PATH=<path_to_install_dir>/lib`
- On macOS:
`export DYLD_FALLBACK_LIBRARY_PATH=<path_to_install_dir>/lib`
- On Windows:
`set PATH=%PATH%;<path_to_install_dir>\bin`


## Installing PySCIPOpt from PyPI
Expand Down
8 changes: 8 additions & 0 deletions docs/api/classifier.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Classifier
**********

.. autoclass:: pygcgopt.gcg.ConsClassifier
:members:

.. autoclass:: pygcgopt.gcg.VarClassifier
:members:
5 changes: 4 additions & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ API Reference
.. toctree::

model.rst
classifier.rst
decomposition.rst
detprobdata.rst
detector.rst
pricingsolver.rst
partition.rst
pricingsolver.rst
score.rst
8 changes: 8 additions & 0 deletions docs/api/partition.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Partition
*********

.. autoclass:: pygcgopt.gcg.ConsPart
:members:

.. autoclass:: pygcgopt.gcg.VarPart
:members:
5 changes: 5 additions & 0 deletions docs/api/score.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Score
*****

.. autoclass:: pygcgopt.gcg.Score
:members:
34 changes: 18 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
# assume that SCIP is installed on the system
includedirs.append(os.path.abspath(os.path.join(optdir, 'include')))

# Current release of GCG has broken folder structure when installed. All GCG sources *should* be in a `gcg` subfolder in the sources. Until this is fixed, we need to include the `gcg` folder so that imports work.
if os.path.exists(os.path.join(gcgoptdir, 'include')) and not os.path.exists(os.path.join(gcgoptdir, 'include', 'graph')):
includedirs.append(os.path.abspath(os.path.join(gcgoptdir, 'include', 'gcg')))
if not gcgoptdir:
if platform.system() == 'Linux':
includedirs.append("/usr/include/gcg")
Expand All @@ -32,21 +29,27 @@


# determine scip library
if os.path.exists(os.path.join(scipoptdir, 'lib/shared/libscipsolver.so')):
if os.path.exists(os.path.join(scipoptdir, "lib", "shared", "libscip.so")):
# SCIP seems to be created with make
sciplibdir = os.path.abspath(os.path.join(scipoptdir, 'lib/shared'))
sciplibname = 'scipsolver'
extra_compile_args.append('-DNO_CONFIG_HEADER')
sciplibdir = os.path.abspath(os.path.join(scipoptdir, "lib", "shared"))
sciplibname = "scip"
extra_compile_args.append("-DNO_CONFIG_HEADER")
# the following is a temporary hack to make it compile with SCIP/make:
extra_compile_args.append("-DTPI_NONE") # if other TPIs are used, please modify
else:
# assume that SCIP is installed on the system
sciplibdir = os.path.abspath(os.path.join(scipoptdir, 'lib'))
sciplibname = 'scip'
if platform.system() in ['Windows']:
sciplibname = 'libscip'
sciplibdir = os.path.abspath(os.path.join(scipoptdir, "lib"))
sciplibname = "libscip" if platform.system() in ["Windows"] else "scip"

# setup gcg library
gcglibdir = os.path.abspath(os.path.join(gcgoptdir, "lib"))
gcglibname = "gcg"
# determine gcg library
if os.path.exists(os.path.join(gcgoptdir, "lib", "shared", "libgcg.so")):
# SCIP seems to be created with make
gcglibdir = os.path.abspath(os.path.join(gcgoptdir, "lib", "shared"))
gcglibname = "gcg"
else:
# assume that SCIP is installed on the system
gcglibdir = os.path.abspath(os.path.join(gcgoptdir, "lib"))
gcglibname = "libgcg" if platform.system() in ["Windows"] else "gcg"

print('Using SCIP library <%s> at <%s>.' % (sciplibname, sciplibdir))
print('Using GCG library <%s> at <%s>.' % (gcglibname, gcglibdir))
Expand Down Expand Up @@ -82,8 +85,7 @@

ext = '.pyx' if use_cython else '.cpp'

if platform.system() == 'Darwin':
extra_compile_args.append("-std=c++11")
extra_compile_args.append("-std=c++11")

extensions = [Extension('pygcgopt.gcg', [os.path.join(packagedir, 'gcg'+ext)],
include_dirs=includedirs,
Expand Down
76 changes: 42 additions & 34 deletions src/pygcgopt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.3.1'
__version__ = '0.4.0'

# required for Python 3.8 on Windows
import os
Expand All @@ -7,39 +7,47 @@
os.add_dll_directory(os.path.join(os.getenv('SCIPOPTDIR').strip('"'), 'bin'))

# Expose pyscipopt object through pygcgopt
from pyscipopt import multidict
from pyscipopt import Benders
from pyscipopt import Benderscut
from pyscipopt import Branchrule
from pyscipopt import Nodesel
from pyscipopt import Conshdlr
from pyscipopt import Eventhdlr
from pyscipopt import Heur
from pyscipopt import Presol
from pyscipopt import Pricer
from pyscipopt import Prop
from pyscipopt import Sepa
from pyscipopt import LP
from pyscipopt import Expr
from pyscipopt import quicksum
from pyscipopt import quickprod
from pyscipopt import exp
from pyscipopt import log
from pyscipopt import sqrt
from pyscipopt import SCIP_RESULT
from pyscipopt import SCIP_PARAMSETTING
from pyscipopt import SCIP_PARAMEMPHASIS
from pyscipopt import SCIP_STATUS
from pyscipopt import SCIP_STAGE
from pyscipopt import SCIP_PROPTIMING
from pyscipopt import SCIP_PRESOLTIMING
from pyscipopt import SCIP_HEURTIMING
from pyscipopt import SCIP_EVENTTYPE
from pyscipopt import SCIP_LPSOLSTAT
from pyscipopt import SCIP_BRANCHDIR
from pyscipopt import SCIP_BENDERSENFOTYPE
from pyscipopt import SCIP_ROWORIGINTYPE
from pyscipopt import multidict
from pyscipopt import Benders
from pyscipopt import Benderscut
from pyscipopt import Branchrule
from pyscipopt import Nodesel
from pyscipopt import Conshdlr
from pyscipopt import Eventhdlr
from pyscipopt import Heur
from pyscipopt import Presol
from pyscipopt import Pricer
from pyscipopt import Prop
from pyscipopt import Sepa
from pyscipopt import LP
from pyscipopt import Expr
from pyscipopt import quicksum
from pyscipopt import quickprod
from pyscipopt import exp
from pyscipopt import log
from pyscipopt import sqrt
from pyscipopt import SCIP_RESULT
from pyscipopt import SCIP_PARAMSETTING
from pyscipopt import SCIP_PARAMEMPHASIS
from pyscipopt import SCIP_STATUS
from pyscipopt import SCIP_STAGE
from pyscipopt import SCIP_PROPTIMING
from pyscipopt import SCIP_PRESOLTIMING
from pyscipopt import SCIP_HEURTIMING
from pyscipopt import SCIP_EVENTTYPE
from pyscipopt import SCIP_LPSOLSTAT
from pyscipopt import SCIP_BRANCHDIR
from pyscipopt import SCIP_BENDERSENFOTYPE
from pyscipopt import SCIP_ROWORIGINTYPE

# export user-relevant objects
from pygcgopt.gcg import Model, Detector, PricingSolver
from pygcgopt.gcg import Model
from pygcgopt.gcg import Detector
from pygcgopt.gcg import PricingSolver
from pygcgopt.gcg import ConsClassifier
from pygcgopt.gcg import VarClassifier
from pygcgopt.gcg import Score
from pygcgopt.gcg import PY_GCG_PRICINGSTATUS as GCG_PRICINGSTATUS
from pygcgopt.gcg import PY_CONS_DECOMPINFO as CONS_DECOMPINFO
from pygcgopt.gcg import PY_VAR_DECOMPINFO as VAR_DECOMPINFO
from pygcgopt.gcg import PY_USERGIVEN as USERGIVEN
34 changes: 34 additions & 0 deletions src/pygcgopt/consclassifier.pxi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cdef class ConsClassifier:
"""Base class of the Constraint Classifier Plugin"""
cdef public Model model
cdef public str name

def freeConsClassifier(self):
'''calls destructor and frees memory of constraint classifier'''
pass

def classify(self, conss, partition):
pass

cdef SCIP_RETCODE PyConsClassifierFree(SCIP* scip, GCG_CONSCLASSIFIER* consclassifier) noexcept with gil:
cdef GCG_CLASSIFIERDATA* consclassifierdata
consclassifierdata = GCGconsClassifierGetData(consclassifier)
py_consclassifier = <ConsClassifier>consclassifierdata
py_consclassifier.freeConsClassifier()
Py_DECREF(py_consclassifier)
return SCIP_OKAY

cdef SCIP_RETCODE PyConsClassifierClassify(SCIP* scip, GCG_CONSCLASSIFIER* consclassifier, SCIP_Bool transformed) noexcept with gil:
cdef GCG_CLASSIFIERDATA* consclassifierdata
consclassifierdata = GCGconsClassifierGetData(consclassifier)
py_consclassifier = <ConsClassifier>consclassifierdata
if transformed:
detprobdata = py_consclassifier.model.getDetprobdataPresolved()
else:
detprobdata = py_consclassifier.model.getDetprobdataOrig()
conss = detprobdata.getRelevantConss()
partition = detprobdata.createConsPart(py_consclassifier.name, 0, len(conss))
py_consclassifier.classify(conss, partition)
print("Consclassifier {0} yields a classification with {1} different constraint classes".format(partition.getName(), partition.getNClasses()))
detprobdata.addConsPartition(partition)
return SCIP_OKAY
Loading
Loading