Hi Guys
I wish to minimise a function consisting of a least squares term and a penalisation term, however the penaliser depends on a transformed version of the variable I wish to solve for.
My objective looks like:
\|Ax-b\|_2^2+\lambda\sum_{t=2}^T \sqrt{c_t+\|x_t-x_{t-1}\|_2^2}
where x is the concatenation of variables (I want to solve for) at different points in time s.t:
x=(x_{1,1},x_{1,2},x_{1,p},\ldots,x_{T,1},x_{T,p})
so x_t above is the sub vector:
x_t=(x_{t,1},x_{t,2},\ldots,x_{t,p}).
I was wondering how I can enter this in CVX, my problem comes down to summing over one dimension (t) and taking a norm over the other (\|x_t-x_{t-1}\|_2).
Is there a facility to do this kind of partial summation via the functions in CVX?
Also do I have to do some kind of variable transformation via say a differencing matrix? How would one specify such a transformed variable within the objective?
Best Wishes
Alex
Let x be a T\times p matrix. Assuming c_t\ge0, then let d be the (T-1)-vector with d_t=\sqrt{c_{t-1}}. Let D be the matrix of first differences, then your penalty is \left\|(Dx:d)\right\|_F and can be expressed as
norm([D * x, d], 'fro')
I haven’t actually tried this, but I think it’s right. Note: You could use sum_square(A*vec(x)-b) for the first part of the objective.
Edit (based on AlexG’s follow up comment): I believe you can do this without a for loop by using the function norms (combined with sum). Hope this helps.
Hmmm you are exactly right Bien, thank you for your answer, unfortunately I mistyped the function I am actually interested in a penalty which looks like
\lambda \sum_{t=2}^T\sqrt{(c_t+\|x_t-x_{t-1}\|_2^2)}
I can formulate similarly by converting x to a T\times p matrix and using the differencing matrix but the entries in the square root need to be considered at individual time-points.
In this case I need to be able to take the 2 norm of the rows within the matrix [D*X+d] performing the summation over the resultant vector.
Any ideas?
Once again thanks for your fast response 
EDIT: Ok so I found out how to do this with looped conditions via the page here:
https://inst.eecs.berkeley.edu/~ee127a/book/login/l_socp_group.html
Thank you for the help!
Best
Alex
Just a quick observation: if c_t\geq 0,
$$\sqrt{c_t+|x_t-x_{t-1}|2^2} = \left| \begin{bmatrix} \sqrt{c_t} \ x_t - x{t-1} \end{bmatrix} \right|_2$$
To sum over all of t, the norms function would come in handy:
lambda * sum(norms( [ sqrt(c)' ; x(:,2:end)-x(:,1:end-1) ] )
I’ve edited your question above to reflect your correction. (Readers, take note, you can and should edit your questions if you need to make corrections or clarifications!)