Skip to content

Commit 6ab8c7e

Browse files
committed
Update to include more examples and operator classes
1 parent 6186f03 commit 6ab8c7e

30 files changed

Lines changed: 1646 additions & 155 deletions

Examples/ConditionalGradient.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@
5454
%
5555
% See Jaggi, Martin. "Revisiting Frank-Wolfe: Projection-free sparse
5656
% convex optimization." In: Proceedings of the 30th International
57-
% Conference on Machine Learning (ICML-13), pp. 427–435 (2013)
58-
57+
% Conference on Machine Learning (ICML-13), pp. 427–435 (2013)

Examples/ConjugateGradientMethod.m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
clear all; clc;
2+
% In this example, we use a greedy first-order method (GFOM), or conjugate
3+
% gradient, for solving the L-smooth (possibly mu-strongly)
4+
% convex minimization problem
5+
% min_x F(x); for notational convenience we denote xs=argmin_x F(x).
6+
%
7+
% We show how to compute the worst-case value of F(xN)-F(xs) when xN is
8+
% obtained by doing N steps of the gradient method starting with an initial
9+
% iterate satisfying ||x0-xs||<=1.
10+
11+
12+
% (0) Initialize an empty PEP
13+
P=pep();
14+
15+
% (1) Set up the objective function
16+
param.L=1; % Smoothness parameter
17+
param.mu=0.0; % Strong convexity parameter
18+
19+
% F is the objective function
20+
F=P.DeclareFunction('SmoothStronglyConvex',param);
21+
22+
% (2) Set up the starting point and initial condition
23+
x0=P.StartingPoint(); % x0 is some starting point
24+
[xs,fs]=F.OptimalPoint(); % xs is an optimal point, and fs=F(xs)
25+
P.InitialCondition((x0-xs)^2<=1); % Add an initial condition ||x0-xs||^2<= 1
26+
27+
% (3) Algorithm
28+
N=5; % number of iterations
29+
30+
x=cell(N+1,1);%we store all the x's in a cell (for convenience)
31+
g=cell(N+1,1);%we store all the g's in a cell (for convenience)
32+
x{1}=x0;
33+
g{1}=F.gradient(x{1});
34+
dirs{1}=g{1};
35+
for i=1:N
36+
[x{i+1}, g{i+1}] = exactlinesearch_step(x{i},F,dirs);
37+
dirs{2+(i-1)*2} = x{i+1} - x{1};
38+
dirs{3+(i-1)*2} = g{i+1};
39+
end
40+
41+
% (4) Set up the performance measure
42+
fN=F.value(x{N+1}); % g=grad F(x), f=F(x)
43+
P.PerformanceMetric(fN-fs); % Worst-case evaluated as F(x)-F(xs)
44+
45+
% (5) Solve the PEP
46+
P.solve()
47+
48+
% (6) Evaluate the output
49+
double(fN-fs) % worst-case objective function accuracy
50+
% The results are the same as those for the optimized gradient method.

Examples/DouglasRachfordSplitting.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
P=pep();
2525

2626
% (1) Set up the objective function
27-
paramf1.mu=.1; % Strong convexity parameter
28-
paramf1.L=1; % Smoothness parameter
29-
f1=P.DeclareFunction('SmoothStronglyConvex',paramf1);
30-
f2=P.DeclareFunction('Convex');
31-
F=f1+f2; % F is the objective function
27+
paramf1.mu = .1; % Strong convexity parameter
28+
paramf1.L = 1; % Smoothness parameter
29+
f1 = P.DeclareFunction('SmoothStronglyConvex',paramf1);
30+
f2 = P.DeclareFunction('Convex');
31+
F = f1+f2; % F is the objective function
3232

3333
% (2) Set up the starting point and initial condition
3434
w0=P.StartingPoint(); % x0 is some starting point
@@ -41,22 +41,22 @@
4141
% the next step evaluates the oracle at the tagged point 'opt' (xs) for
4242
% recovering the values of g1s and g2s; this allows to guarantee that
4343
% g1s+g2s=0;
44-
[g1s,~]=f1.oracle('opt');
45-
[g2s,~]=f2.oracle('opt');
46-
lambda=2; ws=xs+lambda*g2s;
44+
[g1s,~] = f1.oracle('opt');
45+
[g2s,~] = f2.oracle('opt');
46+
lambda = 2; ws = xs+lambda*g2s;
4747

4848
% Add an initial condition ||w0-ws||^2<= 1
4949
P.InitialCondition((w0-ws)^2-1<=0);
5050

