Skip to main content

How to relax integrality for some variables?

Answered

Comments

2 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?.
  • Eli Towle
    • Gurobi Staff

    Hi,

    You can change the type of a variable by modifying the VType variable attribute. For example:

    import gurobipy as gp

    m = gp.Model()

    # Create binary variable
    x = m.addVar(vtype=gp.GRB.BINARY)
    m.update()
    print("x's original type is: {}".format(x.VType))

    # Change to continuous
    x.VType = gp.GRB.CONTINUOUS
    m.update()
    print("x's new type is: {}".format(x.VType))

    gives us:

    x's original type is: B
    x's new type is: C

    Thanks,

    Eli

    0

Post is closed for comments.