Skip to main content

Python interface and modeling environment for SCIP

Project description

PySCIPOpt

This project provides an interface from Python to the SCIP Optimization Suite. Starting from v8.0.3, SCIP uses the Apache2.0 license. If you plan to use an earlier version of SCIP, please review SCIP's license restrictions.

Gitter PySCIPOpt on PyPI Integration test coverage AppVeyor Status

Documentation

Please consult the online documentation or use the help() function directly in Python or ? in IPython/Jupyter.

See CHANGELOG.md for added, removed or fixed functionality.

Installation

Using Conda

Conda version Conda platforms

DO NOT USE THE CONDA BASE ENVIRONMENT TO INSTALL PYSCIPOPT.

Conda will install SCIP automatically, hence everything can be installed in a single command:

conda install --channel conda-forge pyscipopt

Using PyPI and from Source

See INSTALL.md for instructions. Please note that the latest PySCIPOpt version is usually only compatible with the latest major release of the SCIP Optimization Suite. The following table summarizes which version of PySCIPOpt is required for a given SCIP version:

SCIP PySCIPOpt
9.1 5.1+
9.0 5.0.x
8.0 4.x
7.0 3.x
6.0 2.x
5.0 1.4, 1.3
4.0 1.2, 1.1
3.2 1.0

Information which version of PySCIPOpt is required for a given SCIP version can also be found in INSTALL.md.

Building and solving a model

There are several examples and tutorials. These display some functionality of the interface and can serve as an entry point for writing more complex code. Some of the common usecases are also available in the recipes sub-package. You might also want to have a look at this article about PySCIPOpt: https://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/6045. The following steps are always required when using the interface:

  1. It is necessary to import python-scip in your code. This is achieved by including the line
from pyscipopt import Model
  1. Create a solver instance.
model = Model("Example")  # model name is optional
  1. Access the methods in the scip.pxi file using the solver/model instance model, e.g.:
x = model.addVar("x")
y = model.addVar("y", vtype="INTEGER")
model.setObjective(x + y)
model.addCons(2*x - y*y >= 0)
model.optimize()
sol = model.getBestSol()
print("x: {}".format(sol[x]))
print("y: {}".format(sol[y]))

Writing new plugins

The Python interface can be used to define custom plugins to extend the functionality of SCIP. You may write a pricer, heuristic or even constraint handler using pure Python code and SCIP can call their methods using the callback system. Every available plugin has a base class that you need to extend, overwriting the predefined but empty callbacks. Please see test_pricer.py and test_heur.py for two simple examples.

Please notice that in most cases one needs to use a dictionary to specify the return values needed by SCIP.

Extending the interface

PySCIPOpt already covers many of the SCIP callable library methods. You may also extend it to increase the functionality of this interface. The following will provide some directions on how this can be achieved:

The two most important files in PySCIPOpt are the scip.pxd and scip.pxi. These two files specify the public functions of SCIP that can be accessed from your python code.

To make PySCIPOpt aware of the public functions you would like to access, you must add them to scip.pxd. There are two things that must be done in order to properly add the functions:

  1. Ensure any enums, structs or SCIP variable types are included in scip.pxd
  2. Add the prototype of the public function you wish to access to scip.pxd

After following the previous two steps, it is then possible to create functions in python that reference the SCIP public functions included in scip.pxd. This is achieved by modifying the scip.pxi file to add the functionality you require.

We are always happy to accept pull request containing patches or extensions!

Please have a look at our contribution guidelines.

Gotchas

Ranged constraints

While ranged constraints of the form

lhs <= expression <= rhs

are supported, the Python syntax for chained comparisons can't be hijacked with operator overloading. Instead, parenthesis must be used, e.g.,

lhs <= (expression <= rhs)

Alternatively, you may call model.chgRhs(cons, newrhs) or model.chgLhs(cons, newlhs) after the single-sided constraint has been created.

Variable objects

You can't use Variable objects as elements of sets or as keys of dicts. They are not hashable and comparable. The issue is that comparisons such as x == y will be interpreted as linear constraints, since Variables are also Expr objects.

Dual values

While PySCIPOpt supports access to the dual values of a solution, there are some limitations involved:

  • Can only be used when presolving and propagation is disabled to ensure that the LP solver - which is providing the dual information - actually solves the unmodified problem.
  • Heuristics should also be disabled to avoid that the problem is solved before the LP solver is called.
  • There should be no bound constraints, i.e., constraints with only one variable. This can cause incorrect values as explained in #136

Therefore, you should use the following settings when trying to work with dual information:

model.setPresolve(pyscipopt.SCIP_PARAMSETTING.OFF)
model.setHeuristics(pyscipopt.SCIP_PARAMSETTING.OFF)
model.disablePropagation()

