Skip to main content

Detect linear problem

Answered

Comments

3 comments

  • Official comment
    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?.
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Aron,

    If we would catch this special case, then we could argue about checking for fixed quadratic terms and removing these as well. Then again we could argue about checking for quadratic terms which can be removed via presolving and then fixing of variables. This cycle can be made arbitrary complex so we decided to just trust the user in their input and handle the constraint as quadratic if there is evidence of quadratic terms (even if it's empty).

    You can still achieve your goal by constructing the user input as a QuadExpr and then checking its size argument. If it is \(0\), then you know that it is indeed a LinExpr. You can then get the LinExpr from your QuadExpr via the GRBQuadExpr::getLinExpr function.

    Best regards,
    Jaromił

    0
  • Aron Zingler
    Conversationalist
    Gurobi-versary
    First Question

    Hi Jaromił,

    thanks for your suggestion. Indeed, this is very similar to the workaround currently employed.

    As you pointed out, you could always check for more special cases. Personally, I would argue that this a very basic check, similar to unused variables. On the other hand, I imagine most users will not run into this issue and people writing, e.g., wrappers can easily employ the mentioned strategy of checking the size of the QuadExpr.

     

    Maybe this could rather added to the documentation.

    0

Post is closed for comments.