Constraint on the sum of the absolute values in QP?

1,449 views
Skip to first unread message

Adrian Sarno

unread,
Mar 22, 2016, 12:13:20 AM3/22/16
to CVXOPT


I am coding qp() solver to maximizes a quadratic objective.

The x vector is constrained between -1 and +1 by the inequality constraint.

Is it possible to constrain the sum of absolute values to be equal to 1?
like in:        sum_i( abs(x_i)) == 1

thanks in advance

Martin

unread,
Mar 22, 2016, 2:33:03 AM3/22/16
to CVXOPT
No, it's a non-convex constraint, but the constraint sum_i(abs(x_i)) <= 1 is convex. 

Adrian Sarno

unread,
Mar 22, 2016, 3:14:06 AM3/22/16
to CVXOPT
thanks for your response, inequality would work fine. I would need a bit of help to code it.

I can't figure out how to code the abs() inside the sum()
The closest I get is to code an inequality constraint on the linear sum_i(x_i) <= 1 
but not sum_i(abs(x_i)) <= 1

  # Create inequality constraint for sum_i(x_i) <= 1
    G = opt.matrix(1.0, (1, n))  #   row vector for sum_i(), with dot product.
    h = opt.matrix(1.0, (n ,1))   # column vector of constraints 

Martin

unread,
Mar 22, 2016, 4:03:52 AM3/22/16
to CVXOPT

You can express the constraint in terms of the following linear inequality constraints:

-t_i \leq x_i \leq t_i and t_1 + t_2 +\cdots + t_n \leq 1

Adrian Sarno

unread,
Mar 22, 2016, 3:27:36 PM3/22/16
to CVXOPT
I understand the logic, but I can't find a place in the cvxopt function for quadratic programming to include the t variables.
How can you add those variables to the model?

Martin

unread,
Mar 23, 2016, 4:26:09 AM3/23/16
to CVXOPT

You can define a new variable (x,t) so that

[-I -I ][x] <= [0]
[ I -I ][t]    [0]
[ 0 e ]       [1]

corresponds to the inequality in the QP and e = (1,\ldots,1). In other words, you let the vector x in the QP correspond to (x,t) in your problem formulation.

Adrian Sarno

unread,
Mar 24, 2016, 2:42:56 PM3/24/16
to CVXOPT
that worked!
thanks a lot, I learned what I needed to know.
...
Reply all
Reply to author
Forward
0 new messages