Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Weird comportment of MixedIntegerLinearProgram

This is not realy a question but an observation perhaps a bugg I do not know.

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
x = p.new_variable(real=True, nonnegative=True)
p.set_integer(x[2])
p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
p.add_constraint(2*x[2] - 6*x[3] <= 0)
p.add_constraint(x[0] - x[1] - x[2] >= 0)
p.add_constraint(x[3] >= 1)
p.set_objective(3*x[1]+6*x[2]-3*x[3])
p.show()

This code set x[0] integer when it should be x[2]. The following code works

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
x = p.new_variable(real=True, nonnegative=True)
p.set_real(x[0])
p.set_real(x[1])
p.set_integer(x[2])
p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
p.add_constraint(2*x[2] - 6*x[3] <= 0)
p.add_constraint(x[0] - x[1] - x[2] >= 0)
p.add_constraint(x[3] >= 1)
p.set_objective(3*x[1]+6*x[2]-3*x[3])
p.show()

I find this weird. If I code p.set_integer(x[2]), I wait for x[2] to be integer. (I f I do not add p.set_real(x[1]), x[1] is setup integer). Certainly one more time, some body will say I do not read correctly the notice.

Weird comportment of MixedIntegerLinearProgram

This is not realy a question but an observation perhaps a bugg I do not know.

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
x = p.new_variable(real=True, nonnegative=True)
p.set_integer(x[2])
p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
p.add_constraint(2*x[2] - 6*x[3] <= 0)
p.add_constraint(x[0] - x[1] - x[2] >= 0)
p.add_constraint(x[3] >= 1)
p.set_objective(3*x[1]+6*x[2]-3*x[3])
p.show()

This code set x[0] integer when it should be x[2]. The following code works

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
x = p.new_variable(real=True, nonnegative=True)
p.set_real(x[0])
p.set_real(x[1])
p.set_integer(x[2])
p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
p.add_constraint(2*x[2] - 6*x[3] <= 0)
p.add_constraint(x[0] - x[1] - x[2] >= 0)
p.add_constraint(x[3] >= 1)
p.set_objective(3*x[1]+6*x[2]-3*x[3])
p.show()

I find this weird. If I code p.set_integer(x[2]), I wait for x[2] to be integer. (I f I do not add p.set_real(x[1]), x[1] is setup integer). Certainly one more time, some body will say I do not read correctly the notice.

Weird comportment behaviour of MixedIntegerLinearProgram

This is not realy Not really a question but question, more of an observation observation, perhaps a bugg bug, I do not know.

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
solver="GLPK")
x = p.new_variable(real=True, nonnegative=True)
p.set_integer(x[2])
p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
p.add_constraint(2*x[2] - 6*x[3] <= 0)
p.add_constraint(x[0] - x[1] - x[2] >= 0)
p.add_constraint(x[3] >= 1)
p.set_objective(3*x[1]+6*x[2]-3*x[3])
p.set_objective(3*x[1] + 6*x[2] - 3*x[3])
p.show()

This code set sets x[0] integer when it should be x[2]. .

The following code worksworks:

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
solver="GLPK")
x = p.new_variable(real=True, nonnegative=True)
p.set_real(x[0])
p.set_real(x[1])
p.set_integer(x[2])
p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
p.add_constraint(2*x[2] - 6*x[3] <= 0)
p.add_constraint(x[0] - x[1] - x[2] >= 0)
p.add_constraint(x[3] >= 1)
p.set_objective(3*x[1]+6*x[2]-3*x[3])
p.set_objective(3*x[1] + 6*x[2] - 3*x[3])
p.show()

I find this weird. If I code p.set_integer(x[2]), I wait for expect x[2] to be integer. (I f integer. (If I do not add p.set_real(x[1]), x[1] is setup integer). set to integer). Certainly one more time, some body somebody will say I do did not read correctly the notice.documentation correctly.