Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 3a8b10d

Browse files
author
Matthias Koeppe
committed
Fix #20462 - MIPVariable.set_min, set_max
1 parent d5646a4 commit 3a8b10d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/sage/numerical/mip.pyx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,9 +2871,21 @@ cdef class MIPVariable(Element):
28712871
4
28722872
sage: p.get_min(v[0])
28732873
4.0
2874+
2875+
TESTS:
2876+
2877+
Test that :trac:`20462` is fixed::
2878+
2879+
sage: p.<x,y> = MixedIntegerLinearProgram()
2880+
sage: x[0], y[0]
2881+
(x_0, x_1)
2882+
sage: x.set_min(42)
2883+
sage: p.get_min(y[0]) is None
2884+
True
2885+
28742886
"""
28752887
self._lower_bound = min
2876-
for v in self._p._variables:
2888+
for v in self._dict.values():
28772889
self._p.set_min(v,min)
28782890

28792891
def set_max(self, max):
@@ -2896,9 +2908,20 @@ cdef class MIPVariable(Element):
28962908
4
28972909
sage: p.get_max(v[0])
28982910
4.0
2911+
2912+
TESTS:
2913+
2914+
Test that :trac:`20462` is fixed::
2915+
2916+
sage: p.<x,y> = MixedIntegerLinearProgram()
2917+
sage: x[0], y[0]
2918+
(x_0, x_1)
2919+
sage: x.set_max(42)
2920+
sage: p.get_max(y[0]) is None
2921+
True
28992922
"""
29002923
self._upper_bound = max
2901-
for v in self._p._variables:
2924+
for v in self._dict.values():
29022925
self._p.set_max(v,max)
29032926

29042927
def _repr_(self):

0 commit comments

Comments
 (0)