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
-
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
Please sign in to leave a comment.
Comments
2 comments