Prev Next with_l2_ok.m

l1_with_l2: Example and Test

Source Code
 
function [ok] = with_l2_ok()
ok = true;
% ------------------------------------------------------------------------
% You can change these parameters
ell = 300; % number of l1 equations
m   = 200; % number of l2 equations
n   = 100; % number of variables in minimization problem
% ------------------------------------------------------------------------
% Define the problem
rand('seed', 123);
A        = rand(ell, n)  * diag( 1:n );
a        = diag( 1:ell ) * rand(ell, 1);
B        = rand(m, n)  * diag( 1:n );
b        = diag( 1:m ) * rand(m, 1);
%
% compute solution
max_itr    = 20;
delta      = 1e-5 * max(max(abs([A ; B])));
[x , info] = l1_with_l2(max_itr, A, a, B, b, delta);
%
% check solution
obj = sum( abs( A * x - a ) ) + .5 * (B * x - b)' * (B * x - b);
for j = 1 : n
     xj    = x(j);
     x(j)  = xj + 1e-2;
     check = sum( abs( A * x - a ) ) + .5 * (B * x - b)' * (B * x - b);
     ok    = ok & (check >= obj);
     x(j)  = xj - 1e-2;
     check = sum( abs( A * x - a ) ) + .5 * (B * x - b)' * (B * x - b);
     ok    = ok & (check >= obj);
     x(j)  = xj;
end
%
return
end

Input File: test/with_l2_ok.m