Skip to main content

Calculation of norm of a constraint in a relaxed problem

Answered

Comments

2 comments

  • Jonasz Staszek
    Community Moderator 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

Please sign in to leave a comment.