Oven logo

Oven

Published

Python interface and modeling environment for SCIP

pip install pyscipopt

Package Downloads

Weekly DownloadsMonthly Downloads

Project URLs

Requires Python

>=3.8

Dependencies

    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.

    The old documentation, which we are in the process of migrating from, is still more complete w.r.t. the API, and can be found here

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

    Installation

    The recommended installation method is via PyPI

    pip install pyscipopt
    

    For information on specific versions, installation via Conda, and guides for building from source, please see the online documentation.

    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.

    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.