Originally posted by: EdKlotz
If you're not sure how to model your quadratic function, in general I'd recommend starting with a simpler quadratic function, like f(x) = x^2, get that working, and gradually add terms after that.
Your situation is only slightly different than what I posted previously, because you have a linear term as well as a quadratic term. So you are looking at
z ==1 --> x'Qx + c'x <= b
and the linearization you want to use is
x'Qx + c'x + Mz<= b + M
In your case, the quadratic part is ax^2 + exy + cy^2
and the linear part is
bx + dy + f.
So in DoCplex you add the linear constraint
ax^2 + exy + cy^2 + bx + dy + f.+ Mz <= B + M
and it should give you what you want. Regarding deriving a reasonable bound on f(x,y) that you can use for M, you can use the upper (and possibly lower) bounds on x and y to do that. I'm doing to assume a, e, c, b, d and f are all >= 0, so that we only need consider the upper bounds. If some of those values are negative, we'd need to consider lower bounds as well, but the idea is basically the same, namely that if U1 and U2 are the upper bounds on x and y, then
ax^2 + exy + cy^2 + bx + dy + f. <= aU1^2 + eU1*U2 + cU2^2 + bU1 + dU2 + f
Use this bound on your f(x,y) as your big M value. Hopefully your U1 and U2 bounds, and your a, b, c, d, e and f values are all fairly reasonable, to this value of M is modest, and spares you potential numerical troubles if you pick an arbitrarily large value. But if not, you can also try solving
max f(x,y)
s.t.
<all other constraints in the model>
and hopefully that will give you a tighter value for M.
#CPLEXOptimizers#DecisionOptimization