Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change in linear programming syntax

Until the recent update in SMC to the latest version of Sage, the following would work:

p = MixedIntegerLinearProgram()
x=p.new_variable(nonnegative=True)
y=p.new_variable(nonnegative=True)
z=p.new_variable(nonnegative=True)
p.set_objective(x + y+ 3*z)

This now gives an error saying that * and + are not defined for these objects.

The following does work, however:

p = MixedIntegerLinearProgram()
x=p.new_variable(nonnegative=True)
y=p.new_variable(nonnegative=True)
z=p.new_variable(nonnegative=True)
p.set_objective(x[0] + y[0]+ 3*z[0])

So, are all new variables in an MILP assumed to be arrays? Is there are way to work with variables as in my first example without using subscripts? (This is mainly for teaching purposes.)