How to handle absolute value in objective function?
回答済みDear Community,
I have a question about the possible way to handle absolute value in the objective function.
Assume that I has two variables a and b, and a constant c.
And I want to minimize |a*b - c| which is actually a QP objective function.
So far as I know I cannot implement it like (a * b - c) * (a * b - c) since this will form a objective function of the four power and Gurobi wouldn't accept this (I guess).
Is there any implementation that can solve this? BTW I am programming with C++.
Thank you in advance. :-)
Yingcong
-
正式なコメント
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?. -
Dear Yingcong,
A very detailed description of how to formulate the minimization of the absolute function can be found in the stackexchange post Converting absolute value program into linear program.
Regarding the formulation \((a \cdot b - c) \cdot (a \cdot b - c)\). It is possible to formulate it with Gurobi, if you introduce an auxiliary variable \(z\) and the equality constraint \[ z = a \cdot b.\] Your problem would then read
\[\begin{align*}
\min z &\cdot z - 2 \cdot c \cdot z + c \cdot c \\
z &= a\cdot b
\end{align*}\]You can find more information in our Knowledge Base article on How do I model multilinear terms in Gurobi?
Best regards,
Jaromił1 -
Dear Jaromił,
thank you very much for the sharing of the link about the problem formulation and the advice on the implementation. I have followed your lead and found a proper approach to solve it.
Best regards,
Yingcong
0
投稿コメントは受け付けていません。
コメント
3件のコメント