pub struct ADMM { /* private fields */ }Expand description
ADMM (Alternating Direction Method of Multipliers) for distributed and constrained optimization.
Solves problems of the form:
minimize f(x) + g(z)
subject to Ax + Bz = c§Applications
- Distributed Lasso: Split data across workers for large-scale regression
- Consensus optimization: Average models from different sites (federated learning)
- Constrained problems: Equality-constrained optimization via consensus
- Model parallelism: Parallelize training across devices
§Algorithm
ADMM alternates between three updates:
- x-update:
x^{k+1} = argmin_x { f(x) + (ρ/2)‖Ax + Bz^k - c + u^k‖² } - z-update:
z^{k+1} = argmin_z { g(z) + (ρ/2)‖Ax^{k+1} + Bz - c + u^k‖² } - u-update:
u^{k+1} = u^k + (Ax^{k+1} + Bz^{k+1} - c)
where u is the scaled dual variable and ρ is the penalty parameter.
§Convergence
- Rate: O(1/k) for convex f and g
- Stopping criteria: Both primal and dual residuals below tolerance
- Adaptive ρ: Automatically adjusts penalty parameter for faster convergence
§Example: Consensus Form (Lasso)
For Lasso regression with consensus constraint x = z:
use aprender::optim::ADMM;
use aprender::primitives::{Vector, Matrix};
let n = 5;
let m = 10;
// Create problem data
let A = Matrix::eye(n); // Identity for consensus
let B = Matrix::eye(n);
let c = Vector::zeros(n);
// x-minimizer: least squares update
let data_matrix = Matrix::eye(m); // Your data matrix
let observations = Vector::ones(m); // Your observations
let lambda = 0.1;
let x_minimizer = |z: &Vector<f32>, u: &Vector<f32>, _c: &Vector<f32>, rho: f32| {
// Minimize ½‖Dx - b‖² + (ρ/2)‖x - z + u‖²
// Closed form: x = (DᵀD + ρI)⁻¹(Dᵀb + ρ(z - u))
let mut rhs = Vector::zeros(n);
for i in 0..n {
rhs[i] = rho * (z[i] - u[i]);
}
rhs // Simplified for example
};
// z-minimizer: soft-thresholding (proximal operator for L1)
let z_minimizer = |ax: &Vector<f32>, u: &Vector<f32>, _c: &Vector<f32>, rho: f32| {
let mut z = Vector::zeros(n);
for i in 0..n {
let v = ax[i] + u[i];
let threshold = lambda / rho;
z[i] = if v > threshold {
v - threshold
} else if v < -threshold {
v + threshold
} else {
0.0
};
}
z
};
let mut admm = ADMM::new(100, 1.0, 1e-4).with_adaptive_rho(true);
let x0 = Vector::zeros(n);
let z0 = Vector::zeros(n);
let result = admm.minimize_consensus(
x_minimizer,
z_minimizer,
&A,
&B,
&c,
x0,
z0,
);§Reference
Boyd, S., Parikh, N., Chu, E., Peleato, B., & Eckstein, J. (2011). “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” Foundations and Trends in Machine Learning, 3(1), 1-122.
Implementations§
Source§impl ADMM
impl ADMM
Sourcepub fn new(max_iter: usize, rho: f32, tol: f32) -> Self
pub fn new(max_iter: usize, rho: f32, tol: f32) -> Self
Creates a new ADMM optimizer.
§Parameters
max_iter: Maximum number of iterations (typical: 100-1000)rho: Penalty parameter (typical: 0.1-10.0, problem-dependent)tol: Convergence tolerance for residuals (typical: 1e-4 to 1e-6)
§Returns
A new ADMM optimizer with default settings:
- Adaptive rho: disabled (use
with_adaptive_rho(true)to enable) - Rho increase factor: 2.0
- Rho decrease factor: 2.0
§Example
use aprender::optim::ADMM;
let admm = ADMM::new(100, 1.0, 1e-4);Sourcepub fn with_adaptive_rho(self, adaptive: bool) -> Self
pub fn with_adaptive_rho(self, adaptive: bool) -> Self
Enables or disables adaptive penalty parameter adjustment.
When enabled, rho is automatically adjusted based on the ratio of primal to dual residuals:
- If primal residual >> dual residual: increase rho (enforce constraints more)
- If dual residual >> primal residual: decrease rho (improve objective)
§Example
use aprender::optim::ADMM;
let admm = ADMM::new(100, 1.0, 1e-4).with_adaptive_rho(true);Sourcepub fn with_rho_factors(self, increase: f32, decrease: f32) -> Self
pub fn with_rho_factors(self, increase: f32, decrease: f32) -> Self
Sets the factors for adaptive rho adjustment.
§Parameters
increase: Factor to multiply rho when primal residual is large (default: 2.0)decrease: Factor to divide rho when dual residual is large (default: 2.0)
Sourcepub fn minimize_consensus<F, G>(
&mut self,
x_minimizer: F,
z_minimizer: G,
a: &Matrix<f32>,
b_mat: &Matrix<f32>,
c: &Vector<f32>,
x0: Vector<f32>,
z0: Vector<f32>,
) -> OptimizationResult
pub fn minimize_consensus<F, G>( &mut self, x_minimizer: F, z_minimizer: G, a: &Matrix<f32>, b_mat: &Matrix<f32>, c: &Vector<f32>, x0: Vector<f32>, z0: Vector<f32>, ) -> OptimizationResult
Minimizes a consensus-form ADMM problem.
Solves: minimize f(x) + g(z) subject to Ax + Bz = c
§Parameters
x_minimizer: Function that solves x-subproblem given (z, u, c, rho)z_minimizer: Function that solves z-subproblem given (Ax, u, c, rho)A,B,c: Constraint matrices and vector (Ax + Bz = c)x0,z0: Initial values for x and z
§Returns
OptimizationResult containing the optimal x value and convergence information.
§Minimizer Functions
The x_minimizer should solve:
argmin_x { f(x) + (ρ/2)‖Ax + Bz - c + u‖² }The z_minimizer should solve:
argmin_z { g(z) + (ρ/2)‖Ax + Bz - c + u‖² }These often have closed-form solutions or can use proximal operators.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ADMM
impl RefUnwindSafe for ADMM
impl Send for ADMM
impl Sync for ADMM
impl Unpin for ADMM
impl UnwindSafe for ADMM
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more