Skip to content

Commit 3570a9a

Browse files
author
Release Manager
committed
Trac #34881: allow to remove no constraints
Removing no constraint makes sage glpk currently crash, which we fix here. URL: https://trac.sagemath.org/34881 Reported by: mantepse Ticket author(s): Martin Rubey Reviewer(s): Matthias Koeppe
2 parents 0ceb103 + b03cf22 commit 3570a9a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/sage/numerical/mip.pyx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2366,11 +2366,20 @@ cdef class MixedIntegerLinearProgram(SageObject):
23662366
....: p.add_constraint(x - y, max=10)
23672367
sage: p.number_of_constraints()
23682368
3
2369+
2370+
TESTS:
2371+
2372+
Removing no constraints does not make Sage crash, see
2373+
:trac:`34881`::
2374+
2375+
sage: MixedIntegerLinearProgram().remove_constraints([])
2376+
23692377
"""
23702378
if self._check_redundant:
23712379
for i in sorted(constraints, reverse=True):
23722380
self._constraints.pop(i)
2373-
self._backend.remove_constraints(constraints)
2381+
if constraints:
2382+
self._backend.remove_constraints(constraints)
23742383

23752384
def set_binary(self, ee):
23762385
r"""

0 commit comments

Comments
 (0)