# Casting a problem in standard SOCP format in CVX

Consider the following problem:

$$\min \sum_{i=1}^n (Y_i - Z^{(i)})^2 \ \text{subjected to}~ \epsilon_k^{\top}(X_j-X_k) \leq Z^{(j)}-Z^{(k)} ~ \forall k,j = 1 \ldots n,\ \sum_{j=1}^d \sqrt{\sum_{i=1}^n \epsilon_{i,j}^2} \leq C.$$

where \epsilon_1, \ldots \epsilon_n, X_1 \ldots X_n \in \mathbb{R}^d and Z \in \mathbb{R}^n (and Z^{(i)} is the i^{th} component of Z) and Y_1, \ldots Y_n \in \mathbb{R}.

Note that we are given X_1, \ldots , X_n and Y_1, \ldots Y_n and the minimization is with respect to \epsilon_1, \ldots \epsilon_n and Z? Is this a SOCP program that could be cast in a format solvable in CVX ? Thanks a lot.

Declare epsilon to be an n by d matrix variable, and Y and Z to be n by 1. Then the objective is square(norm(Y-Z)), but you could consider changing the objective to norm(Y-Z), which will have the same argmin. All of the constraints except the last are linear and can be written out straightforwardly.

As for the last constraint, take the following as not necessarily the most elegant formulation (maybe someone else will post a “nicer” formulation), but I believe it should work. Use the code snippet

expression epsilon_column_norms(d)
for j=1:d,epsilon_column_norms(j)=norm(epsilon(:,j));end
sum(epsilon_column_norms) <= C