Skip to main content

Can integer programming problem with non-continuous feasible region be solved with Gurobi?

Answered

Comments

4 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    Hi Hyewook,

    yes, this is possible, with the help of a few indicator constraints and variables. Perhaps this post will give you an idea.

    Best regards,
    Jonasz

    0
  • Hyewook Kim
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you for a help, and sorry for a late reply.

    I certainly got an idea from the post above that adding extra binary variables(z) can implement 'Or constraints', such as 'less than n1 Or greater than n2'.

     

    Now, I'm struggling with how to utilize this idea to present choose-one-of-numerous-'And constraints' problem like my original question.

    As written above, x should be between either one of (1<=x<=4) or (8<=x<=11) or (18<=x<=20) ranges.

    And adding binary variable might help the solver to choose one of these 3 between-ranges.

    But I'm still middle of figuring out how to implement 'And constraints' (e.g. greater than 1 and less than 4).

     

    Best regards,

    HW

     

    0
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    Hi Hyewook,

    the "And" part is governed by adding two indicator constraints for each indicator variable. For example:

    z[i, 1] = m.addVar(vtype="B",name=f"indicator_{i}_1")
    z[i, 2] = m.addVar(vtype="B",name=f"indicator_{i}_2")
    z[i, 3] = m.addVar(vtype="B",name=f"indicator_{i}_3")
        
    m.addLConstr(z[i, 1] + z[i, 2] + z[i, 3] == 1)
        
    m.addGenConstrIndicator(z[i, 1], True, x, gp.GRB.GREATER_EQUAL, 1.0)
    m.addGenConstrIndicator(z[i, 1], True, x, gp.GRB.LESS_EQUAL, 4.0)

    m.addGenConstrIndicator(z[i, 2], True, x, gp.GRB.GREATER_EQUAL, 8.0)
    m.addGenConstrIndicator(z[i, 2], True, x, gp.GRB.LESS_EQUAL, 11.0)

    m.addGenConstrIndicator(z[i, 3], True, x, gp.GRB.GREATER_EQUAL, 18.0)
    m.addGenConstrIndicator(z[i, 3], True, x, gp.GRB.LESS_EQUAL, 20.0)

    Hope this helps.

    Best regards
    Jonasz

    0

Post is closed for comments.