some problem about adding SOS constraint
AnsweredHi there,
Firstly, a binary variable 'DownDepInterval[k, i, r]' is defined and I need to add the following constraints
for (int k = 0; k < DownSerNum; k++)
{
for (int i = 0; i < TotalStaNum - 1; i++)
{
GRBLinExpr x = 0;
for (int r = 0; r < StaticData.TimeIntervalNum; r++)
{
x.AddTerm(1, DownDepInterval[k, i, r]);
}
model.AddConstr(x == 1, "c10," + k);
}
}
I am very interested whether the above constraint "model.AddConstr(x == 1, "c10," + k);" can be formulated in a SOS fashion.
Thanks,
Jiawei Yuan
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
A constraint x1 + ... + xn <= 1 with xj being binary variables says that at most one them can be non-zero. This is equivalent to forming the SOS1 constraint SOS1(x1,...,xn). But the SOS1 constraint doesn't help you here, because the linear constraint is stronger in terms of the LP relaxation. This is why Gurobi would immediately translate the SOS1 constraint back into the linear constraint during presolve.
Your constraint is an equality. This is not equivalent to an SOS constraint, because for an SOS, setting everything to zero is feasible.
Regards,
Tobias
0 -
Thank you very much, best wishes to you.
0
Post is closed for comments.
Comments
3 comments