PySCIPOpt Project Overview
PySCIPOpt is a Python library that provides a powerful interface to the SCIP Optimization Suite, allowing users to leverage advanced optimization techniques directly from Python. The SCIP Optimization Suite is renowned in the fields of mathematical programming and combinatorial optimization, and starting from version 8.0.3, it is available under the Apache 2.0 license. Users utilizing earlier versions should be aware of and review SCIP's license restrictions.
Documentation and Support
The PySCIPOpt project offers comprehensive resources to assist users in effectively employing the interface. Detailed online documentation is available, which can be accessed via PySCIPOpt Documentation. Users can also seek assistance directly in Python using the help()
function or by using a question mark ?
in interactive environments like IPython or Jupyter Notebooks.
Additionally, as the documentation is undergoing updates, there remains an older, more complete version related to the API available here. The project's changelog can provide further insights into updates and modifications, available in the CHANGELOG.md file.
Installation
Installing PySCIPOpt is straightforward and can be done using PyPI with the following command:
pip install pyscipopt
For those interested in specific versions, Conda-based installations, or building from the source, more instructions are provided in the online documentation here.
Building and Solving Models
PySCIPOpt allows users to build and solve optimization models efficiently through the following steps:
-
Importing PySCIPOpt: Begin by importing the main PySCIPOpt module in your Python script:
from pyscipopt import Model
-
Creating a Solver Instance: Construct a model instance which serves as the solver.
model = Model("Example") # The model name is optional
-
Defining Variables and Constraints: Use the model instance to define variables, constraints, and the objective function:
x = model.addVar("x") y = model.addVar("y", vtype="INTEGER") model.setObjective(x + y) model.addCons(2*x - y*y >= 0)
-
Optimizing and Retrieving Results: Optimize the model and retrieve the solution:
model.optimize() sol = model.getBestSol() print("x: {}".format(sol[x])) print("y: {}".format(sol[y]))
Various examples and tutorials are available to help users get started with writing more complex scripts using PySCIPOpt. These can be found in the examples and tutorials sections in the repository.
Writing New Plugins
PySCIPOpt supports the development of custom plugins to extend SCIP's functionality. Users can create pricers, heuristics, or constraint handlers in Python. To develop these plugins, base classes provided by PySCIPOpt can be extended, customizing callback methods as needed. Examples can be found in test files like test_pricer.py
and test_heur.py
.
Citing PySCIPOpt
When utilizing PySCIPOpt in any publication or scientific research, the authors request that you correctly cite their work. Details for citation can be found in the provided citation document.
By offering advanced optimization capabilities wrapped in Python, PySCIPOpt bridges the gap between cutting-edge optimization research and practical application, making it an invaluable tool for researchers and practitioners alike.