$ show scipopt/PySCIPOpt
PySCIPOpt is a Python interface to the SCIP optimization solver, providing a comprehensive modeling environment for linear, mixed-integer, nonlinear, and constraint programming. The library wraps SCIP's C API through Cython, allowing users to formulate optimization problems using Python objects (variables, constraints, expressions) and to solve them with SCIP's state-of-the-art algorithms. The core architecture revolves around the `Model` class, which exposes all solver functionality, and a suite of plugin base classes (branching rules, heuristics, separators, constraint handlers, etc.) that enable users to customize the solution process. The expression system (`Expr`, `GenExpr`, `MatrixExpr`) supports algebraic formulation with operator overloading, while the recipes subpackage provides higher-level modeling helpers for common tasks such as piecewise linear constraints, infeasibility diagnosis, and convergence tracking. The repository is actively maintained and closely tracks SCIP releases, but also explicitly seeks new maintainers to sustain long-term development.
The LLM identified 5 files worth highlighting for reuse:
Implements multiple formulations for piecewise linear constraints (SOS2, convex combination, logarithmic branching), allowing users to choose the most efficient representation for their model. The modular design makes it easy to extend with additional formulation strategies.
Provides a method to identify infeasible constraints by relaxing the objective and introducing slack variables with penalty terms. This is a reusable, non-obvious pattern for diagnosing infeasible optimization models, and it can be adapted to different solvers or modeling frameworks.
Implements an event handler that records primal bound, dual bound, and solving time during the optimization process. The captured data can be used to generate convergence plots or analyze solver performance. The pattern demonstrates clean integration with SCIP's event system and can be extended to track other statistics.
Base class for event handlers, supporting both subclassing (for stateful handlers) and a lightweight callback-based interface via `attachEventHandlerCallback`. This flexibility makes it suitable for a wide range of uses, from simple logging to complex monitoring, and the underlying bridge pattern is a reusable design pattern for Cython-based plugin systems.
Defines MatrixExpr and MatrixVariable classes that extend NumPy ndarrays, enabling vectorized formulation of constraints and variables. This integration allows concise expression of matrix-based optimization models and is reusable in any project that benefits from array-level model construction.