Skip to main content

Combining Different Types if Variables in Matrix Constraints

Ongoing

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?.
  • Mario Ruthmair
    • Gurobi Staff

    Hi Mr. Satender,

    You could create a one-dimensional binary matrix variable including both variable sets x and z, and then change the type of the x variables to CONTINUOUS afterwards, as demonstrated below on a small example:

    A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
    b = np.array([1, 2, 3])

    m = gp.Model("model")
    x = m.addMVar(3, vtype=GRB.BINARY, name="x")
    x[0].VType = GRB.CONTINUOUS

    m.addConstr(A @ x <= b, name="matrix")
    Best regards,
    Mario
    1

Post is closed for comments.