文章给出了求解:
1.投影到单纯形
2.投影到
l1
ball的算法。
下图只给出了复杂度为
O(nlogn)
的算法,关于算法复杂度为
O(n)
的算法,请参考文章后面的详细内容。
% 测试
clearvars;clc;
z=1;
%v=[4 4]';
v=[-0.5 1]';
w=proj2_L1ball0(v,z);
%真实的结果应该为:
% y=x; 与x+y=1,两条之间的交点,即点:(0.5,0.5)
function w=proj2_L1ball0(v,z)
% 函数的功能: 将高维空间点v投影到||w||_1 \leq z的ball中,即在ball中找到一个点与点v之间的欧式距离最小。
% input:
% v:待投影的矢量(点)
% z:L1 ball的约束
% output:
% w:投影后的矢量(点)
% 说明:其中点或者矢量都以列矢量的形式出现
n=length(v);
if norm(v,1)<=z
w=v;
else
u=abs(v);
su=sort(u,1,'descend');
j=1;
while true
if su(j)-(sum(su(1:j),1)-z)/j<0
j=j-1;
break;
end
if j==n
break;
end
j=j+1;
end
theta=1/j*(sum(su(1:j),1)-z);
w=bsxfun(@times,sign(v),max(u-theta,0));
end
end
从投影结果可以看出,很容易得到稀疏形式的解。
上图给出了三个投影的实例,不在
||w||1<1
范围内的点的投影均落在边界上,并且从上面点的投影来看,我们很容易求解出稀疏的解。
参考文献:
1.Efficient Projections onto the ℓ1-Ball for Learning in High Dimensions[2008]
2. latex\EPon2Ball.tex