Modifying quadratic coefficients (C++)
回答済みI'd like to modify coefficients of quadratic terms in objectives and constraints. It looks like there aren't any functions to directly do this from C++.
With an objective, you can use gurobi methods to get the objective, remove a quadratic term, add a quadratic term and then re-add the objective.
It's not clear how you would do something similar for a constraint.
What is the best practice for modifying quadratic terms "in place"?
--Bill
-
正式なコメント
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?. -
The best way to modify a quadratic expression (GRBQuadExpr object) is to add the new terms. This is what you suggest for a quadratic objective. For a quadratic constraint, you can't edit it in place. Instead, do the following:
- Get the GRBQConstr object
- Call GRBModel::getQCRow() to get the GRBQuadExpr object
- Modify the GRBQuadExpr object
- Call GRBModel::remove() to remove the original GRBQConstr
- Call GRBModel::addQConstr()
This doesn't exactly modify the model in place. However, unlike LP, there is less benefit to warm start.
0
投稿コメントは受け付けていません。
コメント
2件のコメント