Citing PySCIPOpt

Please cite this paper

@incollection{MaherMiltenbergerPedrosoRehfeldtSchwarzSerrano2016,
  author = {Stephen Maher and Matthias Miltenberger and Jo{\~{a}}o Pedro Pedroso and Daniel Rehfeldt and Robert Schwarz and Felipe Serrano},
  title = {{PySCIPOpt}: Mathematical Programming in Python with the {SCIP} Optimization Suite},
  booktitle = {Mathematical Software {\textendash} {ICMS} 2016},
  publisher = {Springer International Publishing},
  pages = {301--307},
  year = {2016},
  doi = {10.1007/978-3-319-42432-3_37},
}

as well as the corresponding SCIP Optimization Suite report when you use this tool for a publication or other scientific work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyscipopt-5.1.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

PySCIPOpt-5.1.1-cp312-cp312-win_amd64.whl (56.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

PySCIPOpt-5.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.1.1-cp312-cp312-macosx_11_0_arm64.whl (7.7 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

PySCIPOpt-5.1.1-cp312-cp312-macosx_10_9_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

PySCIPOpt-5.1.1-cp311-cp311-win_amd64.whl (56.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

PySCIPOpt-5.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.1.1-cp311-cp311-macosx_11_0_arm64.whl (7.7 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

PySCIPOpt-5.1.1-cp311-cp311-macosx_10_9_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

PySCIPOpt-5.1.1-cp310-cp310-win_amd64.whl (56.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

PySCIPOpt-5.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.1.1-cp310-cp310-macosx_11_0_arm64.whl (7.7 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

PySCIPOpt-5.1.1-cp310-cp310-macosx_10_9_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

PySCIPOpt-5.1.1-cp39-cp39-win_amd64.whl (56.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

PySCIPOpt-5.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.1.1-cp39-cp39-macosx_11_0_arm64.whl (7.7 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

PySCIPOpt-5.1.1-cp39-cp39-macosx_10_9_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

PySCIPOpt-5.1.1-cp38-cp38-win_amd64.whl (56.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

PySCIPOpt-5.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.8 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.1.1-cp38-cp38-macosx_11_0_arm64.whl (7.7 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

PySCIPOpt-5.1.1-cp38-cp38-macosx_10_9_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file pyscipopt-5.1.1.tar.gz.

File metadata

  • Download URL: pyscipopt-5.1.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyscipopt-5.1.1.tar.gz
Algorithm Hash digest
SHA256 7c7ebf2124b8cf0d35cd3fc65c255a226661dd360dd8bb6c24df2bef110f579c
MD5 4b87ae89826efae907ef891d20fbed30
BLAKE2b-256 b52d2e6d3c302c5be5d1573efdc4c1aab303ae23c52497da2681e2acea5d8f39

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c2dd9e613cce0f8d9fe941da101c91bdb534386dd15c322d87434be0fb90b94b
MD5 ca0268e38653055aaa2b5c9e5b34e286
BLAKE2b-256 5c64e2b57762a0e6ca654b29036714306438f7200c25e93ae6caaffe869214d4

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0335fae1e4f5005b248bedb390d9caef6a03e66c83df84505ab4e49b605de016
MD5 e3b37e2df542cf50db49c928a1858217
BLAKE2b-256 28ed3a6f784ac88c831e0835358e8fbce0fc5bf3cc6320b683f216d62fb3d48e

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a42f1112fd438da9e6960717725bdd1142a8dcd1151a2891ee230253b516b32
MD5 788f18786b0b9b7aee2ceb22de418085
BLAKE2b-256 de6def1173c84c3cd5df67378383b6c087ebcaa6460e0e306855e5fd2cdd06f4

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a3aa6564e72f961695915dfd320f9a511d6293a3c5d4c11ef91f09d9d4e49848
MD5 b2e80b043ebde3142761937f14e2ec78
BLAKE2b-256 3eec1cca56cc4e2ea9b6fa7fb737ed4cf7ff3d459c787ec5b0c271c0956328d7

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 21078810ee17a809c0d3df10208c61e39c2d0e2a231478005d1c995b346fb0a7
MD5 ad394458e93ffb394adf80b68c25e3f0
BLAKE2b-256 d45af56b75930b85c3804ecc8eb72782523ca62118b445054cdae515670b9c01

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22b852aba93f31f4bb6322474dfdde4a3d1b206f3c346a6d249746ed48ba053e
MD5 18f23144813cb4c037bfdaf3083df398
BLAKE2b-256 c35b182add9be84f6c22f77bc0e29264f144e07bb1838f5b2412e8981806568c

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92e29f21e37b442549cce797a16bf9b96cdbd9d10040d672a7fb0952781f594c
MD5 374e91e64976580f91f3b0dc89c54a39
BLAKE2b-256 63b075ddc493be97e621c4348ba333d251e40effe1cf1caa4484b0478a8e4dc9

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 451e40f283aa95c31801d6b2a6e012ce54687fc96a1f2e0193ae6c9951fb0d9a
MD5 b345e22aa4478451b2c63af02b4d604c
BLAKE2b-256 6fff888be3ac16b2a1941d458cf732131ad5302d75beaa27d79355a360945287

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ea694a5d0975c0dc97cb59b53bd94b5b9e6663e2b6e54e7ca6c89e2dfcae0ac4
MD5 5f33c250d2dbe2945d978ef4ad9bde99
BLAKE2b-256 4e8b0a37528df883783e384c520b7dbcdeaea3c5be64bd9a3bb35e4886324691

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 980186ac1f4af16d81beea8951d13b026e6799df385e0a4e6f081a64449b5316
MD5 6de4888f13a1c3c7f61585a22af9bf50
BLAKE2b-256 f0408c9f787d539b2a971040c6a807e4fe3c854e8b9cb3141d7f2f0e18775ed7

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c992aea04cc4985a22d97c9f7c6dc2acaf558734504401737d5d12d561d6aa40
MD5 e5f4b89aa872dd0964df19a28fe7e100
BLAKE2b-256 4665f833afae34037346fdfba9b38f4bc7682e7fa563aaade576169e55352142

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 72d2a57ac1428bb3daba4df39d6558bb8f4a013c264203fc149b7a20704aa1fa
MD5 31955260307997ce0995b8e46c31f2ea
BLAKE2b-256 92d9382e40ad33043291e36a2539aeae2f13280a933e2e62e989c81474e89acd

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: PySCIPOpt-5.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 56.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for PySCIPOpt-5.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a00c8561026046eff46aab2abeb5c19431d53fd5a36139107418eaceba59f042
MD5 71b6d5b3672f6f3cc8e26aafeb85321d
BLAKE2b-256 00a075f411ecf6de9fae0ccd1bf0a2b47cd84a30e4eac9ce78f4146fbb6e35e7

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9ea3a669654bd3a48b108b582bffdb7e5e64b633fd4c5d58037523f634c839d
MD5 4b953e90f243d8e9d88d5e8551351329
BLAKE2b-256 ee3e4fbdf6b824c77cf16ab4db514465990ba417c9887850f88d7e08300ea426

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cf7d731c741c877612f9905e5a2bf4fd727c197d348b0eb076b4966f24c8ea9
MD5 e33d2fc1bb51f0cbf0c727a7be94132c
BLAKE2b-256 7aec0dfee012d927ec689790e6357a62f15e79aa0e92c6884e8948d622d36a04

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 11ca681893b7614d3f515e3ab691cc368c8590a4491410910f598114eac0e51a
MD5 d44b9a7ebaf1bcef182cd0cded68ee3b
BLAKE2b-256 7e4b8d5104c05214d4c955610502f1062abe607cc20d1aa94c5a886a2a0e2eb3

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: PySCIPOpt-5.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 56.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for PySCIPOpt-5.1.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ed3dc6786b3753b94731c674f3f4d04f0ff4eddaa485cf068b5c5cf1d85e5b73
MD5 d55b2f5f2374d956640979430896fb67
BLAKE2b-256 76d627d0bb9c8765eaa39e4603e8a204bed2634a3d7b9bfed24305a2aec72a8d

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99f9f7f1a207513fb04af9a16b41e28c74a5c47c1316dde67d2c33dd8c452a99
MD5 0969c07a79f34e126195e48a92e48cf3
BLAKE2b-256 98de8df4642524c4050ad1a1a10cc05e3812e8d9e7ec8e3c81c65876537e8422

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7548b0d93b9348a6bb023fa9e78f46e21a94cf827d5576d2917cf0b6dd6784d4
MD5 6ff75502f11459c087b33cafd912dcda
BLAKE2b-256 c8056bd98421244ca80238c1186d39803dbbd743248baf6b0c1e55fc37075a1e

See more details on using hashes here.

File details

Details for the file PySCIPOpt-5.1.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for PySCIPOpt-5.1.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c4b41176bc9f56024201f9a64c4e1c5af7369fbf2445c2b1eaa6d72bcb09c31
MD5 66b4ec9413cbc74b1cc54bb81fe1f586
BLAKE2b-256 c5586273bec39abfbb546ffdf567e826fe6154f578ad0b3ba932da8174740cdf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page