You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Permission is hereby granted, free of charge, to any person obtaining a copy
6
-
of this software and associated documentation files (the "Software"), to deal
7
-
in the Software without restriction, including without limitation the rights
8
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
-
copies of the Software, and to permit persons to whom the Software is
10
-
furnished to do so, subject to the following conditions:
5
+
Permission is hereby granted, free of charge, to any person btaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
6
12
-
The above copyright notice and this permission notice shall be included in all
13
-
copies or substantial portions of the Software.
7
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
8
15
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
-
SOFTWARE.
9
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
as well as the corresponding [SCIP Optimization Suite report](https://scip.zib.de/index.php#cite) when you use this tool for a publication or other scientific work.
122
+
123
+
Seeking Maintainers
124
+
----------------------------------
125
+
126
+
PySCIPOpt is sustained by volunteer effort, and as the project grows we are inviting more contributors and maintainers to join the team.
127
+
128
+
What needs to be done
129
+
----------------------
130
+
These are the core responsibilities:
131
+
132
+
* Community support: Going over the open issues regularly. Occasionally visiting Stack Overflow and OR.SE, as users also ask questions there.
133
+
* PR review: Reviewing user pull requests, making sure that the CHANGELOG is updated, and all added methods are tested.
134
+
* API coverage: keep expanding PySCIPOpt's coverage of SCIP's C API.
135
+
* Documentation: help keep the documentation up to date, and add new tutorials/examples.
136
+
* Releases: there should be a PySCIPOpt release with every SCIP release, at a minimum.
137
+
138
+
Even if you are not interested in becoming a maintainer, but would like to help out occasionally, that would be very welcome as well!
139
+
140
+
Send us an email over at **joao.goncalves.dionisio@gmail.com** if you're ready to take on the challenge :)
Copy file name to clipboardExpand all lines: docs/tutorials/iis.rst
+30-48Lines changed: 30 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,21 +33,18 @@ Let us create a simple infeasible model and then generate an IIS for it.
33
33
34
34
.. code-block:: python
35
35
36
-
from pyscipopt import Model
36
+
x1 = model.addVar("x1", vtype="B")
37
+
x2 = model.addVar("x2", vtype="B")
38
+
x3 = model.addVar("x3", vtype="B")
37
39
38
-
m = Model()
39
-
x1 = m.addVar("x1", vtype="B")
40
-
x2 = m.addVar("x2", vtype="B")
41
-
x3 = m.addVar("x3", vtype="B")
40
+
# These four constraints cannot be satisfied simultaneously
41
+
model.addCons(x1 + x2 == 1, name="c1")
42
+
model.addCons(x2 + x3 == 1, name="c2")
43
+
model.addCons(x1 + x3 == 1, name="c3")
44
+
model.addCons(x1 + x2 + x3 <= 0, name="c4")
42
45
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()
46
+
model.optimize()
47
+
iis = model.generateIIS()
51
48
52
49
When you run this code, SCIP will output a log showing the progress of finding the IIS:
53
50
@@ -82,14 +79,14 @@ When you run this code, SCIP will output a log showing the progress of finding t
82
79
Num. Vars. in IIS : 3
83
80
Num. Bounds in IIS : 6
84
81
82
+
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.
83
+
You see in the final statistics that the IIS is indeed irreducible, with 3 variables and 2 constraints.
84
+
85
85
.. note::
86
86
While an already optimized infeasible model is not required to use the IIS functionality, it is
87
87
encouraged to call this functionality only after ``model.optimize()``. Otherwise, SCIP will naturally optimize
88
88
the base problem first to ensure that it is actually infeasible.
89
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
90
The IIS Object
94
91
==============
95
92
@@ -98,7 +95,7 @@ The ``IIS`` object returned by ``generateIIS()`` can be queried to access the fo
98
95
- **time**: The CPU time spent finding the IIS
99
96
- **irreducible**: Boolean indicating if the IIS is irreducible
100
97
- **nodes**: Number of nodes explored during IIS generation
101
-
- **model**: A ``Model`` object containing the subscip with the IIS constraints
98
+
- **subscip**: A ``Model`` object containing the subscip with the IIS constraints
102
99
103
100
You can interact with the subscip to examine which constraints and variables are part of the IIS:
104
101
@@ -125,47 +122,31 @@ for identifying infeasible subsystems.
125
122
Basic Structure
126
123
---------------
127
124
128
-
To create a custom IIS finder, inherit from the ``IISfinder`` class and implement the ``iisfinderexec`` method:
125
+
To create a custom IIS finder, inherit from the ``IISfinder`` class and implement the ``iisfinderexec`` method.
126
+
This IISfinder just directly removes two constraints in the example above to yield an IIS:
129
127
130
128
.. code-block:: python
131
129
132
-
from pyscipopt importModel, IISfinder, SCIP_RESULT
130
+
from pyscipopt import IISfinder, SCIP_RESULT
133
131
134
132
classSimpleIISFinder(IISfinder):
135
133
"""
136
-
A simple IIS finder that removes constraints one by one
137
-
until the problem becomes feasible.
134
+
Minimal working example: keep a known infeasible subset (by name)
135
+
and mark it as the IIS.
138
136
"""
139
137
140
138
defiisfinderexec(self):
141
139
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()
140
+
141
+
# keep only constraints {c2, c4} and delete others
142
+
keep = {"c2", "c4"}
143
+
for cons inlist(subscip.getConss()):
144
+
if cons.name notin keep:
145
+
subscip.delCons(cons)
146
+
147
+
# Tell SCIP that our sub-SCIP represents an (irreducible) IIS
148
+
self.iis.setSubscipInfeasible(True)
149
+
self.iis.setSubscipIrreducible(True)
169
150
return {"result": SCIP_RESULT.SUCCESS}
170
151
171
152
Including Your Custom IIS Finder
@@ -186,6 +167,7 @@ To use your custom IIS finder, include it in the model before calling ``generate
0 commit comments