decent_bench.centralized_algorithms#
- decent_bench.centralized_algorithms.gradient_descent(cost_function: CostFunction, x0: ndarray[tuple[Any, ...], dtype[float64]] | None, *, step_size: float, max_iter: int, stop_tol: float | None, max_tol: float | None) ndarray[tuple[Any, ...], dtype[float64]][source]#
Find the x that minimizes the cost function using gradient descent.
- Parameters:
cost_function – cost function to minimize
x0 – initial guess, defaults to
np.zeros()ifNoneis providedstep_size – scaling factor for each update
max_iter – maximum number of iterations to run
stop_tol – early stopping criteria - stop if
norm(x_new - x) <= stop_tolmax_tol – maximum tolerated
norm(x_new - x)at the end
- Raises:
RuntimeError – if
norm(x_new - x) > max_tolat the end- Returns:
x that minimizes the cost function.
- decent_bench.centralized_algorithms.accelerated_gradient_descent(cost_function: CostFunction, x0: ndarray[tuple[Any, ...], dtype[float64]] | None, *, max_iter: int, stop_tol: float | None, max_tol: float | None) ndarray[tuple[Any, ...], dtype[float64]][source]#
Find the x that minimizes the cost function using accelerated gradient descent.
- Parameters:
cost_function – cost function to minimize
x0 – initial guess, defaults to
np.zeros()ifNoneis providedmax_iter – maximum number of iterations to run
stop_tol – early stopping criteria - stop if
norm(x_new - x) <= stop_tolmax_tol – maximum tolerated
norm(x_new - x)at the end
- Raises:
RuntimeError – if
norm(x_new - x) > max_tolat the endValueError – if
cost_function.m_smooth < 0,cost_function.m_cvx < 0, or cost function is affine
- Returns:
x that minimizes the cost function.
- decent_bench.centralized_algorithms.proximal_solver(cost_function: CostFunction, y: ndarray[tuple[Any, ...], dtype[float64]], rho: float) ndarray[tuple[Any, ...], dtype[float64]][source]#
Find the proximal at y using accelerated gradient descent.
This is the solution to the proximal operator defined as:
\[\operatorname{prox}_{\rho f}(\mathbf{y}) = \arg\min_{\mathbf{x}} \left\{ f(\mathbf{x}) + \frac{1}{2\rho} \| \mathbf{x} - \mathbf{y} \|^2 \right\}\]where \(\rho > 0\) is the penalty and \(f\) the cost function.
- Raises:
ValueError – if cost_function’s domain and y don’t have the same shape, or if rho is not greater than 0