Cova Solver
A Rust library providing optimization solvers for convex problems, built on top of Clarabel.
Features
- ADMM (Alternating Direction Method of Multipliers): Uses Clarabel to solve convex subproblems
- LASSO Regression: Sparse regression with L1 regularization
- Basis Pursuit: Sparse recovery for underdetermined systems
- Custom ADMM Problems: Flexible framework for defining custom optimization problems
Quick Start
Add this to your Cargo.toml:
[]
= { = "." }
= { = "../cova-algebra" }
Usage
LASSO Regression
Solve sparse regression problems with L1 regularization:
use ;
use AdmmSolver;
// Problem: minimize ||Ax - b||² + λ||x||₁
let a = from_row_slice;
let b = from_vec;
let lambda = 0.1; // Regularization parameter
let mut solver = new;
let solution = solver.solve_lasso?;
println!;
println!;
Basis Pursuit
Solve sparse recovery problems:
use ;
use AdmmSolver;
// Problem: minimize ||x||₁ subject to Ax = b
let a = from_row_slice;
let b = from_vec;
let mut solver = new;
let solution = solver.solve_basis_pursuit?;
// The solution should be sparse and satisfy Ax = b
Custom ADMM Problems
Define custom optimization problems using the general ADMM framework:
use ;
use ;
// Example: Box-constrained quadratic programming
// minimize (1/2)||x - x₀||² subject to x ∈ [0,1]ⁿ
let n = 3;
let x0 = from_vec; // Target outside [0,1]³
// Set up ADMM formulation
let p = identity;
let q = -&x0;
let a_constraint = identity;
let b_constraint = -identity;
let c = zeros;
// Define the z-update (projection onto [0,1]ⁿ)
let z_update = ;
let mut solver = new;
let solution = solver.solve_qp_admm?;
ADMM Algorithm
The ADMM solver decomposes problems of the form:
minimize f(x) + g(z)
subject to Ax + Bz = c
into three iterative steps:
- x-update: Minimize f(x) + (ρ/2)||Ax + Bz - c + u||² (solved using Clarabel)
- z-update: Apply proximal operator of g(z) (problem-specific, user-defined)
- u-update: Update dual variable u := u + ρ(Ax + Bz - c)
Configuration
Customize ADMM parameters:
use ;
let params = AdmmParams ;
let solver = with_params;
Examples
Run the examples to see the solver in action:
This will demonstrate:
- LASSO regression with different regularization parameters
- Basis pursuit for sparse recovery
- Custom box-constrained optimization
How it Works
The library combines two powerful tools:
- Clarabel: A modern conic optimization solver in pure Rust for solving the convex subproblems
- ADMM: A versatile algorithm that can handle a wide variety of convex optimization problems
Key benefits:
- Pure Rust: No C/C++/Fortran dependencies
- Flexible: Easy to define custom optimization problems
- Efficient: Leverages Clarabel's high-performance interior-point methods
- Robust: Well-tested algorithm with proven convergence properties
Limitations
- Currently focused on convex optimization problems
- The x-update subproblems must be efficiently solvable by Clarabel (quadratic programming)
- For very large-scale problems, specialized solvers might be more efficient
Dependencies
clarabel: Pure Rust conic optimization solvercova-algebra: Linear algebra operationsthiserror: Error handling
License
AGPL-3.0