OR constraint?
回答済みAny smart Gurobi guy can find errors in the following code segment?
This segment runs but does not have any impact to the optimization result.
This segment hopes to add an OR constraint:
------------
sum(0:n-1)(x[0][j]*V[j])-sum(0:n-1)(y[0][j]*V[j])>0 OR
sum(0:n-1)(x[1][j]*V[j])-sum(0:n-1)(y[1][j]*V[j])>0 OR
... OR
sum(0:n-1)(x[m-1][j]*V[j])-sum(0:n-1)(y[m-1][j]*V[j])>0)
------------
//Or constraints for V - Pareto Improvement Checking, i.e., y is not a Pareto improvement of x
GRBVar []orv=new GRBVar[m];
for (int i = 0; i<m; i++)
{
GRBLinExpr exprUniConstraint = new GRBLinExpr();
for (int j = 0; j<n; j++)
{
exprUniConstraint.addTerm(V[j], x[i][j]);
exprUniConstraint.addTerm(-V[j], y[i][j]);
}
orv[i]=model.addVar(0, 1, 1, GRB.BINARY, "var"+String.valueOf(i));
model.addGenConstrIndicator(orv[i], 1, exprUniConstraint, GRB.GREATER_EQUAL, 0.0000, "orv"+String.valueOf(i));
}
GRBVar Corv=model.addVar(0, 1, 1, GRB.BINARY, "Cvar");
model.addGenConstrOr(Corv, orv, "Corv");
-
正式なコメント
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?. -
Hi Haibin - Can you create a concrete example and show how your constraint is violated by the solution? From my quick look, it appears that you are combining all of the terms here. Thanks, G.
0 -
Hi Gwyneth,
Thank you for your response.
These parts should be OK. There is a problem in the modeling. I revised the modeling and used a different solution.
Best regards,
Haibin
0
投稿コメントは受け付けていません。
コメント
3件のコメント