メインコンテンツへスキップ

Modifying quadratic coefficients (C++)

回答済み

コメント

2件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff Gurobi Staff
    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?.
  • Greg Glockner
    • Gurobi Staff Gurobi Staff

    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:

    1. Get the GRBQConstr object
    2. Call GRBModel::getQCRow() to get the GRBQuadExpr object
    3. Modify the GRBQuadExpr object
    4. Call GRBModel::remove() to remove the original GRBQConstr
    5. Call GRBModel::addQConstr()

    This doesn't exactly modify the model in place. However, unlike LP, there is less benefit to warm start.

    0

投稿コメントは受け付けていません。