Skip to content

Commit 518fe94

Browse files
committed
2 parents 6ab8c7e + 29d41a1 commit 518fe94

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Examples/InexactFastGradientMethod.m

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@
1515

1616

1717
% (0) Initialize an empty PEP
18-
P=pep();
18+
P = pep();
1919

2020
% (1) Set up the objective function
21-
param.mu=0;
22-
param.L=1; % Smoothness parameter
21+
param.mu = 0; % strong convexity parameter
22+
param.L = 1; % Smoothness parameter
2323

2424
F=P.DeclareFunction('SmoothStronglyConvex',param); % F is the objective function
2525

2626
% (2) Set up the starting point and initial condition
27-
x0=P.StartingPoint(); % x0 is some starting point
28-
[xs,fs]=F.OptimalPoint(); % xs is an optimal point, and fs=F(xs)
29-
P.InitialCondition((x0-xs)^2<=1); % Add an initial condition ||x0-xs||^2<= 1
27+
x0 = P.StartingPoint(); % x0 is some starting point
28+
[xs, fs] = F.OptimalPoint(); % xs is an optimal point, and fs=F(xs)
29+
P.InitialCondition((x0-xs)^2 <= 1); % Add an initial condition ||x0-xs||^2<= 1
3030

3131
% (3) Algorithm
32-
N=7; % number of iterations
33-
34-
x=cell(N+1,1);% we store the iterates in a cell for convenience
35-
x{1}=x0;
36-
y=x0;
37-
eps=.1;
38-
for i=1:N
39-
d = inexactsubgradient(y,F,eps);
40-
x{i+1}=y-1/param.L*d;
41-
y=x{i+1}+(i-1)/(i+2)*(x{i+1}-x{i});
32+
N = 7; % number of iterations
33+
34+
x = cell(N+1,1); % we store the iterates in a cell for convenience
35+
x{1} = x0;
36+
y = x0;
37+
eps = .1;
38+
for i = 1:N
39+
d = inexactsubgradient(y, F, eps);
40+
x{i+1} = y - 1/param.L * d;
41+
y = x{i+1} + (i-1)/(i+2) * (x{i+1} - x{i});
4242
end
4343

4444
% (4) Set up the performance measure
45-
[g,f]=F.oracle(x{N+1}); % g=grad F(x), f=F(x)
46-
P.PerformanceMetric(f-fs); % Worst-case evaluated as F(x)-F(xs)
45+
[g, f] = F.oracle(x{N+1}); % g=grad F(x), f=F(x)
46+
P.PerformanceMetric(f - fs); % Worst-case evaluated as F(x)-F(xs)
4747

4848
% (5) Solve the PEP
4949
P.solve()
5050

5151
% (6) Evaluate the output
52-
double(f-fs) % worst-case objective function accuracy
52+
double(f - fs) % worst-case objective function accuracy
5353

5454
% Result should be worse than 2/(N^2+5*N+6) (for exact fast gradient)
5555
% see Taylor, Adrien B., Julien M. Hendrickx, and François Glineur.

0 commit comments

Comments
 (0)