Modelling squared euclidean distance in objective function (C-API)
回答済みI want to implement the following objective function in the C-API:
min (x²-1) + (y²-1)
As far as I see it in the documentation I would need to reformulate the objective function to
min x²-2x+1 + y²-2y+1
using the objective Attribute for the linear terms and GRBaddqpterms for the quadratic values. In that case I would need to add as well the constant value after the optimization, which is no problem of course. But I am curious if there is a more "elegant" way of incorporating this in the objective function?
-
正式なコメント
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Christian,
I'm guessing you have a typo and your objective is meant to be \(\min \quad (x-1)^2 + (y-1)^2 \)
You can add a constant to the objective like so:
error = GRBsetdblattr(model, "ObjCon", 2.0);
This is also a valid alternative:
\[\begin{align*} \min \quad w^2 + z^2 \\ w = x-1 \\ z = y-1 \end{align*}\]
- Riley
0
投稿コメントは受け付けていません。
コメント
2件のコメント