5151
% (3) Algorithm
52-
N=5; % number of iterations
53-
gam=lambda; % step size
52+
N = 5; % number of iterations
53+
gam = lambda; % step size
5454

55-
w=w0;
55+
w = w0;
5656
for i=1:N
57-
x=proximal_step(w,f2,gam);
58-
y=proximal_step(2*x-w,f1,gam);
59-
w=y-x+w;
57+
x = proximal_step(w,f2,gam);
58+
y = proximal_step(2*x-w,f1,gam);
59+
w = y-x+w;
6060
end
6161

6262
% (4) Set up the performance measure
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
clear all; clc;
2+
% In this example, we use a Douglas-Rachford splitting (DRS)
3+
% method for solving a monotone inclusion problem
4+
% find x st 0 \in Ax + Bx
5+
% where A is L-Lipschitz and monotone and B is (maximally) mu-strongly
6+
% monotone. We denote by JA and JB the respective resolvents of A and B.
7+
%
8+
% One iteration of the algorithm starting from point w is as follows:
9+
% x = JB( w )
10+
% y = JA( 2 * x - w )
11+
% z = w - theta * ( x - y )
12+
% and then we choose as the next iterate the value of z.
13+
%
14+
% Given two initial points w0 and w1, we show how to compute the worst-case
15+
% contraction factor ||z0 - z1||/||w0 - w1|| obtained after doing one
16+
% iteration of DRS from respectively w0 and w1.
17+
% Note that we allow the user to choose a stepsize alpha in the resolvent.
18+
%
19+
% This setting is studied in
20+
% (**) Ernest K. Ryu, Adrien B. Taylor, C. Bergeling, and P. Giselsson.
21+
% "Operator Splitting Performance Estimation: Tight contraction
22+
% factors and optimal parameter selection." arXiv:1812.00146, 2018.
23+
%
24+
% (0) Initialize an empty PEP
25+
P=pep();
26+
27+
% (1) Set up the class of monotone inclusions
28+
paramA.L = 1; paramA.mu = 0; % A is 1-Lipschitz and 0-strongly monotone
29+
paramB.mu = .1; % B is .1-strongly monotone
30+
31+
A = P.DeclareFunction('LipschitzStronglyMonotone',paramA);
32+
B = P.DeclareFunction('StronglyMonotone',paramB);
33+
34+
% (2) Set up the starting points
35+
w0=P.StartingPoint();
36+
w1=P.StartingPoint();
37+
P.InitialCondition((w0-w1)^2<=1); % Normalize the initial distance ||w0-ws||^2 <= 1
38+
39+
% (3) Algorithm
40+
alpha = 1.3; % step size (in the resolvents)
41+
theta = .9; % overrelaxation
42+
43+
x0 = proximal_step(w0,B,alpha);
44+
y0 = proximal_step(2*x0-w0,A,alpha);
45+
z0 = w0-theta*(x0-y0);
46+
47+
x1 = proximal_step(w1,B,alpha);
48+
y1 = proximal_step(2*x1-w1,A,alpha);
49+
z1 = w1-theta*(x1-y1);
50+
51+
% (4) Set up the performance measure: ||z0-z1||^2
52+
P.PerformanceMetric((z0-z1)^2);
53+
54+
% (5) Solve the PEP
55+
P.solve()
56+
57+
% (6) Evaluate the output
58+
double((z0-z1)^2) % worst-case contraction factor
59+
60+
% Results to be compared with WC below (from (**)):
61+
L = alpha*paramA.L; mu = alpha*paramB.mu;
62+
C = sqrt(((2*(theta-1)*mu+theta-2)^2+L^2*(theta-2*(mu+1))^2)/(L^2+1));
63+
if theta*(theta+C)/(mu+1)^2/C * (C+mu*((2*(theta-1)*mu+theta-2)-L^2*...
64+
(theta-2*(mu+1)))/(L^2+1)) >=0
65+
WC = ((theta+C)/2/(mu+1))^2;
66+
elseif L<=1 && mu >= (L^2+1)/(L-1)^2 && theta<=-(2*(mu+1)*(L+1)*(mu+...
67+
(mu-1)*L^2-2*mu*L-1))/(mu+L*(L^2+L+1)+2*mu^2*(L-1)+mu*L*(1-(L-3)*L)+1)
68+
WC = (1-theta*(L+mu)/(L+1)/(mu+1))^2;
69+
else
70+
WC = (2-theta)/4/mu/(L^2+1) * ...
71+
(theta*(1-2*mu+L^2)-2*mu*(L^2-1))*...
72+
(theta*(1+2*mu+L^2)-2*(mu+1)*(L^2+1))/...
73+
(theta*(1+2*mu-L^2)-2*(mu+1)*(1-L^2));
74+
end
75+
WC

