Skip to main content

Modifying quadratic coefficients (C++)

Answered

Comments

1 comment

  • 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

Please sign in to leave a comment.