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.0 5.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.0.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

PySCIPOpt-5.0.1-cp312-cp312-win_amd64.whl (55.9 MB view details)

Uploaded CPython 3.12 Windows x86-64

PySCIPOpt-5.0.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.0.1-cp312-cp312-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

PySCIPOpt-5.0.1-cp312-cp312-macosx_10_9_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

PySCIPOpt-5.0.1-cp311-cp311-win_amd64.whl (56.0 MB view details)

Uploaded CPython 3.11 Windows x86-64

PySCIPOpt-5.0.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.0.1-cp311-cp311-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

PySCIPOpt-5.0.1-cp311-cp311-macosx_10_9_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

PySCIPOpt-5.0.1-cp310-cp310-win_amd64.whl (56.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

PySCIPOpt-5.0.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.0.1-cp310-cp310-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

PySCIPOpt-5.0.1-cp310-cp310-macosx_10_9_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

PySCIPOpt-5.0.1-cp39-cp39-win_amd64.whl (56.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

PySCIPOpt-5.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.0.1-cp39-cp39-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

PySCIPOpt-5.0.1-cp39-cp39-macosx_10_9_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

PySCIPOpt-5.0.1-cp38-cp38-win_amd64.whl (56.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

PySCIPOpt-5.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

PySCIPOpt-5.0.1-cp38-cp38-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

PySCIPOpt-5.0.1-cp38-cp38-macosx_10_9_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pyscipopt-5.0.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.0.1.tar.gz
Algorithm Hash digest
SHA256 dc467c4d1c9224c47ebcc319e11acf1a8809b240422cf2999b18618155a96b23
MD5 b5caa607db2cd3e819639609b713f500
BLAKE2b-256 6561edb07bafeac8cc2950763222b4a62718e7e17ad4e48dc977b0872845d731

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 44851647a2037485ef30b87239a9cdf9aa763c4f847aabf3599c73d333c567c6
MD5 96432855e4d7a8bc772c7e68ab5d0755
BLAKE2b-256 f331c030f218aacbef966b9018be5c847fdf2e07e5bc12ff2ee6667b4b67f84c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab9a9a258e0ce8a49efad6fb3d3ce4237423a62144060513015b03326a5c27c4
MD5 1ef9f01d9a948ce5138cb73c036f04fe
BLAKE2b-256 2feb3517bab0b0c4d2b78d2defa1a39e97fb302a32fcb4c75230ed0880e5f08a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 577e2e819a6c091f4d49e43b345614caf53622aa5657a18fec233de079e1c911
MD5 e60a2b93e93e9d09132692427902f221
BLAKE2b-256 2cc6abd6aa6af4ddb30868e4df583707e7b733d74d7f9748be6aed6a3756f29a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e422af9edd84057f3c96042c9cae0f1099518464f35706941c3de9bafcb814be
MD5 d9f46b08e7a9f48e0b64c6f4d60f9779
BLAKE2b-256 6c1f3913cc96622aa5bb5e4bc0ae9070e922fa1bd4f8998b64bb63beb0b15be0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4de812ee1f6d4abc1c61b4681b084bdddb205fa50816c7b92a050ef4e1e194c2
MD5 89301c0086923c7473d3acd11f14d936
BLAKE2b-256 97f44302ce05c9ed433d3a85f4d2f6086a389b60b85bed274692b821e33d3d15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de86da45c3b755f06d77ffc846bd9e88bdb0c267e1cdae16f13b41d55eaa2ee5
MD5 32786499ef5222baf70e5099387d3e90
BLAKE2b-256 1f59343af91e1a2d9051e0e9c797f936cb22b7435b9a06e39ae98c23b9787f02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae4398d252e2efca14e83d07401c6c571c3997f77b447d7fc7a20a05dab05f52
MD5 d225379ed69993bd2c3b3c92bf9e15f3
BLAKE2b-256 9b802608e06873e103abb7bf0daa35e3bcb59c5af6fd32932463d917b787f423

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 38b45c1fc11414318e91e0b909ef1b6bc550b933b333cba78fb4b2f5584184d8
MD5 2fdfd3a34c4c6a5ac0c91aa7cb48ef62
BLAKE2b-256 588f3647d6f247cee89404872380722e5b24a7338c0955280b3e4cb8bed94044

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d98d522c7de51bce1060488cd54c8e67f291492b00c54cbd78b0b2b1070bc7d5
MD5 52b47411af67344d080cfc3ae017fd62
BLAKE2b-256 a1048fd1aea6e0271bc701a75ed48fd903dd583e320421f9b03631746379919c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ddb366daf44943e4859c780bf135f558b1ff8ba250b82b6825c7269f42e39cc
MD5 74faec2194dbfe4b7ad7b90aec4ae4cc
BLAKE2b-256 308dacb44874eafa5c0a5245dbf5f46375c00f03e9ecc6f1d75f62215a824968

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 575277a444e62e22a8e35d6c079b66ea0888185166844bdd4a895a0ff25bc5f7
MD5 883dff140abd96012734b707b3dd0790
BLAKE2b-256 f9e1fc9a5b8f2f330c3c3e5592e4c200b55f1e4595d14a44ec314f19622766e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3235849990eea81ac5eb503e0247c34cf4c28c727d00ff23fa421ad63a014499
MD5 063ae6a4c39ff7902b7ac1e3b58f30e8
BLAKE2b-256 e88f688bf7b7ba1246b1841652db19314e5234d15ab6779b9757db8ae1fbccad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PySCIPOpt-5.0.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 56.0 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.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2102062e5d37871d0bdeb30c1fc7f384694084b84f5d3960c19baef9019dfad0
MD5 836c48ddb357e23856748bbb8068d389
BLAKE2b-256 1d8899f6c554efa1504d0b9af042ded8a7c188f68c98c4d55b8f35045dc06de3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b44ab06d599c4feaaa722485728e2f606c43bb52ea16551c8808e4fe0e60b8b
MD5 b75575e73c97d0ed9b3510e7fed88a79
BLAKE2b-256 1c3b79236b74ea5551c89ebc54e255f032a3edad9794fe4895560eda26fc2c2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b23e4a0b36736a05af314ef10aa22ae1c54b1c86d75f2c9b94029952b123852c
MD5 2c92a2ee858c0b33f6ab30e00e4024e9
BLAKE2b-256 b79a442105bd917d46434613fbcb5b219b48a3d07301e7099c984343842abddf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 be3e6f743cd5f8491559107573405fbf489eb3f902dd5a51b82261b1038c126e
MD5 fcae4930e7bc8f1195287ee772255904
BLAKE2b-256 1c1b20924b0344cdafcce63d2209a545b0fbe092f0cdd3388e9210a422f31328

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PySCIPOpt-5.0.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 56.0 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.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 98051bd86e425f7a70f8750cbeed36f4c552adabe79bc29294daaad9d67806b4
MD5 86256974d12e0a345fdfcceb18204395
BLAKE2b-256 f4de828d06a164065cb423e516d6c8344424a2356578d071dc26d580c2e63c9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4cb2ea0534b2f3618666b85a168116c7e60644fd7b97f672e8f80bd5bad57125
MD5 26fc3d704dc7d2b69edec811dfdd4478
BLAKE2b-256 695662e2f6be0213e4c384b3d2ce2373b688a779d5c85cd6b63fe5dce61ee698

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0fe4d6f8aa46766117e935215909b92ac0408f4386e0f2e78979dc1cb5ba24ce
MD5 bc9eb6ae167a5dbc191bd38884154d7d
BLAKE2b-256 99e4f8b8f37f9dfc35c43efade7790906e57fe473051b9a2de208e7943eb98de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PySCIPOpt-5.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b99228335fc09d9c651c58e5e386c35084d0811baf2fc991f3195b6d3a5615c7
MD5 05e6f49cd0bd382dde6c3753767235b6
BLAKE2b-256 de38f5d1574119ae133c1b9bf2148a7bfc106e14eeced213b691c3f4d4473494

See more details on using hashes here.

Supported by

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