Examples/GradientExactLineSearch.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
P.InitialCondition(f0-fs<=1); % Add an initial condition f0-fs<= 1
3737

3838
% (3) Algorithm
39-
N=2;
40-
x=x0;
41-
for i=1:N
42-
[g,~]=F.oracle(x);
43-
x=exactlinesearch_step(x,F,g);
39+
N = 2;
40+
x = x0;
41+
for i = 1:N
42+
g = F.gradient(x);
43+
x = exactlinesearch_step(x,F,g);
4444
end
4545

4646
% (4) Set up the performance measure

Examples/HalpernIteration.m

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
clear all; clc;
2+
% In this example, we use the Halpern iteration for finding a fixed point
3+
% to the non-expansive operator A :
4+
% find x such that x = Ax
5+
%
6+
% (**) Lieder, Felix. "On the Convergence Rate of the Halpern-Iteration."
7+
% (2017)
8+
9+
10+
% (0) Initialize an empty PEP
11+
P=pep();
12+
13+
% (1) Set up the objective function
14+
paramA.L=1; % A is 1-Lipschitz (non-expansive)
15+
A = P.DeclareFunction('Lipschitz',paramA);
16+
17+
% (2) Set up the starting point and initial condition
18+
x0 = P.StartingPoint(); % x0 is some starting point
19+
xs = fixedpoint(A);
20+
P.InitialCondition((x0-xs)^2<=1); % Add an initial condition ||x0-xs||^2<= 1
21+
22+
% (3) Algorithm
23+
N = 10;
24+
lambda = @(k)(1/(k+2));
25+
x=x0;
26+
for i=1:N
27+
x = lambda(i-1) * x0 + (1-lambda(i-1)) * A.evaluate(x);
28+
end
29+
xN = x;
30+
AxN = A.evaluate(xN);
31+
% (4) Set up the performance measure
32+
P.PerformanceMetric((xN-AxN)^2); % Worst-case squared residual
33+
34+
% (5) Solve the PEP
35+
P.solve()
36+
37+
% (6) Evaluate the output
38+
double((xN-AxN)^2) % worst-case squared residual
39+
40+
% The result should be (2/(N+1))^2 as in (**)

Examples/KrasnoselskiiMann.m

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
clear all; clc;
2+
% In this example, we use Krasnoselskii-Mann iterations for finding a
3+
% fixed point to the non-expansive operator A :
4+
% find x such that x = Ax
5+
%
6+
% This scheme was first studied using PEPs in:
7+
% (**) Felix Lieder. "Projection Based Methods for Conic Linear Programming
8+
% Optimal First Order Complexities and Norm Constrained Quasi Newton
9+
% Methods." PhD thesis (2018)
10+
11+
12+
% (0) Initialize an empty PEP
13+
P=pep();
14+
15+
% (1) Set up the objective function
16+
paramA.L=1; % A is 1-Lipschitz (non-expansive)
17+
A = P.DeclareFunction('Lipschitz',paramA);
18+
19+
% (2) Set up the starting point and initial condition
20+
x0 = P.StartingPoint(); % x0 is some starting point
21+
xs = fixedpoint(A);
22+
P.InitialCondition((x0-xs)^2<=1); % Add an initial condition ||x0-xs||^2<= 1
23+
24+
% (3) Algorithm
25+
N = 10;
26+
lambda = @(k)(1/(k+2));
27+
x=x0;
28+
for i=1:N
29+
x = lambda(i-1) * x + (1-lambda(i-1)) * A.evaluate(x);
30+
end
31+
xN = x;
32+
AxN = A.evaluate(xN);
33+
% (4) Set up the performance measure
34+
P.PerformanceMetric((xN-AxN)^2); % Worst-case squared residual
35+
36+
% (5) Solve the PEP
37+
P.solve()
38+
39+
% (6) Evaluate the output
40+
double((xN-AxN)^2) % worst-case squared residual
41+

