Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What happened to the dim parameter of new_variable?

Hello, Sage community!

I remember I could do this in order to have a bi-indexed variable for MILPs:

LP = MixedIntegerLinearProgram(maximization=True)
x = LP.new_variable(nonnegative=True, dim=2)

So, the syntax x[1][2] is valid. This behavior is documented in some books and manuals for SageMath (perhaps, a little dated now).

However, I just tried to do this in one of my programs, and Sage responded:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-350071b4e772> in <module>()
----> 1 x = LP.new_variable(nonnegative=True, dim=Integer(2))

/Scientific/SageMath/local/lib/python3.7/site-packages/sage/numerical/mip.pyx in sage.numerical.mip.MixedIntegerLinearProgram.new_variable (build/cythonized/sage/numerical/mip.c:6019)()
    701         self._backend.problem_name(name)
    702 
--> 703     def new_variable(self, real=False, binary=False, integer=False, nonnegative=False, name="",
    704                      indices=None):
    705         r"""

TypeError: new_variable() got an unexpected keyword argument 'dim'

Actually, LP.new_variable?? shows me the signature of the new_variable function, but the dim argument is missing.

Did something change? How can I get the same behavior now?

SageMath version: 9.0-beta8

Thanks in advance!