9. Adaptive methods
9.1. Polyak steps in distance to optimum
- PEPit.examples.adaptive_methods.wc_polyak_steps_in_distance_to_optimum(L, mu, gamma, wrapper='cvxpy', solver=None, verbose=1)[source]
Consider the minimization problem
\[f_\star \triangleq \min_x f(x),\]where \(f\) is \(L\)-smooth and \(\mu\)-strongly convex, and \(x_\star=\arg\min_x f(x)\).
This code computes a worst-case guarantee for a variant of a gradient method relying on Polyak step-sizes (PS). That is, it computes the smallest possible \(\tau(L, \mu, \gamma)\) such that the guarantee
\[\|x_{t+1} - x_\star\|^2 \leqslant \tau(L, \mu, \gamma) \|x_{t} - x_\star\|^2\]is valid, where \(x_t\) is the output of the gradient method with PS and \(\gamma\) is the effective value of the step-size of the gradient method with PS.
In short, for given values of \(L\), \(\mu\), and \(\gamma\), \(\tau(L, \mu, \gamma)\) is computed as the worst-case value of \(\|x_{t+1} - x_\star\|^2\) when \(\|x_{t} - x_\star\|^2 \leqslant 1\).
Algorithm: Gradient descent is described by
\[x_{t+1} = x_t - \gamma \nabla f(x_t),\]where \(\gamma\) is a step-size. The Polyak step-size rule under consideration here corresponds to choosing of \(\gamma\) satisfying:
\[\gamma \|\nabla f(x_t)\|^2 = 2 (f(x_t) - f_\star).\]Theoretical guarantee: The gradient method with the variant of Polyak step-sizes under consideration enjoys the tight theoretical guarantee [1, Proposition 1]:
\[\|x_{t+1} - x_\star\|^2 \leqslant \tau(L, \mu, \gamma) \|x_{t} - x_\star\|^2,\]where \(\gamma\) is the effective step-size used at iteration \(t\) and
\begin{eqnarray} \tau(L, \mu, \gamma) & = & \left\{\begin{array}{ll} \frac{(\gamma L-1)(1-\gamma \mu)}{\gamma(L+\mu)-1} & \text{if } \gamma\in[\tfrac{1}{L},\tfrac{1}{\mu}],\\ 0 & \text{otherwise.} \end{array}\right. \end{eqnarray}References:
- Parameters:
L (float) – the smoothness parameter.
mu (float) – the strong convexity parameter.
gamma (float) – the step-size.
wrapper (str) – the name of the wrapper to be used.
solver (str) – the name of the solver the wrapper should use.
verbose (int) –
level of information details to print.
-1: No verbose at all.
0: This example’s output.
1: This example’s output + PEPit information.
2: This example’s output + PEPit information + solver details.
- Returns:
pepit_tau (float) – worst-case value
theoretical_tau (float) – theoretical value
Example
>>> L = 1 >>> mu = 0.1 >>> gamma = 2 / (L + mu) >>> pepit_tau, theoretical_tau = wc_polyak_steps_in_distance_to_optimum(L=L, mu=mu, gamma=gamma, wrapper="cvxpy", solver=None, verbose=1) (PEPit) Setting up the problem: size of the Gram matrix: 4x4 (PEPit) Setting up the problem: performance measure is the minimum of 1 element(s) (PEPit) Setting up the problem: Adding initial conditions and general constraints ... (PEPit) Setting up the problem: initial conditions and general constraints (2 constraint(s) added) (PEPit) Setting up the problem: interpolation conditions for 1 function(s) Function 1 : Adding 6 scalar constraint(s) ... Function 1 : 6 scalar constraint(s) added (PEPit) Setting up the problem: additional constraints for 0 function(s) (PEPit) Compiling SDP (PEPit) Calling SDP solver (PEPit) Solver status: optimal (wrapper:cvxpy, solver: MOSEK); optimal value: 0.6694214876445734 (PEPit) Primal feasibility check: The solver found a Gram matrix that is positive semi-definite All the primal scalar constraints are verified up to an error of 1.765730096858764e-11 (PEPit) Dual feasibility check: The solver found a residual matrix that is positive semi-definite All the dual scalar values associated with inequality constraints are nonnegative (PEPit) The worst-case guarantee proof is perfectly reconstituted up to an error of 3.680247484013155e-10 (PEPit) Final upper bound (dual): 0.6694214876573649 and lower bound (primal example): 0.6694214876445734 (PEPit) Duality gap: absolute: 1.2791434578218741e-11 and relative: 1.91081923934451e-11 *** Example file: worst-case performance of Polyak steps *** PEPit guarantee: ||x_1 - x_*||^2 <= 0.669421 ||x_0 - x_*||^2 Theoretical guarantee: ||x_1 - x_*||^2 <= 0.669421 ||x_0 - x_*||^2
9.2. Polyak steps in function value
- PEPit.examples.adaptive_methods.wc_polyak_steps_in_function_value(L, mu, gamma, wrapper='cvxpy', solver=None, verbose=1)[source]
Consider the minimization problem
\[f_\star \triangleq \min_x f(x),\]where \(f\) is \(L\)-smooth and \(\mu\)-strongly convex, and \(x_\star=\arg\min_x f(x)\).
This code computes a worst-case guarantee for a variant of a gradient method relying on Polyak step-sizes. That is, it computes the smallest possible \(\tau(L, \mu, \gamma)\) such that the guarantee
\[f(x_{t+1}) - f_\star \leqslant \tau(L, \mu, \gamma) (f(x_t) - f_\star)\]is valid, where \(x_t\) is the output of the gradient method with PS and \(\gamma\) is the effective value of the step-size of the gradient method.
In short, for given values of \(L\), \(\mu\), and \(\gamma\), \(\tau(L, \mu, \gamma)\) is computed as the worst-case value of \(f(x_{t+1})-f_\star\) when \(f(x_t)-f_\star \leqslant 1\).
Algorithm: Gradient descent is described by
\[x_{t+1} = x_t - \gamma \nabla f(x_t),\]where \(\gamma\) is a step-size. The Polyak step-size rule under consideration here corresponds to choosing of \(\gamma\) satisfying:
\[\|\nabla f(x_t)\|^2 = 2 L (2 - L \gamma) (f(x_t) - f_\star).\]Theoretical guarantee: The gradient method with the variant of Polyak step-sizes under consideration enjoys the tight theoretical guarantee [1, Proposition 2]:
\[f(x_{t+1})-f_\star \leqslant \tau(L,\mu,\gamma) (f(x_{t})-f_\star),\]where \(\gamma\) is the effective step-size used at iteration \(t\) and
\begin{eqnarray} \tau(L,\mu,\gamma) & = & \left\{\begin{array}{ll} (\gamma L - 1) (L \gamma (3 - \gamma (L + \mu)) - 1) & \text{if } \gamma\in[\tfrac{1}{L},\tfrac{2L-\mu}{L^2}],\\ 0 & \text{otherwise.} \end{array}\right. \end{eqnarray}References:
- Parameters:
L (float) – the smoothness parameter.
mu (float) – the strong convexity parameter.
gamma (float) – the step-size.
wrapper (str) – the name of the wrapper to be used.
solver (str) – the name of the solver the wrapper should use.
verbose (int) –
level of information details to print.
-1: No verbose at all.
0: This example’s output.
1: This example’s output + PEPit information.
2: This example’s output + PEPit information + solver details.
- Returns:
pepit_tau (float) – worst-case value
theoretical_tau (float) – theoretical value
Example
>>> L = 1 >>> mu = 0.1 >>> gamma = 2 / (L + mu) >>> pepit_tau, theoretical_tau = wc_polyak_steps_in_function_value(L=L, mu=mu, gamma=gamma, wrapper="cvxpy", solver=None, verbose=1) (PEPit) Setting up the problem: size of the Gram matrix: 4x4 (PEPit) Setting up the problem: performance measure is the minimum of 1 element(s) (PEPit) Setting up the problem: Adding initial conditions and general constraints ... (PEPit) Setting up the problem: initial conditions and general constraints (2 constraint(s) added) (PEPit) Setting up the problem: interpolation conditions for 1 function(s) Function 1 : Adding 6 scalar constraint(s) ... Function 1 : 6 scalar constraint(s) added (PEPit) Setting up the problem: additional constraints for 0 function(s) (PEPit) Compiling SDP (PEPit) Calling SDP solver (PEPit) Solver status: optimal (wrapper:cvxpy, solver: MOSEK); optimal value: 0.6694214253294206 (PEPit) Primal feasibility check: The solver found a Gram matrix that is positive semi-definite up to an error of 2.474995615842516e-09 All the primal scalar constraints are verified up to an error of 1.1975611058367974e-09 (PEPit) Dual feasibility check: The solver found a residual matrix that is positive semi-definite All the dual scalar values associated with inequality constraints are nonnegative (PEPit) The worst-case guarantee proof is perfectly reconstituted up to an error of 6.514273074953545e-08 (PEPit) Final upper bound (dual): 0.6694214228930617 and lower bound (primal example): 0.6694214253294206 (PEPit) Duality gap: absolute: -2.4363588924103396e-09 and relative: -3.6394994247628294e-09 *** Example file: worst-case performance of Polyak steps *** PEPit guarantee: f(x_1) - f_* <= 0.669421 (f(x_0) - f_*) Theoretical guarantee: f(x_1) - f_* <= 0.669421 (f(x_0) - f_*)