Skip to main content

Modeling quadratic constraints in different variables

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff 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?.
  • Matthias Miltenberger
    • Gurobi Staff Gurobi Staff

    Hi Surya,

    Yes, this is possible:

    import gurobipy as gp
    import numpy as np

    m = gp.Model()
    n = 3
    x = m.addMVar(n, name='x')
    y = m.addMVar(n, name='y')
    c = 2

    m.addConstr(x @ np.eye(3) @ y <= c)

    Resulting in this QP:

    Minimize

    Subject To
    qc0: [ x[0] * y[0] + x[1] * y[1] + x[2] * y[2] ] <= 2
    Bounds
    End

    Cheers,
    Matthias

    1

Post is closed for comments.