Skip to main content

Why is the solution for binary variables 0.999999?

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Simranjit Kaur
    • Gurobi Staff

    Hi Tianyu,

    As explained in the article Why does Gurobi sometimes return non-integral values for integer variables?, the solution value of a binary variable can deviate from 0 or 1. The tolerance for such deviation is defined by the IntFeasTol parameter (default value 1e-5).  

    If the problem with binary variables having a value like 0.999.. only occurs when you try to read them after optimization, you can simply round the values once the optimization process is done. Otherwise, you can try setting the IntegralityFocus parameter to 1, which will prompt Gurobi to take extra steps to remove the integrality violation while maintaining feasibility.

    Best regards,

    Simran

     

     

    1
  • Tianyu Mao
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you for your reply! I found your explanation very helpful.

    0

Post is closed for comments.