Examples/OptimizedGradientMethod.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
% min_x F(x); for notational convenience we denote xs=argmin_x F(x).
55
%
66
% We show how to compute the worst-case value of F(xN)-F(xs) when xN is
7-
% obtained by doing N steps of the gradient method starting with an initial
8-
% iterate satisfying ||x0-xs||<=1.
7+
% obtained by doing N steps of OGM starting with an initial iterate
8+
% satisfying ||x0-xs||<=1.
99
%
1010
% Note that OGM is developped in the following two works:
11-
%(1)Drori, Yoel, and Marc Teboulle.
12-
% "Performance of first-order methods for smooth convex minimization:
13-
% a novel approach." Mathematical Programming 145.1-2 (2014): 451-482.
11+
%(1) Drori, Yoel, and Marc Teboulle.
12+
% "Performance of first-order methods for smooth convex minimization:
13+
% a novel approach." Mathematical Programming 145.1-2 (2014): 451-482.
1414
%
15-
%(2)Kim, Donghwan, and Jeffrey A. Fessler.
16-
% "Optimized first-order methods for smooth convex minimization."
17-
% Mathematical programming 159.1-2 (2016): 81-107.
15+
%(2) Kim, Donghwan, and Jeffrey A. Fessler.
16+
% "Optimized first-order methods for smooth convex minimization."
17+
% Mathematical programming 159.1-2 (2016): 81-107.
1818

1919

2020
% (0) Initialize an empty PEP
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
clear all; clc;
2+
% In this example, we use the optimized gradient method for gradient norm
3+
% (OGM-G) for solving the L-smooth convex minimization problem
4+
% min_x F(x); for notational convenience we denote xs=argmin_x F(x).
5+
%
6+
% We show how to compute the worst-case value of ||F'(xN)||^2 when xN is
7+
% obtained by doing N steps of OGM-G starting with an initial
8+
% iterate satisfying F(x0)-F(x*)<=1.
9+
%
10+
% Note that OGMG is developped in the following work:
11+
% (1) Kim, D., & Fessler, J. A. (2018). "Optimizing the Efficiency of
12+
% First-order Methods for Decreasing the Gradient of Smooth
13+
% Convex Functions." preprint arXiv:1803.06600.
14+
%
15+
16+
17+
% (0) Initialize an empty PEP
18+
P=pep();
19+
L = 1;
20+
% (1) Set up the objective function
21+
param.L=L; % Smoothness parameter
22+
23+
F=P.DeclareFunction('SmoothStronglyConvex',param); % F is the objective function
24+
25+
% (2) Set up the starting point and initial condition
26+
x0=P.StartingPoint(); % x0 is some starting point
27+
[xs,fs]=F.OptimalPoint(); % xs is an optimal point, and fs=F(xs)
28+
[g0,f0]=F.oracle(x0);
29+
P.InitialCondition(f0-fs<=1); % Add an initial condition F(x0)-F(x*)<=1.
30+
31+
% (3) Algorithm
32+
gam=1/param.L; % step size
33+
N=5; % number of iterations
34+
35+
x=cell(N+1,1);%we store all the x's in a cell (for convenience)
36+
x{1}=x0;
37+
g{1}=g0;
38+
y{1}=x0;
39+
theta(1)=1;
40+
for i=1:N
41+
if i<N
42+
theta(i+1)=(1+sqrt(4*theta(i)^2+1))/2;
43+
else
44+
theta(i+1)=(1+sqrt(4*theta(i)^2+1))/2;
45+
end
46+
end
47+
th_ti = @(i)theta(N+1-i);
48+
49+
for i = 1:N
50+
y{i+1} = x{i} - 1/L * g{i};
51+
cc = (2*th_ti(i)-1)/(2*th_ti(i-1)-1);
52+
x{i+1} = y{i+1} + (th_ti(i-1)-1)/th_ti(i-1)*cc*(y{i+1}-y{i}) + cc * (y{i+1}-x{i});
53+
g{i+1} = F.gradient(x{i+1});
54+
end
55+
56+
% (4) Set up the performance measure
57+
% gN=F.gradient(x{N+1}); % g=grad F(x), f=F(x)
58+
obj = (g{N+1})^2;
59+
P.PerformanceMetric(obj); % Worst-case evaluated as F(x)-F(xs)
60+
61+
% (5) Solve the PEP
62+
P.solve();
63+
64+
% (6) Evaluate the output
65+
double(obj) % worst-case objective function accuracy
66+
67+
% The result should be 2/theta(end)^2
68+
% see: Kim, D., & Fessler, J. A. (2018). "Optimizing the Efficiency of
69+
% First-order Methods for Decreasing the Gradient of Smooth
70+
% Convex Functions." preprint arXiv:1803.06600.

0 commit comments

Comments
 (0)