forked from ndwork/dworkLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdouglasRachford.m
49 lines (40 loc) · 1.27 KB
/
douglasRachford.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function out = douglasRachford( x0, proxf, proxg, t, varargin )
% out = douglasRachford( x0, proxf, proxg, t, varargin )
%
% minimizes f( x ) + g( x )
%
% Inputs:
% x0 - an array specifying the initial input
% proxf - a function handle to the proximal operator of f
% proxg - a function handle to the proximal operator of g
% t - the step size
%
% Optional Inputs:
% rho - the relaxation parameter; 0 < rho < 2
%
% Written by Nicholas Dwork - Copyright 2019
%
% This software is offered under the GNU General Public License 3.0. It
% is offered without any warranty expressed or implied, including the
% implied warranties of merchantability or fitness for a particular
% purpose.
p = inputParser;
p.addRequired( 'x0', @isnumeric );
p.addParameter( 'N', 100, @ispositive );
p.addParameter( 'rho', 1, @(x) numel(x) == 1 && x > 0 && x < 2 );
p.addParameter( 'verbose', false, @islogical );
p.parse( x0, varargin{:} );
N = p.Results.N;
rho = p.Results.rho;
verbose = p.Results.verbose;
z = x0;
for optIter = 1 : N
if verbose == true
disp([ 'douglasRachford: Working on ', indx2str(optIter,N), ' of ', num2str(N) ]);
end
x = proxf( z, t );
y = proxg( 2 * x - z, t );
z = z + rho( y - x );
end
out = y;
end