Dear All,
I am trying to solve a mixed-integer optimization problem in JuMP
and Gurobi
. I have a variable x_{i,j} over i,j \in \{1,2,\ldots,n\}, where n is a fairly large number. However, for this particular problem, over an index set
P=\{(i,j) \mid (i,j) \textrm{ satisfying some property}\},
I have x_{i,j} = 0 for all i,j \in P.
Because there are other constraints involving x_{i,j}, it is more convenient if I set those values over P to zero through JuMP
rather than hard coding them. I see there are two ways I can do that in JuMP
, one is via fix
and the other one is through @constraint
macro, e.g.,
for i,j in P
@constraint(model_name, x[i,j] == 0.0)
end
or
for i, j in P
fix(x[i,j], 0.0; force = true)
end
For better performance, which one would be more suitable? Any tips/suggestions will be much appreciated!