Skip to content

Commit e2d9038

Browse files
committed
little IIS progress
1 parent 389ac74 commit e2d9038

2 files changed

Lines changed: 37 additions & 29 deletions

File tree

src/pyscipopt/scip.pxi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9018,12 +9018,12 @@ cdef class Model:
90189018
"""
90199019
PY_SCIP_CALL(SCIPincludeIISfinderGreedy(self._scip))
90209020

9021-
# def iisGreedyMinimize(self, IISfinder iisfinder):
9022-
# """
9023-
# Perform the greedy deletion algorithm with singleton batches to obtain an irreducible infeasible subsystem (IIS)
9024-
# """
9021+
def iisGreedyMakeIrreducible(self, IISfinder iisfinder):
9022+
"""
9023+
Perform the greedy deletion algorithm with singleton batches to obtain an irreducible infeasible subsystem (IIS)
9024+
"""
90259025

9026-
# PY_SCIP_CALL(SCIPiisGreedyMakeIrreducible(iisfinder._iisfinder))
9026+
PY_SCIP_CALL(SCIPiisGreedyMakeIrreducible(iisfinder._iisfinder))
90279027

90289028
def includeRelax(self, Relax relax, name, desc, priority=10000, freq=1):
90299029
"""

tests/test_iis.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
import pytest
22

3-
from pyscipopt import Model
4-
from pyscipopt.scip import IISfinder
3+
from pyscipopt import Model, IISfinder
54

6-
calls = []
7-
class myIISfinder(IISfinder):
8-
def iisfinderexec(self):
9-
calls.append('relaxexec')
5+
class myIIS(IISfinder):
6+
def __init__(self):
7+
super().__init__()
8+
self._iisfinder = None
109

11-
def test_iis_custom():
12-
from helpers.utils import random_mip_1
10+
def isIISFound(self):
11+
return self._iisfinder is not None
1312

14-
m = random_mip_1()
15-
x = m.addVar()
16-
m.addCons(x >= 1, "inf1")
17-
m.addCons(x <= 0, "inf2")
13+
def test_iis_greedy_make_irreducible():
14+
m = Model()
15+
x1 = m.addVar("x1")
16+
x2 = m.addVar("x2")
17+
x3 = m.addVar("x3")
18+
19+
m.addCons(x1 + x2 >= 5)
20+
m.addCons(x2 + x3 >= 5)
21+
m.addCons(x1 + x3 <= 3)
22+
23+
iisfinder = IISfinder()
1824

19-
iis = myIISfinder()
20-
m.includeIISfinder(iis, name="custom", desc="test")
21-
m.optimize()
22-
assert calls != []
25+
m.iisGreedyMakeIrreducible(iisfinder)
2326

24-
def test_iis_greedy():
27+
assert iisfinder.isIISFound() == True
28+
29+
def test_custom_iis():
2530
m = Model()
26-
x = m.addVar()
27-
m.addCons(x >= 1, "inf1")
28-
m.addCons(x <= 0, "inf2")
31+
x1 = m.addVar("x1")
32+
x2 = m.addVar("x2")
33+
x3 = m.addVar("x3")
34+
35+
m.addCons(x1 + x2 >= 5)
36+
m.addCons(x2 + x3 >= 5)
37+
m.addCons(x1 + x3 <= 3)
38+
39+
iisfinder = myIIS()
2940

30-
m.includeIISfinderGreedy()
31-
m.optimize()
41+
pass
3242

33-
test_iis_greedy()
34-
test_iis_custom()

0 commit comments

Comments
 (0)