# Sparse formulation in cvx

(Ali Darabi) #1

hello,
is it correct to do like this ?
if y is sparse

min norm(y-D*s)
subject to norm(s,1)< sparsity order

I worry that cvx couldnot find sparse vector with sparsity order, so I wrote this, but I got error.

min norm(y-D*s)
subject to norm(s,1)== sparsity order

thanks

(Mark L. Stone) #2

Do you want to do something with the sparsity order of the optimization variable s? That would be non-convex.

If you are referring to sparsity order of a sparse input vector y, then it should be straightforward to implement in CVX. For example,

``````y=sparse([0 1 0 2 0 3 0 4 0 5]');
D=rand(10,10);
cvx_begin
variable s(10,1)
minimize(norm(y-D*s))
norm(s,1) <= 4
cvx_end
``````

Of course, using an equality constraint on norm(s,1) is non-convex, and is not allowed by CVX.

(Ali Darabi) #3

I do play with your code and I found this

initial point of s does not have any effect on the optimization output.

clc
clear all
y=sparse([0 1 0 2 0 3 0 4 0 5]’);
D=rand(10,10);

s=ones(10,1);
cvx_begin
variable s(10,1)
minimize(norm(y-D*s))
norm(s,1) <= 4
cvx_end
figure; plot(s)

(Mark L. Stone) #4

Any value of s prior to its declaration in CVX is ignored by CVX. There is no way of specifying an initial value of a CVX variable to CVX. That is the designed behavior of CVX.