MixedIntegerProgramming with more than 2 indexes
Some integer linear programming needs more indexes than two. But this works
p = MixedIntegerLinearProgram(maximization=False, solver="GLPK")
x = p.new_variable(integer=True, nonnegative=True)
p.set_objective(sum(sum(x[i,t] for t in range(10)) for i in range(5)));
p.add_constraint(sum(sum(x[i,t] for t in range(10)) for i in range(5))<=1);
p.show()
and this doesn't.
p = MixedIntegerLinearProgram(maximization=False, solver="GLPK")
x = p.new_variable(integer=True, nonnegative=True)
p.set_objective(sum(sum(sum(x[i,j,t] for t in range(10)) for i in range(5)))for j in range(5));
p.add_constraint(sum(sum(sum(x[i,j,t] for t in range(10)) for i in range(5))) for j in range(5));
p.show()
Is there a way out ?
I would ask for uniformity of notations. The code for sum()
is not the same in Linear programming and outside. This is missleading.
Closing parenthesis are not well placed. This is working