SPGL1 Solve basis pursuit, basis pursuit denoise, and LASSO
[x, r, g, info] = spgl1(A, b, tau, sigma, x0, options)
(IN) is an m-by-n matrix, explicit or an operator.
(IN) is an m-vector.
(IN) is a nonnegative scalar; see (LASSO).
(IN) is a nonnegative scalar (noise); see (BPDN)
(IN) is an n-vector initial estimate of the solution
(IN) is a structure of options from spgSetParms
(OUT) is a solution of the problem
(OUT) is the residual, r = b - Ax
(OUT) is the gradient, g = -A'r
(OUT) is a structure with output information
--------------------------------------------------------------------- Solve the basis pursuit denoise (BPDN) problem
(BPDN) minimize ||x||_1 subj to ||Ax-b||_2 <= sigma,
or the l1-regularized least-squares problem
(LASSO) minimize ||Ax-b||_2 subj to ||x||_1 <= tau. ---------------------------------------------------------------------
INPUTS ====== A is an m-by-n matrix, explicit or an operator. If A is a function, then it must have the signature
y = A(x,mode) if mode == 1 then y = A x (y is m-by-1); if mode == 2 then y = A'x (y is n-by-1).
b is an m-vector. tau is a nonnegative scalar; see (LASSO). sigma if sigma != inf or != [], then spgl1 will launch into a root-finding mode to find the tau above that solves (BPDN). In this case, it's STRONGLY recommended that tau = 0. x0 is an n-vector estimate of the solution (possibly all zeros). If x0 = [], then SPGL1 determines the length n via n = length( A'b ) and sets x0 = zeros(n,1). options is a structure of options from spgSetParms. Any unset options are set to their default value; set options=[] to use all default values.
OUTPUTS ======= x is a solution of the problem r is the residual, r = b - Ax g is the gradient, g = -A'r info is a structure with the following information: .tau final value of tau (see sigma above) .rNorm two-norm of the optimal residual .rGap relative duality gap (an optimality measure) .gNorm Lagrange multiplier of (LASSO) .stat = 1 found a BPDN solution = 2 found a BP sol'n; exit based on small gradient = 3 found a BP sol'n; exit based on small residual = 4 found a LASSO solution = 5 error: too many iterations = 6 error: linesearch failed = 7 error: found suboptimal BP solution = 8 error: too many matrix-vector products .time total solution time (seconds) .nProdA number of multiplications with A .nProdAt number of multiplications with A'
OPTIONS ======= Use the options structure to control various aspects of the algorithm:
options.fid File ID to direct log output .verbosity 0=quiet, 1=some output, 2=more output. .iterations Max. number of iterations (default if 10*m). .bpTol Tolerance for identifying a basis pursuit solution. .optTol Optimality tolerance (default is 1e-4). .decTol Larger decTol means more frequent Newton updates. .subspaceMin 0=no subspace minimization, 1=subspace minimization.
EXAMPLE ======= m = 120; n = 512; k = 20; // m rows, n cols, k nonzeros. p = randperm(n); x0 = zeros(n,1); x0(p(1:k)) = sign(randn(k,1)); A = randn(m,n); [Q,R] = qr(A',0); A = Q'; b = A*x0 + 0.005 * randn(m,1); opts = spgSetParms('optTol',1e-4); [x,r,g,info] = spgl1(A, b, 0, 1e-3, [], opts); // Find BP sol'n.