Question about model.AddGenConstrIndicator()
AnsweredI was debating someone about the behavior of Gurobi. We have a model using indicator constraints.
Let's say you create
int target1_value = 1;
for (int col = 0; col < sims.cols; ++col)
{
gap_value[col] = model.AddVar(0, GRB.INFINITY, 0, GRB.CONTINUOUS, "gaps");
GRBVar gap = model.AddVar(GRB.INFINITY, GRB.INFINITY, 0, GRB.CONTINUOUS, "gap");
b[col] = model.AddVar(0, 1, 0, GRB.BINARY, "b");
And then use
model.AddGenConstrIndicator(b[col], 1, gap == gap_value[col]  target1_value, "penalty_amt");
model.AddGenConstrIndicator(b[col], 0, gap == 0, "no_penalty_amt");
}
From my understanding of the documentation the model will seek to optimize the best values of b[col]. The debate was over whether or not b[col] is set to be 1 when the gap is positive or 0 otherwise.
Therefore, I understand that the gap being positive or not has nothing to do with the value of b[col], the model will choose this based on the constraints. What is debated is whether the value will be set based on the linear expression in the function argument.

What is debated is whether the value will be set based on the linear expression in the function argument.
I am not sure what you mean by the function argument.
If I understand you correctly, your assessment is true. As you mentioned, the values of variables \(b\) enforce restrictions on the values of variables \(\mbox{gap}\). For example, it is still possible for the \(b\) variable to be 1 and the \(\mbox{gap}\) variable to be 0 where \(\mbox{gap_value}\) equals \(\mbox{target1_value}\).
Best regards,
Maliheh
0 
Hi Maliheh, what I meant by function argument was the linear expression argument in AddGenConstrIndicator, whether the gap is positive or not. The debate was whether gap being positive enforced b == 1. But my view was the other way around, as I believe the documentation supports. b== 1 enforces the linear constraint. This also appears to be what you previous comment says as well.
The intended purpose of the constraints was to impose the constraint with a positive gap, and not impose them with a negative or 0 gap. But as implemented I do not believe they are doing this.
0 
What you have implemented is if \(b = 1\), then \(\mbox{gap} = \mbox{gap_value}  \mbox{target1_value}\).
Given the lower bound of 0 for the variable \(\mbox{gap_value}\), the variable \(\mbox{gap}\) is enforced to be between \(\mbox{target1_value}\) and \(\infty\). If the \(\mbox{target1_value}\) is a positive constant, it means that the \(\mbox{gap}\) variable is not forced to be strictly positive. You would need additional constraints to enforce if \(b = 1\), then \(\mbox{gap} \geq \epsilon\) with \(\epsilon\) being the smallest positive meaningful value for the \(\mbox{gap}\) variable.
0
Please sign in to leave a comment.
Comments
3 comments