Using pyomo/cplex:
Suppose I have a cost function that takes 25 integers to be solved, each integer could be from (0 to 4)
The real model is more complex than this but I am trying to minimize the idea.
model.x = Var(range(25), range(5), domain=Binary, initialize=0)
for i in range(25):
model.constraint.add(sum([model.x[i, j] for j in range(5)]) == 1)
Suppose I found using different logical approach that integer 0, 1, 2 should be equal to 4. What I did is that I set a constraint as follows:
model.constraint.add(model.x[0, 4]) == 1
model.constraint.add(model.x[1, 4]) == 1
model.constraint.add(model.x[2, 4]) == 1
my idea is that I want to set pre-defined integers to fixed solutions that I found by other means to speed up the computation time. However, I have read that by adding more constraints you should take more time to reach solutions.
Can someone with experience provide me with a good opinion if there is a better approach?