Calculation of norm of a constraint in a relaxed problem
AnsweredHi. I'd like to add the L2 norm of two constraint sets to the objective function of my augmented lagrangean relaxed model, e.g., L2 norm of llAx-bll+llBy-cll.
I tried to use norm(Ax-b, 2), but it did not work with a TypeError of "unsupported operand type(s) for +=: 'gurobipy.LinExpr' and 'GenExprNorm'".
I'll really appreciate if you could tell me how I can solve this problem.
Thank you in advance.
0
-
Official comment
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. -
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
Jonasz0 -
Dear Jonasz,
Yes, it worked. Thank you so much.
Best regards.
Sakir.
0
Post is closed for comments.
Comments
3 comments