ADMM

Struct ADMM 

Source
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:

  1. x-update: x^{k+1} = argmin_x { f(x) + (ρ/2)‖Ax + Bz^k - c + u^k‖² }
  2. z-update: z^{k+1} = argmin_z { g(z) + (ρ/2)‖Ax^{k+1} + Bz - c + u^k‖² }
  3. 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

Source

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);
Source

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);
Source

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)
Source

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
where F: Fn(&Vector<f32>, &Vector<f32>, &Vector<f32>, f32) -> Vector<f32>, G: Fn(&Vector<f32>, &Vector<f32>, &Vector<f32>, f32) -> Vector<f32>,

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§

Source§

impl Clone for ADMM

Source§

fn clone(&self) -> ADMM

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ADMM

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Optimizer for ADMM

Source§

fn step(&mut self, _params: &mut Vector<f32>, _gradients: &Vector<f32>)

Stochastic update (mini-batch mode) - for SGD, Adam, RMSprop. Read more
Source§

fn reset(&mut self)

Resets the optimizer state (momentum, history, etc.). Read more
Source§

fn minimize<F, G>( &mut self, _objective: F, _gradient: G, _x0: Vector<f32>, ) -> OptimizationResult
where F: Fn(&Vector<f32>) -> f32, G: Fn(&Vector<f32>) -> Vector<f32>,

Batch optimization (deterministic mode) - for L-BFGS, CG, Damped Newton. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V