Contents

```function [x,out] = lbreg_accelerated(A,b,alpha,opts)
```
```% lbreg_accelerated: linearized Bregman iteration with Nesterov's acceleration
%   minimize |x|_1 + 1/(2*alpha) |x|_2^2
%   subject to Ax = b
%
% input:
%       A: constraint matrix
%       b: constraint vector
%       alpha: smoothing parameter, typical value: 1 to 10 times estimated norm(x,inf)
%       opts.
%           lip: the estimated Lipschitz constrant of the dual objective, default: alpha*normest(A*A',1e-2)
%           tol: stop iteration once norm(Ax-b)<tol*norm(b), default: 1e-4
%           maxit: max number of iterations, default: 3000
%           maxT:  max running time in second, default: 1000
%           x_ref: if provided, norm(x^k - x_ref) is computed and saved in out.hist_err, default: []
%
% output:
%       x: solution vector
%       out.
%           iter: number of iterations
%           hist_obj: objective value at each iteration
%           hist_res: |Ax-b|_2 at each iteration
%           hist_err: if opts.x_ref is provided, contains norm(x^k - x_ref); otherwise, will be set to []
%
% Algorithm:
%   Linearized Bregman is the dual gradient ascent iteration.
%   The dual problem objective is:
%     b'y - alpha/2 |shrink(A'y,1)|^2,  where shrink(z,1) = z - proj_[-1,1](z) = sign(z).*max(abs(z)-1,0)
%
%   Let y be the dual variable. The gradient ascent iteration is
%     y^{k+1} = y^k + stepsize (b - alpha A shrink(A'y^k,1));
%   Primal variable x is obtained as x^k = alpha shrink(A'y^k,1)
%
%   The accelerated gradient ascent iteration is
%     beta^k = (1-theta^k)*(sqrt(theta^k*theta^k+4) - theta^k)/2;  (extroplation weight computation)
%     z^{k+1} = y^k + stepsize (b - alpha A shrink(A'y^k,1));      (gradient step, we choose stepsize = 1 / lip)
%     y^{k+1} = z^{k+1} + beta^k (z^{k+1} - z^k);                  (extrapolation step)
%     theta^{k+1} = theta^k*(sqrt(theta^k*theta^k+4) - theta^k)/2; (update of theta)
%
% How to set alpha:
%   There exists alpha0 so that any alpha >= alpha0 gives the solution to minimize |x|_1 subject to Ax = b.
%   The alpha depends on the data, but a typical value is 1 to 10 times the estimate of norm(solution_x,inf)
%
% How is the algorithm stopped: see "% stopping" below
%
% The code implements the Nesterov's acceleration algorithm for Linearized Bregman described in
%   B. Huang, S. Ma, and D. Goldfarb, Accelerated Linearized Bregman Method, J. Sci. Comput, 2012. DOI: 10.1007/s10915-012-9592-9
%
% http://www.caam.rice.edu/~optimization/linearized_bregman
```

Parameters and defaults

```if isfield(opts,'lip'),    lip = opts.lip;     else lip = alpha*normest(A*A',1e-2); end
if isfield(opts,'tol'),    tol = opts.tol;     else tol = 1e-4;   end
if isfield(opts,'maxit'),  maxit = opts.maxit; else maxit = 500;  end
if isfield(opts,'maxT'),   maxT = opts.maxT;   else maxT = 1e3;   end
if isfield(opts,'x_ref'),  x_ref = opts.x_ref; else x_ref = []; out.out.hist_err = [];  end
```

Data preprocessing and initialization

```m = size(A,1);

y = zeros(m,1);  % variable y in Nesterov's method
z = zeros(m,1);  % variable x in Nesterov's method
res = b; % residual (b - Ax)
norm_b = norm(b);

shrink = @(z) sign(z).*max(0,abs(z)-1);

theta = 1; % extrapolation auxilary parameter, initialized to 1
```

Main iterations

```start_time = tic;

for k = 1:maxit

% --- extrapolation parameter ---
beta = (1-theta)*(sqrt(theta*theta+4) - theta)/2;   % computes beta_k in P.80 (2.2.9) of Nesterov's 2004 textbook

% --- y-update ---
z_new = y + res/lip;            % step 1a in P.80 of Nesterov's 2004 textbook
y = z_new + beta*(z_new - z);   % step 1b in P.80 of Nesterov's 2004 textbook, extrapolation
z = z_new;

% --- x-update ---
x = alpha * shrink(y.'*A).';
Ax = A*x;
res = b - Ax; % res will be used in next y-update

% --- theta-update ---
theta = theta*(sqrt(theta*theta+4) - theta)/2;      % computes alpha_{k+1} in P.80 (2.2.9) of Nesterov's 2004 textbook

% --- diagnostics, reporting, stopping checks ---
% reporting
out.hist_obj(k) = b.'*y - norm(x)^2/alpha/2; % dual objective
out.hist_res(k) = norm(res); % residual size |b - Ax|_2
if ~isempty(x_ref); out.hist_err(k) = norm(x - x_ref); end

% stopping
if toc(start_time) > maxT; break; end; % running time check
if k > 1 && norm(res) < tol*norm_b; break; end % relative primal residual check
end

out.iter = k;
```