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

Commit

Permalink
Document generator syntax some more
Browse files Browse the repository at this point in the history
  • Loading branch information
vbraun committed Aug 14, 2014
1 parent e2ddf8c commit d3d0d10
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions src/sage/numerical/mip.pyx
Expand Up @@ -617,8 +617,7 @@ cdef class MixedIntegerLinearProgram(SageObject):
def new_variable(self, real=False, binary=False, integer=False, nonnegative=None, dim=1, name=""):
r"""
Returns an instance of ``MIPVariable`` associated
to the current instance of ``MixedIntegerLinearProgram``.
Return a new MIPVariable
A new variable ``x`` is defined by::
Expand All @@ -629,6 +628,14 @@ cdef class MixedIntegerLinearProgram(SageObject):
argument you may like, as ``x[5]`` or ``x["b"]``, and has methods
``items()`` and ``keys()``.
.. SEEALSO::
- :meth:`set_min`,:meth:`get_min` -- set/get the lower bound of a
variable. Note that by default, all variables are non-negative.
- :meth:`set_max`,:meth:`get_max` -- set/get the upper bound of a
variable.
INPUT:
- ``dim`` -- integer. Defines the dimension of the dictionary.
Expand All @@ -647,13 +654,10 @@ cdef class MixedIntegerLinearProgram(SageObject):
using ``write_mps`` or ``write_lp``, and has no other
effect.
.. SEEALSO::
- :meth:`set_min`,:meth:`get_min` -- set/get the lower bound of a
variable. Note that by default, all variables are non-negative.
- :meth:`set_max`,:meth:`get_max` -- set/get the upper bound of a
variable.
OUTPUT:
A new instance of :class:`MIPVariable` associated to the
current :class:`MixedIntegerLinearProgram`.
EXAMPLE::
Expand Down Expand Up @@ -696,6 +700,22 @@ cdef class MixedIntegerLinearProgram(SageObject):
x_2 is an integer variable (min=-oo, max=+oo)
x_3 is an integer variable (min=-oo, max=+oo)
On the Sage command line, generator syntax is accepted as a
shorthand for generating new variables with default
(``nonnegative=False``) settings::
sage: mip.<x, y, z> = MixedIntegerLinearProgram()
sage: mip.add_constraint(x[0] + y[1] + z[2] <= 10)
sage: mip.show()
Maximization:
<BLANKLINE>
Constraints:
x[0] + y[1] + z[2] <= 10.0
Variables:
x[0] = x_0 is a continuous variable (min=-oo, max=+oo)
y[1] = x_1 is a continuous variable (min=-oo, max=+oo)
z[2] = x_2 is a continuous variable (min=-oo, max=+oo)
TESTS:
Default behaviour (:trac:`15521`)::
Expand Down

0 comments on commit d3d0d10

Please sign in to comment.