id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
20602 Deprecate MixedIntegerLinearProgram.gen(), __call__, linear_function, which do not do anything useful; add default_variable method mkoeppe "As observed in the comments in #20461:
{{{
sage: mip = MixedIntegerLinearProgram(solver='GLPK')
sage: mip.gen(0) ### Names a variable, but does not create it in the backend
x_0
sage: mip.number_of_variables()
0
sage: mip[0] ### This now creates a variable. It prints the same as the result of gen(0), but is different.
x_0
sage: mip.get_values(mip.gen(0))
[...]
TypeError: Not a MIPVariable: x_0
sage: mip.is_real(mip.gen(0))
[...]
KeyError: x_0
sage: mip.is_real(mip[0])
True
}}}
To summarize, the `gen` method pretends that it can refer to backend variables (and so do `linear_function` and the special `__call__` method that is identical to `linear_function`). In reality, these methods cannot be use for anything except for what is tested in the docstring: printing some meaningless stuff.
This patch deprecates these three methods and removes the corresponding confusing and useless examples from the class documentation.
In return, the notion of the ""default MIP variable"" (which `__getitem__` refers to) is explained; and it is exposed to the user by new method `default_variable`.
" defect closed major sage-7.3 numerical fixed lp nbruin dimpase vdelecroix jdemeyer chapoton novoselt Matthias Koeppe Dima Pasechnik N/A 684e91cad780b7dd2b0ec04e514b5ecf9ec95af0 684e91cad780b7dd2b0ec04e514b5ecf9ec95af0