L1 Optimization in matlab
3 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I am trying to solve a slightly modified L1 optimization problem in matlab
argmin_x : |x-d|||^2 + |Fx|||_1
where F is a low rank matrix and d is a given vector. x is the variable to be minimized. Could you suggest the best way to solve this in matlab??
0 个评论
采纳的回答
Teja Muppirala
2013-5-15
Make some d and F just to test it.
d = [1;2;3;4;5];
F = [.1 .3 .5 .7 .9; .2 .4 .6 .8 1.0];
I can think of two ways.
1. Use FMINUNC. This is simple to set up, but for larger problems it will take some time, and you may need to set options such as MaxFunEvals with OPTIMSET to make it work.
V = @(x) norm(x-d)^2+norm(F*x,1);
xopt = fminunc(V,d)
2. Use QUADPROG. This is more complicated to set up, but much faster and more accurate. Create slack variables to deal with the L1 part.
s = size(F,1);
nx = size(F,2);
f = [-2*d; zeros(s,1); ones(s,1)];
H = blkdiag(2*eye(nx),zeros(s),zeros(s));
Aeq = [F -eye(s) -zeros(s)];
beq = zeros(s,1);
A = [zeros(s,nx) eye(s) -eye(s);
zeros(s,nx) -eye(s) -eye(s)];
b = zeros(2*s,1);
[xopt,fval] = quadprog(H,f,A,b,Aeq,beq);
xopt = xopt(1:nx)
Trying it out for d and F given above, I get the same answer either way.
xopt =
0.8500
1.6500
2.4500
3.2500
4.0500
0 个评论
更多回答(1 个)
Sravan Karrena
2019-3-21
编辑:Walter Roberson
2019-3-21
s = size(F,1);
nx = size(F,2);
f = [-2*d; zeros(s,1); ones(s,1)];
H = blkdiag(2*eye(nx),zeros(s),zeros(s));
Aeq = [F -eye(s) -zeros(s)];
beq = zeros(s,1);
A = [zeros(s,nx) eye(s) -eye(s); zeros(s,nx) -eye(s) -eye(s)];
b = zeros(2*s,1);
[xopt,fval] = quadprog(H,f,A,b,Aeq,beq);
xopt = xopt(1:nx)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!