Skip to main content

Detect linear problem

Answered

Comments

2 comments

  • 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
    Gurobi-versary
    First Question
    First Comment

    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

Please sign in to leave a comment.