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.