Skip to content
Merged

SCIP 10 #1009

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
6a4140b
Add printStatisticsJson
Joao-Dionisio May 28, 2025
3c50d40
Implied integer stuff
Joao-Dionisio May 31, 2025
45933b9
Add extra event types
Joao-Dionisio May 31, 2025
af1645d
minor fixes in relax.pxi
Joao-Dionisio May 31, 2025
a310db6
start of iisfinder plugin
Joao-Dionisio May 31, 2025
3db696e
udpate inlcudeReader with the new definition, add printStatisticsJson
mmghannam Jun 3, 2025
40b901a
Add assert to statistics json test
Jun 3, 2025
2fe7680
compilation, left iis for later
Joao-Dionisio Jun 3, 2025
a29aa5c
fix issues with exact scip. still no support
Joao-Dionisio Jun 3, 2025
15afb8e
Merge remote-tracking branch 'origin/master' into SCIP10
Joao-Dionisio Jun 5, 2025
6c126f7
fixed some tests
Joao-Dionisio Jun 5, 2025
b841b95
fix minor typos
Joao-Dionisio Jun 5, 2025
79c88a1
changelog so I don't forget
Joao-Dionisio Jun 5, 2025
703fd34
variable type tests
Joao-Dionisio Jun 5, 2025
f352c30
fix test_pricer bug
Joao-Dionisio Jun 11, 2025
97434b5
Merge branch 'master' into SCIP10
Joao-Dionisio Jun 17, 2025
81395b2
typo
Joao-Dionisio Jun 17, 2025
ae60d7e
IISfinder progress
Joao-Dionisio Jun 17, 2025
be3022e
Start of support for exact scip
Joao-Dionisio Jun 17, 2025
dc08654
Fix reader write (#1015)
DominikKamp Jul 2, 2025
ffcf001
Fix most compilation issues and warnings
Joao-Dionisio Jul 11, 2025
b417a92
Update IIS method and remove redeclaration
Joao-Dionisio Jul 11, 2025
5d2f440
Merge branch 'master' into SCIP10
Joao-Dionisio Jul 24, 2025
389ac74
Fix build error
Joao-Dionisio Jul 24, 2025
e2d9038
little IIS progress
Joao-Dionisio Jul 24, 2025
55c99bb
iis compilation
Joao-Dionisio Jul 24, 2025
3914760
some iis methods
Joao-Dionisio Jul 24, 2025
e9238a1
remove semicolons
Joao-Dionisio Jul 24, 2025
f9a781d
Change IIS methods imported
Joao-Dionisio Jul 26, 2025
01757c8
remove cons_and methods that were removed in SCIP
svigerske Sep 23, 2025
3e44a06
Merge branch 'SCIP10' of github.com:scipopt/PySCIPOpt into SCIP10
mmghannam Sep 24, 2025
c5b72dc
Update callback signatures of IISFinderExec and ReaderWrite to match …
mmghannam Sep 24, 2025
48434eb
Merge branch 'master' of github.com:scipopt/PySCIPOpt into SCIP10
mmghannam Sep 24, 2025
a1a707f
Export IISfinder class
Sep 24, 2025
3b7fab3
Add simple iis tests
Sep 24, 2025
5c71a07
Fix write json statistics test
Sep 24, 2025
0f3b26a
Use deprecated implied integer type
Sep 24, 2025
ddb4e5d
Raise error when relaxator doesn't implement the exec callback
Sep 24, 2025
baac6be
Fix event tests and add another one for catching variable events
Sep 24, 2025
1a57360
Fix relaxator tests
Sep 24, 2025
113891c
Merge branch 'master' into SCIP10
mmghannam Oct 9, 2025
2e53afa
Merge branch 'master' of https://github.com/scipopt/PySCIPOpt into SC…
Joao-Dionisio Nov 12, 2025
ba2d6ce
Merge branch 'SCIP10' of https://github.com/scipopt/PySCIPOpt into SC…
Joao-Dionisio Nov 12, 2025
bd9a4e3
Merge branch 'master' of github.com:scipopt/PySCIPOpt into SCIP10
Joao-Dionisio Nov 22, 2025
5f8afa0
add forgotten events. tests pass
Joao-Dionisio Nov 22, 2025
1c04b3c
custom iis finder test
Joao-Dionisio Nov 22, 2025
edc0fda
try to fix jenkins pipeline
Joao-Dionisio Nov 22, 2025
a030bf7
some stuff for the release
Joao-Dionisio Nov 22, 2025
3235b75
more complete and passing event tests
Joao-Dionisio Nov 23, 2025
d42c496
typo
Joao-Dionisio Nov 23, 2025
e8d2b4d
correct version name
Joao-Dionisio Nov 23, 2025
d36054e
changelog and exact keyword
Joao-Dionisio Nov 24, 2025
31362d1
update scip version
Joao-Dionisio Nov 24, 2025
ac40257
trying out new links
Joao-Dionisio Nov 25, 2025
7fb7826
binaries will remain on github
Joao-Dionisio Nov 25, 2025
3c57380
Merge branch 'SCIP10' of github.com:scipopt/PySCIPOpt into SCIP10
Joao-Dionisio Nov 25, 2025
bb459d6
update with new file names
Joao-Dionisio Nov 25, 2025
4024b01
Merge branch 'SCIP10' of github.com:scipopt/PySCIPOpt into SCIP10
Joao-Dionisio Nov 25, 2025
e09fbc9
one more attempt
Joao-Dionisio Nov 25, 2025
9da0614
ignoring scip deprecation warning, for now
Joao-Dionisio Nov 25, 2025
f54b321
try removing cached scip
Joao-Dionisio Nov 25, 2025
33af1b3
revert last commit
Joao-Dionisio Nov 26, 2025
c90edde
some work on iis
Joao-Dionisio Nov 26, 2025
88fe800
fix breaking tests with new preset
Joao-Dionisio Nov 27, 2025
ace9ec3
remove usage of deprecated implied integrality
Joao-Dionisio Nov 27, 2025
d31337a
pyscipopt style
Joao-Dionisio Nov 27, 2025
249c4e2
clean up the class
Joao-Dionisio Nov 27, 2025
f07187d
some iis improvements
Joao-Dionisio Nov 27, 2025
14053ee
more robust time testing
Joao-Dionisio Nov 27, 2025
bfc4c79
I think this is it
Joao-Dionisio Nov 27, 2025
91c3598
cleaner iis
Joao-Dionisio Nov 27, 2025
6ded37c
iis tutorial
Joao-Dionisio Nov 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run tests with coverage
env:
version: 9.2.4
version: 10.0.0

on:
push:
Expand All @@ -25,8 +25,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${{ env.version }}/scipoptsuite_${{ env.version }}-1+jammy_amd64.deb"
sudo apt-get update && sudo apt install -y ./scipoptsuite_${{ env.version }}-1+jammy_amd64.deb

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -40,7 +40,7 @@ jobs:

- name: Install PySCIPOpt
run: |
export CFLAGS="-O0 -ggdb -Wall -Wextra -Werror" # Debug mode. More warnings. Warnings as errors.
export CFLAGS="-O0 -ggdb -Wall -Wextra -Werror -Wno-error=deprecated-declarations" # Debug mode. More warnings. Warnings as errors, but allow deprecated declarations.
python -m pip install . -v 2>&1 | tee build.log
grep -i "warning" build.log || true

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Integration test

env:
version: 9.2.4
version: 10.0.0

on:
push:
Expand All @@ -23,8 +23,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${version}/scipoptsuite_${version}-1+jammy_amd64.deb"
sudo apt-get update && sudo apt install -y ./scipoptsuite_${version}-1+jammy_amd64.deb

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

- name: Download dependencies (SCIPOptSuite)
shell: powershell
run: wget https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-win64.exe -outfile scipopt-installer.exe
run: wget https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/scipoptsuite-${{ env.version }}-win-x64.exe -outfile scipopt-installer.exe

- name: Install dependencies (SCIPOptSuite)
shell: cmd
Expand Down Expand Up @@ -92,10 +92,11 @@ jobs:
- name: Install dependencies (SCIPOptSuite)
run: |
brew install tbb boost bison
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Darwin.sh
chmod +x SCIPOptSuite-${{ env.version }}-Darwin.sh
./SCIPOptSuite-${{ env.version }}-Darwin.sh --skip-license --include-subdir
mv SCIPOptSuite-${{ env.version }}-Darwin ${{ github.workspace }}/scipoptsuite
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${version}/scipoptsuite-${version}-macos13-arm64.tgz"
tar xzf "scipoptsuite-${version}-macos13-arm64.tgz"
chmod +x "scipoptsuite-${version}-macos13-arm64.sh"
"./scipoptsuite-${version}-macos13-arm64.sh" --skip-license --include-subdir
mv "scipoptsuite-${version}-macos13-arm64" "${{ github.workspace }}/scipoptsuite"

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -122,4 +123,3 @@ jobs:
### if you need valgrind on mac, you can install it via
# brew tap LouisBrunner/valgrind
# brew install --HEAD LouisBrunner/valgrind/valgrind

6 changes: 3 additions & 3 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: TestPyPI release

env:
version: 9.2.4
version: 10.0.0


# runs only when a release is published, not on drafts
Expand All @@ -17,8 +17,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${version}/scipoptsuite_${version}-1+jammy_amd64.deb"
sudo apt-get update && sudo apt install -y ./scipoptsuite_${version}-1+jammy_amd64.deb

- name: Setup python 3
uses: actions/setup-python@v4
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/update-packages-and-documentation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Test and Release PyPI Package

env:
version: 9.2.4
version: 10.0.0


# runs only when a release is published, not on drafts
Expand Down Expand Up @@ -38,8 +38,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/scipoptsuite_${{ env.version }}-1+jammy_amd64.deb
sudo apt-get update && sudo apt install -y ./scipoptsuite_${{ env.version }}-1+jammy_amd64.deb

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -71,7 +71,9 @@ jobs:

- name: Download dependencies (SCIPOptSuite)
shell: powershell
run: wget https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-win64-VS15.exe -outfile scipopt-installer.exe
run: |
$url = "https://github.com/scipopt/scip/releases/download/v${{ env.version }}/scipoptsuite-${{ env.version }}-win-x64.exe"
Invoke-WebRequest -Uri $url -OutFile scipopt-installer.exe

- name: Install dependencies (SCIPOptSuite)
shell: cmd
Expand Down Expand Up @@ -107,8 +109,8 @@ jobs:

- name: Install dependencies (SCIPOptSuite)
run: |
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/scipoptsuite_${{ env.version }}-1+jammy_amd64.deb
sudo apt-get update && sudo apt install -y ./scipoptsuite_${{ env.version }}-1+jammy_amd64.deb

- name: Setup python 3
uses: actions/setup-python@v4
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
### Changed
### Removed

## 6.0.0 - 2025.xx.yy
### Added
- Support for SCIP 10.0.0
- Added support for IIS - Irreducible Inconsistent Subsystems
- Added 4 new events: TYPECHANGED, IMPLTYPECHANGED, DUALBOUNDIMPROVED, GAPUPDATED.
- Support for new implied integrality
- Wrapped varIsBinary(), varIsIntegral(), varIsImpliedIntegral(), varIsNonImpliedIntegral(), varGetImplType()
- Interfaced some exact SCIP methods
- wrapped SCIPprintStatisticsJson
### Fixed
### Changed
### Removed
- Removed methods chgAndConsCheckFlagWhenUpgr, chgAndConsRemovableFlagWhenUpgr

## 5.7.0 - 2025.11.17
### Added
- Added possibility of having variables in exponent.
Expand Down
2 changes: 2 additions & 0 deletions docs/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ To download SCIP please either use the pre-built SCIP Optimization Suite availab

* - SCIP
- PySCIPOpt
* - 10.0.0
- 6.0
* - 9.2
- 5.3, 5.4, 5.5, 5.6, 5.7
* - 9.1
Expand Down
222 changes: 222 additions & 0 deletions docs/tutorials/iis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
###############
Irreducible Infeasible Subsystems (IIS)
###############

For the following, let us assume that a Model object is available, which is created as follows:

.. code-block:: python

from pyscipopt import Model, IISfinder, SCIP_RESULT
model = Model()

.. contents:: Contents

What is an IIS?
===============

It is a common issue for integer programming practitioners to (unexpectedly) encounter infeasible problems.
Often it is desirable to better understand exactly why the problem is infeasible.
Was it an error in the input data, was the underlying formulation incorrect, or was the model simply infeasible by construction?

A common tool for helping diagnose the reason for infeasibility is an **Irreducible Infeasible Subsystem (IIS)**.
An IIS is a subset of constraints and variable bounds from the original problem that:

1. Remains infeasible when considered together
2. Cannot be further reduced without the subsystem becoming feasible

Practitioners can use IIS finders to narrow their focus onto a smaller, more manageable problem.
Note, however, that there are potentially many different irreducible subsystems for a given infeasible problem, and that IIS finders may not provide a guarantee of an IIS of minimum size.

Generating an IIS
=================
Let us create a simple infeasible model and then generate an IIS for it.

.. code-block:: python

from pyscipopt import Model

m = Model()
x1 = m.addVar("x1", vtype="B")
x2 = m.addVar("x2", vtype="B")
x3 = m.addVar("x3", vtype="B")

# These four constraints cannot be satisfied simultaneously
m.addCons(x1 + x2 == 1, name="c1")
m.addCons(x2 + x3 == 1, name="c2")
m.addCons(x1 + x3 == 1, name="c3")
m.addCons(x1 + x2 + x3 <= 0, name="c4")

model.optimize()
iis = model.generateIIS()

When you run this code, SCIP will output a log showing the progress of finding the IIS:

.. code-block:: text

presolving:
presolving (1 rounds: 1 fast, 0 medium, 0 exhaustive):
2 deleted vars, 2 deleted constraints, 0 added constraints, 0 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
0 implications, 0 cliques, 0 implied integral variables (0 bin, 0 int, 0 cont)
presolving detected infeasibility
Presolving Time: 0.00

SCIP Status : problem is solved [infeasible]
Solving Time (sec) : 0.00
Solving Nodes : 0
Primal Bound : +1.00000000000000e+20 (0 solutions)
Dual Bound : +1.00000000000000e+20
Gap : 0.00 %
time(s)| node | cons | vars | bounds| infeasible
0.0| 0| 1| 3| 6| no
0.0| 0| 2| 3| 6| no
0.0| 0| 4| 3| 6| no
0.0| 0| 3| 3| 6| yes
0.0| 0| 2| 3| 6| yes
0.0| 0| 2| 3| 6| yes

IIS Status : irreducible infeasible subsystem (IIS) found
IIS irreducible : yes
Generation Time (sec) : 0.01
Generation Nodes : 0
Num. Cons. in IIS : 2
Num. Vars. in IIS : 3
Num. Bounds in IIS : 6

.. note::
While an already optimized infeasible model is not required to use the IIS functionality, it is
encouraged to call this functionality only after ``model.optimize()``. Otherwise, SCIP will naturally optimize
the base problem first to ensure that it is actually infeasible.

After SCIP finds that the model is infeasible, see that SCIP's IIS finders alternate between including constraints to make the problem feasible, and removing constraints to make the problem as small as possible.
You see in the final statistics that the IIS is indeed irreducible, with 3 variables and 2 constraints.

The IIS Object
==============

The ``IIS`` object returned by ``generateIIS()`` can be queried to access the following information:

- **time**: The CPU time spent finding the IIS
- **irreducible**: Boolean indicating if the IIS is irreducible
- **nodes**: Number of nodes explored during IIS generation
- **model**: A ``Model`` object containing the subscip with the IIS constraints

You can interact with the subscip to examine which constraints and variables are part of the IIS:

.. code-block:: python

iis = model.generateIIS()
subscip = iis.getSubscip()

# Get constraints in the IIS
for cons in subscip.getConss():
print(f"Constraint: {cons.name}")

# Get variables in the IIS
for var in subscip.getVars():
print(f"Variable: {var.name}")

Creating a Custom IIS Finder
=============================

You may want to implement your own algorithm to find an IIS.
PySCIPOpt supports this through the ``IISfinder`` class, which allows you to define custom logic
for identifying infeasible subsystems.

Basic Structure
---------------

To create a custom IIS finder, inherit from the ``IISfinder`` class and implement the ``iisfinderexec`` method:

.. code-block:: python

from pyscipopt import Model, IISfinder, SCIP_RESULT

class SimpleIISFinder(IISfinder):
"""
A simple IIS finder that removes constraints one by one
until the problem becomes feasible.
"""

def iisfinderexec(self):
subscip = self.iis.getSubscip()
constraints = subscip.getConss()

# Start with all constraints
active_constraints = set(constraints)

for cons in constraints:
# Temporarily remove the constraint
active_constraints.discard(cons)

# Check if remaining constraints are still infeasible
# (This would require setting up a sub-problem with only active_constraints)
# For simplicity, we use the full solve approach here

subscip.freeTransform()
subscip.delCons(cons)
subscip.optimize()

if subscip.getStatus() == SCIP_STATUS.INFEASIBLE:
# Still infeasible without this constraint
# Keep it removed
pass
else:
# Feasible without it, so constraint is needed in IIS
active_constraints.add(cons)
# In practice, you'd recreate the subscip with all active constraints

iis.markIrreducible()
return {"result": SCIP_RESULT.SUCCESS}

Including Your Custom IIS Finder
---------------------------------

To use your custom IIS finder, include it in the model before calling ``generateIIS()``:

.. code-block:: python

# Create model
model = Model()

# Add variables and constraints (infeasible problem)
x1 = model.addVar("x1", vtype="B")
x2 = model.addVar("x2", vtype="B")
x3 = model.addVar("x3", vtype="B")

model.addCons(x1 + x2 == 1, name="c1")
model.addCons(x2 + x3 == 1, name="c2")
model.addCons(x1 + x3 == 1, name="c3")

# Create and include the custom IIS finder
simple_iis = SimpleIISFinder()
model.includeIISfinder(
simple_iis,
name="simpleiis",
desc="Simple greedy IIS finder",
priority=1000000 # Higher priority means it will be used first
)

# Solve to verify infeasibility
model.optimize()

# Generate IIS using our custom finder
iis = model.generateIIS()

# Examine the result
print(f"\nIIS Information:")
print(f" Time: {iis.getTime():.2f} seconds")
print(f" Nodes: {iis.getNNodes()}")
print(f" Irreducible: {iis.isSubscipIrreducible()}")
print(f" Number of constraints: {iis.getSubscip().getNConss()}")

Key Methods in IISfinder
-------------------------

When implementing a custom IIS finder, you have access to several important methods:

- ``subscip=self.iis.getSubscip()``: Get the sub-problem (Model) containing the candidate IIS
- ``subscip.getConss()``: Get all constraints in the subscip
- ``subscip.delCons(cons)``: Remove a constraint from the subscip
- ``subscip.addCons(cons)``: Add a constraint back to the subscip
- ``subscip.optimize()``: Solve the subscip
- ``subscip.getStatus()``: Check if the subscip is infeasible
Loading