Steven Schwarz
Steven Schwarz

Reputation: 11

Cplex Term with 2 variables

i want to add this constraint to my ILP in cplex using java.

u_jk >= (u_ik + d_i + t_ij)x_ijk

    IloLinearNumExpr right = cplex.linearNumExpr();
    right.addTerm(serviceDuration , x[i][j][k]);
    right.addTerm(time[i][j], x[i][j][k]);
    right.addTerm(u[i][k], x[i][j][k]);
    cplex.addGe(u[j][k], right);

On the fourth line I get a problem, because u[i][k] and x[i][j][k] are IloNumVars. Any Idea, how to get this to work?

Upvotes: 0

Views: 367

Answers (1)

David Nehme
David Nehme

Reputation: 21572

It's because u*x is not linear if both u and x are variables. To create a quadratic expression using Ilog concert, you need to use the IloQuadNumExpr. However, once you get past that issue, you will have the issue that quadratic expressions with no square terms (zero on the diagonal) are neither convex or concave, so can't be solved with cplex. If either u or x is binary, you can use the transformation described in a previous question.

Upvotes: 1

Related Questions