Skip to main content

AugmentedLagrangian

Struct AugmentedLagrangian 

Source
pub struct AugmentedLagrangian { /* private fields */ }
Expand description

Augmented Lagrangian method for constrained optimization.

Solves problems with equality constraints:

minimize f(x)
subject to: h(x) = 0  (equality constraints)

§Algorithm

Augmented Lagrangian: L_ρ(x, λ) = f(x) + λᵀh(x) + ½ρ‖h(x)‖²

for k = 1, 2, ..., max_iter:
    x_k = argmin L_ρ(x, λ_k)
    λ_k+1 = λ_k + ρ h(x_k)
    if ‖h(x)‖ is small: converged
    else: increase ρ

§Key Features

  • Penalty parameter ρ: Increased adaptively for faster convergence
  • Lagrange multipliers λ: Automatically updated for equality constraints
  • Flexible subproblem solver: Uses gradient descent for inner loop
  • Convergence: Superlinear under regularity conditions

§Applications

  • Equality constraints: Linear systems, manifold optimization
  • ADMM: Alternating Direction Method of Multipliers (special case)
  • Consensus optimization: Distributed optimization, federated learning
  • PDE-constrained optimization: Physics-informed neural networks

§Example

use aprender::optim::AugmentedLagrangian;
use aprender::primitives::Vector;

// Minimize: ½(x₁-2)² + ½(x₂-3)² subject to x₁ + x₂ = 1
let objective = |x: &Vector<f32>| {
    0.5 * (x[0] - 2.0).powi(2) + 0.5 * (x[1] - 3.0).powi(2)
};

let gradient = |x: &Vector<f32>| {
    Vector::from_slice(&[x[0] - 2.0, x[1] - 3.0])
};

// Equality constraint: x₁ + x₂ - 1 = 0
let equality = |x: &Vector<f32>| Vector::from_slice(&[x[0] + x[1] - 1.0]);

let equality_jac = |_x: &Vector<f32>| {
    vec![Vector::from_slice(&[1.0, 1.0])]
};

let mut al = AugmentedLagrangian::new(100, 1e-6, 1.0);
let x0 = Vector::zeros(2);
let result = al.minimize_equality(objective, gradient, equality, equality_jac, x0);

assert!(result.constraint_violation < 1e-4);

§References

  • Nocedal & Wright (2006). “Numerical Optimization.” Chapter 17.
  • Bertsekas (1982). “Constrained Optimization and Lagrange Multiplier Methods.”

Implementations§

Source§

impl AugmentedLagrangian

Source

pub fn new(max_iter: usize, tol: f32, initial_rho: f32) -> Self

Creates a new Augmented Lagrangian optimizer.

§Arguments
  • max_iter - Maximum number of outer iterations
  • tol - Convergence tolerance for constraint violation
  • initial_rho - Initial penalty parameter (typically 1.0-10.0)
§Example
use aprender::optim::AugmentedLagrangian;

let optimizer = AugmentedLagrangian::new(100, 1e-6, 1.0);
Source

pub fn with_rho_increase(self, factor: f32) -> Self

Sets penalty increase factor.

§Arguments
  • factor - Penalty increase factor (> 1, typically 2.0-10.0)
§Example
use aprender::optim::AugmentedLagrangian;

let optimizer = AugmentedLagrangian::new(100, 1e-6, 1.0)
    .with_rho_increase(5.0);
Source

pub fn minimize_equality<F, G, H, J>( &mut self, objective: F, gradient: G, equality: H, equality_jac: J, x0: Vector<f32>, ) -> OptimizationResult
where F: Fn(&Vector<f32>) -> f32, G: Fn(&Vector<f32>) -> Vector<f32>, H: Fn(&Vector<f32>) -> Vector<f32>, J: Fn(&Vector<f32>) -> Vec<Vector<f32>>,

Minimizes objective subject to equality constraints.

Solves: minimize f(x) subject to h(x) = 0

§Arguments
  • objective - Objective function f(x)
  • gradient - Gradient ∇f(x)
  • equality - Equality constraints h(x) = 0 (returns vector)
  • equality_jac - Jacobian of equality constraints ∇h(x)
  • x0 - Initial point
§Returns

Optimization result with constraint satisfaction metrics

Trait Implementations§

Source§

impl Clone for AugmentedLagrangian

Source§

fn clone(&self) -> AugmentedLagrangian

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 AugmentedLagrangian

Source§

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

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

impl Optimizer for AugmentedLagrangian

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§

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