Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python interface for the SCIP Optimization Suite

License

NotificationsYou must be signed in to change notification settings

scipopt/PySCIPOpt

Repository files navigation

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

GitterPySCIPOpt on PyPIIntegration testcoverageAppVeyor Status

Documentation

Please consult theonline documentation or use thehelp() 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 foundhere

SeeCHANGELOG.md for added, removed or fixed functionality.

Installation

The recommended installation method is viaPyPI:

pip install pyscipopt

To avoid interfering with system packages, it's best to use avirtual environment:

python3 -m venv venv# creates a virtual environment called venvsource venv/bin/activate# activates the environment. On Windows use: venv\Scripts\activatepip install pyscipopt

Remember to activate the environment (source venv/bin/activate or equivalent) in each terminal session where you use PySCIPOpt.Note that some configurations require the use of virtual environments.

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

Building and solving a model

There are severalexamples andtutorials. These display some functionality of theinterface and can serve as an entry point for writing more complex code. Some of the common usecases are also available in therecipes 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. Thefollowing steps are always required when using the interface:

  1. It is necessary to import python-scip in your code. This is achievedby including the line
frompyscipoptimportModel
  1. Create a solver instance.
model=Model("Example")# model name is optional
  1. Access the methods in thescip.pxi file using the solver/modelinstancemodel, 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 thefunctionality of SCIP. You may write a pricer, heuristic or evenconstraint handler using pure Python code and SCIP can call theirmethods using the callback system. Every available plugin has a baseclass that you need to extend, overwriting the predefined but emptycallbacks. Please seetest_pricer.py andtest_heur.py for two simpleexamples.

Please notice that in most cases one needs to use adictionary tospecify the return values needed by SCIP.

Using PySCIPOpt?

If your project or company is using PySCIPOpt, consider letting us know atscip@zib.de. We are always interestedin knowing how PySCIPOpt is being used, and, given permission, would also appreciate adding your company's logoto our website.

If you are creating models with some degree of complexity which don't take too long to solve, also considersharing them with us. We might want to add them totests/helpers/utils.py to help make our tests more robust, or add them to our examples.

Citing PySCIPOpt

Please citethis 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 correspondingSCIP Optimization Suite report when you use this tool for a publication or other scientific work.

Seeking Maintainers

PySCIPOpt is sustained by volunteer effort, and as the project grows we are inviting more contributors and maintainers to join the team.

What needs to be done

These are the core responsibilities:

  • Community support: Going over the open issues regularly. Occasionally visiting Stack Overflow and OR.SE, as users also ask questions there.
  • PR review: Reviewing user pull requests, making sure that the CHANGELOG is updated, and all added methods are tested.
  • API coverage: keep expanding PySCIPOpt's coverage of SCIP's C API.
  • Documentation: help keep the documentation up to date, and add new tutorials/examples.
  • Releases: there should be a PySCIPOpt release with every SCIP release, at a minimum.

Even if you are not interested in becoming a maintainer, but would like to help out occasionally, that would be very welcome as well!

Send us an email over atjoao.goncalves.dionisio@gmail.com if you're ready to take on the challenge :)


[8]ページ先頭

©2009-2026 Movatter.jp