Skip to main content

Why binary variables range from (0,1)

Answered

Comments

5 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.
  • Chenshi Jia
    • Gurobi-versary
    • First Question
    • First Comment

    Some pictures are missing.

    0
  • Michel Soares
    • Gurobi-versary
    • Thought Leader

    Hi Chenshi,

    I assume you might be referring to some of these 0.9999999 numbers. Indeed there are some "rounding errors" that may cause this behaviour (usually quite small, less than 1e-5).

    When checking whether a binary value is 0 or 1, you should consider a possible error, doing something like:

    if binary_value > 0.5:
    #assume binary is 1
    else:
    #assume binary is 0
    1
  • Chenshi Jia
    • Gurobi-versary
    • First Question
    • First Comment

    Thank you!

    0
  • Riley Clement
    • Gurobi Staff

    Note we have a parameter, IntegralityFocus, that can help with this but it incurs a (typically small) cost in performance.

    0

Post is closed for comments.