Skip to main content

Calculation of norm of a constraint in a relaxed problem

Answered

Comments

3 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.
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    Hi Sakir,

    I'm not sure I got your question right, but let me give it a shot.

    I would suggest the following approach:

    # I assume A and b are constants and x is defines as Gurobi variable
    z = model.addVar()
    nz = model.addVar()
    model.addLConstr(z == A*x - b)
    model.addConstr(nz == gp.norm([z], 2.0))

    Hope this helps.

    Best regards
    Jonasz

    0
  • SAKIR KARAKAYA
    • Gurobi-versary
    • First Comment
    • First Question

    Dear Jonasz,

    Yes, it worked. Thank you so much.

    Best regards.

    Sakir.

    0

Post is closed for comments.