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

Commit 881d1ac

Browse files
author
Matthias Koeppe
committed
default_variable: New
1 parent 422abf6 commit 881d1ac

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/sage/numerical/mip.pyx

+15-3
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,7 @@ cdef class MixedIntegerLinearProgram(SageObject):
639639
sage: p['x']
640640
x_0
641641
"""
642-
if self._default_mipvariable is None:
643-
self._default_mipvariable = self.new_variable()
644-
return self._default_mipvariable[v]
642+
return self.default_variable()[v]
645643

646644
def base_ring(self):
647645
"""
@@ -815,6 +813,20 @@ cdef class MixedIntegerLinearProgram(SageObject):
815813
lower_bound=0 if (nonnegative or binary) else None,
816814
upper_bound=1 if binary else None)
817815

816+
def default_variable(self):
817+
"""
818+
Return the default :class:`MIPVariable` of `self`.
819+
820+
EXAMPLE::
821+
822+
sage: p = MixedIntegerLinearProgram(solver='GLPK')
823+
sage: p.default_variable()
824+
MIPVariable of dimension 1
825+
"""
826+
if self._default_mipvariable is None:
827+
self._default_mipvariable = self.new_variable()
828+
return self._default_mipvariable
829+
818830
def _first_ngens(self, n):
819831
"""
820832
Construct the first `n` :class:`MIPVariable`s.

0 commit comments

Comments
 (0)