|
| 1 | +using PEPit, OrderedCollections, Mosek, MosekTools |
| 2 | + |
| 3 | +function wc_epsilon_subgradient_method(M, n, gamma, eps, R; solver=Mosek.Optimizer, verbose=true) |
| 4 | + |
| 5 | + problem = PEP() |
| 6 | + |
| 7 | + |
| 8 | + func = declare_function!(problem, ConvexFunction, OrderedDict()) |
| 9 | + |
| 10 | + |
| 11 | + xs = stationary_point!(func) |
| 12 | + fs = value!(func, xs) |
| 13 | + |
| 14 | + |
| 15 | + x0 = set_initial_point!(problem) |
| 16 | + |
| 17 | + |
| 18 | + set_initial_condition!(problem, (x0 - xs)^2 <= R^2) |
| 19 | + |
| 20 | + |
| 21 | + x = x0 |
| 22 | + for _ in 1:n |
| 23 | + x, gx, fx, epsilon = epsilon_subgradient_step!(x, func, gamma) |
| 24 | + set_performance_metric!(problem, fx - fs) |
| 25 | + add_constraint!(problem, epsilon <= eps) |
| 26 | + add_constraint!(problem, gx^2 <= M^2) |
| 27 | + end |
| 28 | + |
| 29 | + |
| 30 | + gx, fx = oracle!(func, x) |
| 31 | + add_constraint!(problem, gx^2 <= M^2) |
| 32 | + set_performance_metric!(problem, fx - fs) |
| 33 | + |
| 34 | + |
| 35 | + pepit_tau = solve!(problem; solver=solver, verbose=verbose) |
| 36 | + |
| 37 | + |
| 38 | + theoretical_tau = (R^2 + 2 * (n + 1) * gamma * eps + (n + 1) * gamma^2 * M^2) / (2 * (n + 1) * gamma) |
| 39 | + |
| 40 | + if verbose |
| 41 | + println("*** Example file: worst-case performance of the epsilon-subgradient method ***") |
| 42 | + println("\tPEPit guarantee:\t min_(0 <= t <= n) f(x_i) - f_* <= $(round(pepit_tau, digits=6))") |
| 43 | + println("\tTheoretical guarantee:\t min_(0 <= t <= n) f(x_i) - f_* <= $(round(theoretical_tau, digits=6))") |
| 44 | + end |
| 45 | + |
| 46 | + |
| 47 | + return pepit_tau, theoretical_tau |
| 48 | +end |
| 49 | + |
| 50 | + |
| 51 | +M, n, eps, R = 2, 6, 0.1, 1 |
| 52 | +gamma = 1 / sqrt(n + 1) |
| 53 | +pepit_tau, theoretical_tau = wc_epsilon_subgradient_method(M, n, gamma, eps, R; verbose=true) |
0 commit comments