Skip to content

Commit bcbfd62

Browse files
Joao-DionisiommghannamMohammed GhannamDominikKampsvigerske
authored
SCIP 10 (#1009)
* Add printStatisticsJson * Implied integer stuff * Add extra event types * minor fixes in relax.pxi * start of iisfinder plugin * udpate inlcudeReader with the new definition, add printStatisticsJson * Add assert to statistics json test * compilation, left iis for later * fix issues with exact scip. still no support * fixed some tests * fix minor typos * changelog so I don't forget * variable type tests * fix test_pricer bug * typo * IISfinder progress * Start of support for exact scip * Fix reader write (#1015) * Fix most compilation issues and warnings * Update IIS method and remove redeclaration * Fix build error * little IIS progress * iis compilation * some iis methods * remove semicolons * Change IIS methods imported * remove cons_and methods that were removed in SCIP - scipopt/scip@602bc1c810 * Update callback signatures of IISFinderExec and ReaderWrite to match SCIP 10 * Export IISfinder class * Add simple iis tests * Fix write json statistics test * Use deprecated implied integer type * Raise error when relaxator doesn't implement the exec callback * Fix event tests and add another one for catching variable events * Fix relaxator tests * add forgotten events. tests pass * custom iis finder test * try to fix jenkins pipeline * some stuff for the release * more complete and passing event tests * typo * correct version name * changelog and exact keyword * update scip version * trying out new links * binaries will remain on github * update with new file names * one more attempt * ignoring scip deprecation warning, for now * try removing cached scip * revert last commit * some work on iis * fix breaking tests with new preset * remove usage of deprecated implied integrality * pyscipopt style * clean up the class * some iis improvements * more robust time testing * I think this is it * cleaner iis * iis tutorial --------- Co-authored-by: Mohammed Ghannam <mohammad.m.ghannam@gmail.com> Co-authored-by: Mohammed Ghannam <mghannam@zib.de> Co-authored-by: DominikKamp <130753997+DominikKamp@users.noreply.github.com> Co-authored-by: Stefan Vigerske <svigerske@gams.com> Co-authored-by: Mohammed Ghannam <ghannam@zib.de>
1 parent c8a045c commit bcbfd62

25 files changed

+1163
-183
lines changed

.github/workflows/coverage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Run tests with coverage
22
env:
3-
version: 9.2.4
3+
version: 10.0.0
44

55
on:
66
push:
@@ -25,8 +25,8 @@ jobs:
2525

2626
- name: Install dependencies (SCIPOptSuite)
2727
run: |
28-
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
29-
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
28+
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${{ env.version }}/scipoptsuite_${{ env.version }}-1+jammy_amd64.deb"
29+
sudo apt-get update && sudo apt install -y ./scipoptsuite_${{ env.version }}-1+jammy_amd64.deb
3030
3131
- name: Setup python ${{ matrix.python-version }}
3232
uses: actions/setup-python@v4
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: Install PySCIPOpt
4242
run: |
43-
export CFLAGS="-O0 -ggdb -Wall -Wextra -Werror" # Debug mode. More warnings. Warnings as errors.
43+
export CFLAGS="-O0 -ggdb -Wall -Wextra -Werror -Wno-error=deprecated-declarations" # Debug mode. More warnings. Warnings as errors, but allow deprecated declarations.
4444
python -m pip install . -v 2>&1 | tee build.log
4545
grep -i "warning" build.log || true
4646

.github/workflows/integration-test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Integration test
22

33
env:
4-
version: 9.2.4
4+
version: 10.0.0
55

66
on:
77
push:
@@ -23,8 +23,8 @@ jobs:
2323

2424
- name: Install dependencies (SCIPOptSuite)
2525
run: |
26-
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
27-
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu22.deb
26+
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${version}/scipoptsuite_${version}-1+jammy_amd64.deb"
27+
sudo apt-get update && sudo apt install -y ./scipoptsuite_${version}-1+jammy_amd64.deb
2828
2929
- name: Setup python ${{ matrix.python-version }}
3030
uses: actions/setup-python@v4
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Download dependencies (SCIPOptSuite)
5656
shell: powershell
57-
run: wget https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-win64.exe -outfile scipopt-installer.exe
57+
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
5858

5959
- name: Install dependencies (SCIPOptSuite)
6060
shell: cmd
@@ -92,10 +92,11 @@ jobs:
9292
- name: Install dependencies (SCIPOptSuite)
9393
run: |
9494
brew install tbb boost bison
95-
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Darwin.sh
96-
chmod +x SCIPOptSuite-${{ env.version }}-Darwin.sh
97-
./SCIPOptSuite-${{ env.version }}-Darwin.sh --skip-license --include-subdir
98-
mv SCIPOptSuite-${{ env.version }}-Darwin ${{ github.workspace }}/scipoptsuite
95+
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${version}/scipoptsuite-${version}-macos13-arm64.tgz"
96+
tar xzf "scipoptsuite-${version}-macos13-arm64.tgz"
97+
chmod +x "scipoptsuite-${version}-macos13-arm64.sh"
98+
"./scipoptsuite-${version}-macos13-arm64.sh" --skip-license --include-subdir
99+
mv "scipoptsuite-${version}-macos13-arm64" "${{ github.workspace }}/scipoptsuite"
99100
100101
- name: Setup python ${{ matrix.python-version }}
101102
uses: actions/setup-python@v4
@@ -122,4 +123,3 @@ jobs:
122123
### if you need valgrind on mac, you can install it via
123124
# brew tap LouisBrunner/valgrind
124125
# brew install --HEAD LouisBrunner/valgrind/valgrind
125-

.github/workflows/test-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: TestPyPI release
22

33
env:
4-
version: 9.2.4
4+
version: 10.0.0
55

66

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

1818
- name: Install dependencies (SCIPOptSuite)
1919
run: |
20-
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
21-
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
20+
wget --quiet --no-check-certificate "https://github.com/scipopt/scip/releases/download/v${version}/scipoptsuite_${version}-1+jammy_amd64.deb"
21+
sudo apt-get update && sudo apt install -y ./scipoptsuite_${version}-1+jammy_amd64.deb
2222
2323
- name: Setup python 3
2424
uses: actions/setup-python@v4

.github/workflows/update-packages-and-documentation.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Test and Release PyPI Package
22

33
env:
4-
version: 9.2.4
4+
version: 10.0.0
55

66

77
# runs only when a release is published, not on drafts
@@ -38,8 +38,8 @@ jobs:
3838

3939
- name: Install dependencies (SCIPOptSuite)
4040
run: |
41-
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
42-
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
41+
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
42+
sudo apt-get update && sudo apt install -y ./scipoptsuite_${{ env.version }}-1+jammy_amd64.deb
4343
4444
- name: Setup python ${{ matrix.python-version }}
4545
uses: actions/setup-python@v4
@@ -71,7 +71,9 @@ jobs:
7171

7272
- name: Download dependencies (SCIPOptSuite)
7373
shell: powershell
74-
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
74+
run: |
75+
$url = "https://github.com/scipopt/scip/releases/download/v${{ env.version }}/scipoptsuite-${{ env.version }}-win-x64.exe"
76+
Invoke-WebRequest -Uri $url -OutFile scipopt-installer.exe
7577
7678
- name: Install dependencies (SCIPOptSuite)
7779
shell: cmd
@@ -107,8 +109,8 @@ jobs:
107109

108110
- name: Install dependencies (SCIPOptSuite)
109111
run: |
110-
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
111-
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu20.deb
112+
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
113+
sudo apt-get update && sudo apt install -y ./scipoptsuite_${{ env.version }}-1+jammy_amd64.deb
112114
113115
- name: Setup python 3
114116
uses: actions/setup-python@v4

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
### Changed
77
### Removed
88

9+
## 6.0.0 - 2025.xx.yy
10+
### Added
11+
- Support for SCIP 10.0.0
12+
- Added support for IIS - Irreducible Inconsistent Subsystems
13+
- Added 4 new events: TYPECHANGED, IMPLTYPECHANGED, DUALBOUNDIMPROVED, GAPUPDATED.
14+
- Support for new implied integrality
15+
- Wrapped varIsBinary(), varIsIntegral(), varIsImpliedIntegral(), varIsNonImpliedIntegral(), varGetImplType()
16+
- Interfaced some exact SCIP methods
17+
- wrapped SCIPprintStatisticsJson
18+
### Fixed
19+
### Changed
20+
### Removed
21+
- Removed methods chgAndConsCheckFlagWhenUpgr, chgAndConsRemovableFlagWhenUpgr
22+
923
## 5.7.0 - 2025.11.17
1024
### Added
1125
- Added possibility of having variables in exponent.

docs/build.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ To download SCIP please either use the pre-built SCIP Optimization Suite availab
2121

2222
* - SCIP
2323
- PySCIPOpt
24+
* - 10.0.0
25+
- 6.0
2426
* - 9.2
2527
- 5.3, 5.4, 5.5, 5.6, 5.7
2628
* - 9.1

docs/tutorials/iis.rst

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
###############
2+
Irreducible Infeasible Subsystems (IIS)
3+
###############
4+
5+
For the following, let us assume that a Model object is available, which is created as follows:
6+
7+
.. code-block:: python
8+
9+
from pyscipopt import Model, IISfinder, SCIP_RESULT
10+
model = Model()
11+
12+
.. contents:: Contents
13+
14+
What is an IIS?
15+
===============
16+
17+
It is a common issue for integer programming practitioners to (unexpectedly) encounter infeasible problems.
18+
Often it is desirable to better understand exactly why the problem is infeasible.
19+
Was it an error in the input data, was the underlying formulation incorrect, or was the model simply infeasible by construction?
20+
21+
A common tool for helping diagnose the reason for infeasibility is an **Irreducible Infeasible Subsystem (IIS)**.
22+
An IIS is a subset of constraints and variable bounds from the original problem that:
23+
24+
1. Remains infeasible when considered together
25+
2. Cannot be further reduced without the subsystem becoming feasible
26+
27+
Practitioners can use IIS finders to narrow their focus onto a smaller, more manageable problem.
28+
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.
29+
30+
Generating an IIS
31+
=================
32+
Let us create a simple infeasible model and then generate an IIS for it.
33+
34+
.. code-block:: python
35+
36+
from pyscipopt import Model
37+
38+
m = Model()
39+
x1 = m.addVar("x1", vtype="B")
40+
x2 = m.addVar("x2", vtype="B")
41+
x3 = m.addVar("x3", vtype="B")
42+
43+
# These four constraints cannot be satisfied simultaneously
44+
m.addCons(x1 + x2 == 1, name="c1")
45+
m.addCons(x2 + x3 == 1, name="c2")
46+
m.addCons(x1 + x3 == 1, name="c3")
47+
m.addCons(x1 + x2 + x3 <= 0, name="c4")
48+
49+
model.optimize()
50+
iis = model.generateIIS()
51+
52+
When you run this code, SCIP will output a log showing the progress of finding the IIS:
53+
54+
.. code-block:: text
55+
56+
presolving:
57+
presolving (1 rounds: 1 fast, 0 medium, 0 exhaustive):
58+
2 deleted vars, 2 deleted constraints, 0 added constraints, 0 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
59+
0 implications, 0 cliques, 0 implied integral variables (0 bin, 0 int, 0 cont)
60+
presolving detected infeasibility
61+
Presolving Time: 0.00
62+
63+
SCIP Status : problem is solved [infeasible]
64+
Solving Time (sec) : 0.00
65+
Solving Nodes : 0
66+
Primal Bound : +1.00000000000000e+20 (0 solutions)
67+
Dual Bound : +1.00000000000000e+20
68+
Gap : 0.00 %
69+
time(s)| node | cons | vars | bounds| infeasible
70+
0.0| 0| 1| 3| 6| no
71+
0.0| 0| 2| 3| 6| no
72+
0.0| 0| 4| 3| 6| no
73+
0.0| 0| 3| 3| 6| yes
74+
0.0| 0| 2| 3| 6| yes
75+
0.0| 0| 2| 3| 6| yes
76+
77+
IIS Status : irreducible infeasible subsystem (IIS) found
78+
IIS irreducible : yes
79+
Generation Time (sec) : 0.01
80+
Generation Nodes : 0
81+
Num. Cons. in IIS : 2
82+
Num. Vars. in IIS : 3
83+
Num. Bounds in IIS : 6
84+
85+
.. note::
86+
While an already optimized infeasible model is not required to use the IIS functionality, it is
87+
encouraged to call this functionality only after ``model.optimize()``. Otherwise, SCIP will naturally optimize
88+
the base problem first to ensure that it is actually infeasible.
89+
90+
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.
91+
You see in the final statistics that the IIS is indeed irreducible, with 3 variables and 2 constraints.
92+
93+
The IIS Object
94+
==============
95+
96+
The ``IIS`` object returned by ``generateIIS()`` can be queried to access the following information:
97+
98+
- **time**: The CPU time spent finding the IIS
99+
- **irreducible**: Boolean indicating if the IIS is irreducible
100+
- **nodes**: Number of nodes explored during IIS generation
101+
- **model**: A ``Model`` object containing the subscip with the IIS constraints
102+
103+
You can interact with the subscip to examine which constraints and variables are part of the IIS:
104+
105+
.. code-block:: python
106+
107+
iis = model.generateIIS()
108+
subscip = iis.getSubscip()
109+
110+
# Get constraints in the IIS
111+
for cons in subscip.getConss():
112+
print(f"Constraint: {cons.name}")
113+
114+
# Get variables in the IIS
115+
for var in subscip.getVars():
116+
print(f"Variable: {var.name}")
117+
118+
Creating a Custom IIS Finder
119+
=============================
120+
121+
You may want to implement your own algorithm to find an IIS.
122+
PySCIPOpt supports this through the ``IISfinder`` class, which allows you to define custom logic
123+
for identifying infeasible subsystems.
124+
125+
Basic Structure
126+
---------------
127+
128+
To create a custom IIS finder, inherit from the ``IISfinder`` class and implement the ``iisfinderexec`` method:
129+
130+
.. code-block:: python
131+
132+
from pyscipopt import Model, IISfinder, SCIP_RESULT
133+
134+
class SimpleIISFinder(IISfinder):
135+
"""
136+
A simple IIS finder that removes constraints one by one
137+
until the problem becomes feasible.
138+
"""
139+
140+
def iisfinderexec(self):
141+
subscip = self.iis.getSubscip()
142+
constraints = subscip.getConss()
143+
144+
# Start with all constraints
145+
active_constraints = set(constraints)
146+
147+
for cons in constraints:
148+
# Temporarily remove the constraint
149+
active_constraints.discard(cons)
150+
151+
# Check if remaining constraints are still infeasible
152+
# (This would require setting up a sub-problem with only active_constraints)
153+
# For simplicity, we use the full solve approach here
154+
155+
subscip.freeTransform()
156+
subscip.delCons(cons)
157+
subscip.optimize()
158+
159+
if subscip.getStatus() == SCIP_STATUS.INFEASIBLE:
160+
# Still infeasible without this constraint
161+
# Keep it removed
162+
pass
163+
else:
164+
# Feasible without it, so constraint is needed in IIS
165+
active_constraints.add(cons)
166+
# In practice, you'd recreate the subscip with all active constraints
167+
168+
iis.markIrreducible()
169+
return {"result": SCIP_RESULT.SUCCESS}
170+
171+
Including Your Custom IIS Finder
172+
---------------------------------
173+
174+
To use your custom IIS finder, include it in the model before calling ``generateIIS()``:
175+
176+
.. code-block:: python
177+
178+
# Create model
179+
model = Model()
180+
181+
# Add variables and constraints (infeasible problem)
182+
x1 = model.addVar("x1", vtype="B")
183+
x2 = model.addVar("x2", vtype="B")
184+
x3 = model.addVar("x3", vtype="B")
185+
186+
model.addCons(x1 + x2 == 1, name="c1")
187+
model.addCons(x2 + x3 == 1, name="c2")
188+
model.addCons(x1 + x3 == 1, name="c3")
189+
190+
# Create and include the custom IIS finder
191+
simple_iis = SimpleIISFinder()
192+
model.includeIISfinder(
193+
simple_iis,
194+
name="simpleiis",
195+
desc="Simple greedy IIS finder",
196+
priority=1000000 # Higher priority means it will be used first
197+
)
198+
199+
# Solve to verify infeasibility
200+
model.optimize()
201+
202+
# Generate IIS using our custom finder
203+
iis = model.generateIIS()
204+
205+
# Examine the result
206+
print(f"\nIIS Information:")
207+
print(f" Time: {iis.getTime():.2f} seconds")
208+
print(f" Nodes: {iis.getNNodes()}")
209+
print(f" Irreducible: {iis.isSubscipIrreducible()}")
210+
print(f" Number of constraints: {iis.getSubscip().getNConss()}")
211+
212+
Key Methods in IISfinder
213+
-------------------------
214+
215+
When implementing a custom IIS finder, you have access to several important methods:
216+
217+
- ``subscip=self.iis.getSubscip()``: Get the sub-problem (Model) containing the candidate IIS
218+
- ``subscip.getConss()``: Get all constraints in the subscip
219+
- ``subscip.delCons(cons)``: Remove a constraint from the subscip
220+
- ``subscip.addCons(cons)``: Add a constraint back to the subscip
221+
- ``subscip.optimize()``: Solve the subscip
222+
- ``subscip.getStatus()``: Check if the subscip is infeasible

0 commit comments

Comments
 (0)