Reputation: 178
I have a problem involving continuous and binary variables. Once I am done with creating the objective function I add constraints which cause CPLEX to fail to find solution. Please let me know what I'm doing wrong.
IloNumExpr cbin1 = cplex.prod(EB_s[a-1],binHandelSprzedaj[a-1]);
cplex.addEq(EB[a],cbin1);
"binHandelSprzedaj" is array of binary variables. "EB_s" and "EB" are arrays of continuous cplex float variables.
Code works if instead of "cbin1" I put either “EB_s[a-1]” or “binHandelSprzedaj[a-1]”. I assume it's because I end up with quadratic constraint. However one of CPLEX provided examples “QCPex1” presents solution with “less-equal” quadratic constraints and the code looks very similar to what I have written. I don't understand why my codes doesn't work. Is it because constraint is quadratic or because it's mix of binary and continuous variables or that it's “equal” type of constraint.
Error message received: CPLEX Error 5002: Q in objective is not positive semi-definite
I'm a big noob at optimization. How do I deal with this problem? I would prefer if CPLEX did as much math as possible for me (maybe some magical command you can suggest).
Constraint in it's final form is more complicated so simple variable relaxation (as presented here http://orinanobworld.blogspot.com/2010/10/binary-variables-and-quadratic-terms.html) won't work. Constrain in the fully defined problem would look something like this:
a = b + c + d + binary * f - (1-binary)*g
where a – g are continuous variables.
Any help will be deeply appreciated.
Upvotes: 0
Views: 1151
Reputation: 16724
Cplex can handle convex MIQP (quadratic objective) and MIQCP (quadratic constraints) problems. It can also handle non-convex MIQPs (via parameter SolutionTarget
). We are left with quadratically constrained non-convex problems, which it cannot handle.
Luckily, we can always linearize the product of a binary and a continuous variable. The reference to Paul Rubin's blog will actually work. (Here is another recipe).
For that replace your:
a = b + c + d + binary * f - (1-binary)*g
by
a = b + c + d + binary * f - g + z
z = binary*g
where z
is another continuous variable. The equation
z = binary*g
can be linearized directly.
Upvotes: 0