Skip to main content

Why does Gurobi return non-integral values for integer/binary variables?

Answered

Comments

5 comments

  • Official comment
    Simranjit Kaur
    • 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

    Hi Khadija,

    All numerical algorithms work with finite precision. This unfortunately results in integer variable not actually taking truly integer values but rather being almost integer (up to a given error). This error can be controlled via the IntFeasTol parameter. If you are interested in truly integer values, you should experiment with the IntegralityFocus parameter. Please note that setting these parameters may worsen performance significantly.

    Best regards,
    Jaromił

    0
  • Khadija HADJ SALEM
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromil, 

    I added the IntegralityFocus parameter, but I am getting the same problem again: non-integral value for some Integer/Binary variables.

    m3.Params.IntegralityFocus = 1

    Best regards,

    Khadija

     

     

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Khadija,

    Please note that setting the IntegralityFocus parameter does not guarantee to provide truly integer solutions. From the parameter documentation

    More precisely, the solver tries to find solutions that are still (nearly) feasible if all integer variables are rounded to exact integral values. We should say that the solver won't always succeed in finding such solutions, and that this setting introduces a modest performance penalty, but the setting will significantly reduce the frequency and magnitude of such violations.

    You could try decreasing the IntFeasTol parameter to \(\texttt{1e-9}\). If this does not help, you could try rounding the solution value by hand and checking whether the then truly integer solution is feasible (within tolerances).

    Best regards,
    Jaromił

    0
  • Gwyneth Butera
    • Gurobi Staff

    More information can be found in our Knowledge Base article  Why does Gurobi sometimes return non-integral values for integer variables? -G

    0

Post is closed for comments.