|
1 | | -using PEPit, OrderedCollections |
2 | | - |
3 | | - |
4 | | -function wc_three_operator_splitting(mu1, L1, L3, alpha, theta, n; verbose=true) |
5 | | - |
6 | | - problem = PEP() |
7 | | - |
8 | | - f1 = declare_function!(problem, SmoothStronglyConvexFunction, OrderedDict("mu" => mu1, "L" => L1); reuse_gradient=true) |
9 | | - f2 = declare_function!(problem, ConvexFunction, OrderedDict(); reuse_gradient=false) |
10 | | - f3 = declare_function!(problem, SmoothConvexFunction, OrderedDict("L" => L3); reuse_gradient=true) |
11 | | - |
12 | | - w0 = set_initial_point!(problem) |
13 | | - w0p = set_initial_point!(problem) |
14 | | - |
15 | | - set_initial_condition!(problem, (w0 - w0p)^2 <= 1) |
16 | | - |
17 | | - w = w0 |
18 | | - for _ in 1:n |
19 | | - x, _, _ = proximal_step!(w, f2, alpha) |
20 | | - |
21 | | - gx, _ = oracle!(f3, x) |
22 | | - |
23 | | - y, _, _ = proximal_step!(2 * x - w - alpha * gx, f1, alpha) |
24 | | - |
25 | | - w = w + theta * (y - x) |
26 | | - end |
27 | | - |
28 | | - wp = w0p |
29 | | - for _ in 1:n |
30 | | - xp, _, _ = proximal_step!(wp, f2, alpha) |
31 | | - |
32 | | - gxp, _ = oracle!(f3, xp) |
33 | | - |
34 | | - yp, _, _ = proximal_step!(2 * xp - wp - alpha * gxp, f1, alpha) |
35 | | - |
36 | | - wp = wp + theta * (yp - xp) |
37 | | - end |
38 | | - |
39 | | - set_performance_metric!(problem, (w - wp)^2) |
40 | | - |
41 | | - pepit_tau = solve!(problem; verbose=verbose) |
42 | | - |
43 | | - theoretical_tau = nothing |
44 | | - |
45 | | - if verbose |
46 | | - println("*** Example file: worst-case performance of the Three Operator Splitting in distance ***") |
47 | | - println("\tPEPit guarantee:\t ||w^1_n - w^0_n||^2 <= $(round(pepit_tau, digits=6)) ||w^1_0 - w^0_0||^2") |
48 | | - end |
49 | | - |
50 | | - return pepit_tau, theoretical_tau |
51 | | -end |
52 | | - |
53 | | - |
54 | | -L3 = 1.0 |
55 | | - |
56 | | -alpha = 1 / L3 |
57 | | - |
58 | | -pepit_tau, theoretical_tau = wc_three_operator_splitting(0.1, 10.0, L3, alpha, 1.0, 4; verbose=true) |
59 | | - |
60 | | - |
| 1 | +using PEPit, OrderedCollections |
| 2 | + |
| 3 | + |
| 4 | +function wc_three_operator_splitting(mu1, L1, L3, alpha, theta, n; verbose=true) |
| 5 | + |
| 6 | + problem = PEP() |
| 7 | + |
| 8 | + f1 = declare_function!(problem, SmoothStronglyConvexFunction, OrderedDict("mu" => mu1, "L" => L1); reuse_gradient=true) |
| 9 | + f2 = declare_function!(problem, ConvexFunction, OrderedDict(); reuse_gradient=false) |
| 10 | + f3 = declare_function!(problem, SmoothConvexFunction, OrderedDict("L" => L3); reuse_gradient=true) |
| 11 | + |
| 12 | + w0 = set_initial_point!(problem) |
| 13 | + w0p = set_initial_point!(problem) |
| 14 | + |
| 15 | + set_initial_condition!(problem, (w0 - w0p)^2 <= 1) |
| 16 | + |
| 17 | + w = w0 |
| 18 | + for _ in 1:n |
| 19 | + x, _, _ = proximal_step!(w, f2, alpha) |
| 20 | + |
| 21 | + gx, _ = oracle!(f3, x) |
| 22 | + |
| 23 | + y, _, _ = proximal_step!(2 * x - w - alpha * gx, f1, alpha) |
| 24 | + |
| 25 | + w = w + theta * (y - x) |
| 26 | + end |
| 27 | + |
| 28 | + wp = w0p |
| 29 | + for _ in 1:n |
| 30 | + xp, _, _ = proximal_step!(wp, f2, alpha) |
| 31 | + |
| 32 | + gxp, _ = oracle!(f3, xp) |
| 33 | + |
| 34 | + yp, _, _ = proximal_step!(2 * xp - wp - alpha * gxp, f1, alpha) |
| 35 | + |
| 36 | + wp = wp + theta * (yp - xp) |
| 37 | + end |
| 38 | + |
| 39 | + set_performance_metric!(problem, (w - wp)^2) |
| 40 | + |
| 41 | + pepit_tau = solve!(problem; verbose=verbose) |
| 42 | + |
| 43 | + theoretical_tau = nothing |
| 44 | + |
| 45 | + if verbose |
| 46 | + println("*** Example file: worst-case performance of the Three Operator Splitting in distance ***") |
| 47 | + println("\tPEPit guarantee:\t ||w^1_n - w^0_n||^2 <= $(round(pepit_tau, digits=6)) ||w^1_0 - w^0_0||^2") |
| 48 | + end |
| 49 | + |
| 50 | + return pepit_tau, theoretical_tau |
| 51 | +end |
| 52 | + |
| 53 | + |
| 54 | +L3 = 1.0 |
| 55 | + |
| 56 | +alpha = 1 / L3 |
| 57 | + |
| 58 | +pepit_tau, theoretical_tau = wc_three_operator_splitting(0.1, 10.0, L3, alpha, 1.0, 4; verbose=true) |
| 59 | + |
| 60 | + |
0 commit comments