Skip to main content

ADMM - Automatic Decomposition Method by MindOpt

Project description

ADMM: Automatic Decomposition Method by MindOpt

PyPI version Documentation Status License: MIT Build and Publish

ADMM (Automatic Decomposition Method by MindOpt) is a Python library for building and solving structured optimization models. You describe objectives and constraints in a natural mathematical style, and ADMM turns that model into an efficient numerical solve through automatic canonicalization, decomposition, and a high-performance C++ backend.

The core idea is simple: model the problem, not the solver internals. ADMM is designed for formulations that combine linear or quadratic terms, smooth fitting losses, nonsmooth regularization, affine constraints, matrix structure, and custom proximal terms.

For convex models, ADMM targets the global optimum. Through user-defined proximal extensions, it also supports selected nonconvex formulations such as exact sparsity, rank constraints, and manifold-style projections, where the solver acts as a practical local method.

Features

  • Model-first optimization workflow: Write the mathematics directly and let ADMM handle canonicalization, decomposition, and solver orchestration automatically.
  • Rich structured problem support: Combine linear and quadratic objectives, smooth losses, nonsmooth regularizers, affine constraints, and matrix-valued structure such as symmetry and PSD constraints.
  • Beyond standard convex modeling: 48 ready-to-use UDF classes ship out of the box — from L0 sparsity and rank constraints to Cauchy, Welsch, and Tukey robust losses, KL divergence, logistic regression, and graph Laplacian smoothing. For any new smooth loss, supply just eval + grad and the C++ backend solves the proximal subproblem automatically.
  • Built for real applications: Use the same interface for portfolio optimization, sparse and regularized learning, covariance estimation, semidefinite modeling, compressed sensing, and signal or image processing.
  • NumPy-friendly Python API: Work naturally with scalars, vectors, and matrices in a concise Python interface instead of hand-coding low-level updates.
  • Fast backend, practical deployment: Run on a C++ backend with Python bindings across Linux, macOS, and Windows.

When to Use ADMM

ADMM is a strong fit when your model combines several structured ingredients in one formulation, such as:

  • linear or quadratic objectives
  • smooth fitting terms such as least squares, logistic regression, or Huber loss
  • nonsmooth regularization such as L1 or nuclear norm
  • affine equality or inequality constraints
  • structural constraints on variables such as nonnegativity, symmetry, or PSD
  • matrix-valued objectives such as trace, log-determinant, or Frobenius norm
  • custom proximal terms for advanced nonconvex modeling
  • custom smooth losses via gradient-based UDFs (Cauchy, log-cosh, quantile regression, etc.)

Installation

From PyPI

pip install admm

This will automatically install all dependencies including admmlib (the pre-built admm C++ core dependency library).

From Source

git clone https://github.com/alibaba-damo-academy/admm.git
cd admm
pip install . -r requirements.txt

Quick Start

The following example shows a mean-variance portfolio optimization problem:

min    -mu^T w + gamma * w^T Sigma w
s.t.   sum(w) = 1,   w >= 0

The corresponding ADMM code:

import admm
import numpy as np

n = 20
mu = np.abs(np.random.randn(n))
F = np.random.randn(n + 3, n)              # random factor matrix
Sigma = F.T @ F + 0.1 * np.eye(n)          # covariance matrix (PSD)
gamma = 0.5                                # risk-aversion parameter

model = admm.Model()
w = admm.Var("w", n)
model.setObjective(-mu.T @ w + gamma * (w.T @ Sigma @ w))
model.addConstr(admm.sum(w) == 1)
model.addConstr(w >= 0)
model.optimize()

print(f"status: {model.StatusString}")
print(f"obj:    {model.ObjVal:.6f}")

Examples

The examples/ folder contains 40 standalone scripts covering every documented use case — from basic LP/QP to UDF-based nonconvex models and gradient-based smooth losses. Each script runs independently:

python examples/portfolio_optimization.py
python examples/sparse_logistic_regression.py
python examples/udf_l0_norm.py

See examples/README.md for the full list.

User-Defined Proximal Functions

The udf/ folder ships 48 ready-to-use UDF classes — 15 proximal operators for nonconvex and convex penalties (L0, rank, manifold projections, etc.) and 33 gradient-based smooth losses covering robust M-estimators (Cauchy, Welsch, Tukey, Geman-McClure, etc.), classification losses (logistic, hinge, cross-entropy), divergences (KL, Itakura-Saito, χ²), barriers (log barrier, negative entropy), and structural penalties (smooth TV, graph Laplacian) — that go beyond standard convex modeling tools.

ADMM supports two UDF paths — supply the proximal operator (argmin) or just the gradient (grad):

# Path 1: argmin — closed-form proximal operator (nonconvex penalties, indicators)
from udf.L0Norm import L0Norm
model.setObjective(0.5 * admm.sum(admm.square(x - y)) + lam * L0Norm(x))
# Path 2: grad — gradient only (smooth custom losses)
from udf.CauchyLoss import CauchyLoss
model.setObjective(CauchyLoss(A @ x - b, c=2.0))

The grad path lets you add any differentiable custom loss without deriving a proximal formula — the C++ backend handles the proximal solve via gradient descent with backtracking line search.

See udf/README.md for the full class list, how to write your own, and how to contribute.

Documentation

Building from Source

Prerequisites

  • Python >= 3.10
  • C++ compiler (GCC, Clang, or MSVC)
  • Cython >= 0.29.0, setuptools >= 61, NumPy >= 1.20.0, SciPy >= 1.7.0
  • admmlib >= 2026.4.9 (pre-built C++ core dependency)
  • xelatex / latexmk (only needed for PDF documentation)

Supported Platforms

  • Linux: x86_64 (GCC)
  • macOS: ARM64 (Apple Silicon, Clang)
  • Windows: x86_64 (MSVC)

Build and Install

pip install . -r requirements.txt

Run Tests

pytest tests/                    # all tests
pytest tests/test_ut.py          # unit tests
pytest tests/test_admm.py        # application tests
pytest tests/test_udf.py         # user-defined function tests (argmin path)
pytest tests/test_udf_grad.py    # user-defined function tests (grad path)
pytest tests/test_doc.py         # documentation example tests

Build Documentation Locally

cd docs
bash build.sh

Open docs/_build/html/index.html in your browser. To build HTML only (without LaTeX/PDF):

cd docs
python -c "import genrst; genrst.writeRst()"
python -m sphinx -b dirhtml ./ ./_build/html

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines, including how to contribute new user-defined proximal function classes under udf/.

Citing ADMM

If you use ADMM in your research or work, please cite:

@software{admm2026,
  title  = {{ADMM}: {A}utomatic {D}ecomposition {M}ethod by {MindOpt}},
  author = {{MindOpt Team, Alibaba DAMO Academy}},
  year   = {2026},
  url    = {https://github.com/alibaba-damo-academy/admm},
  note   = {Open-source Python library for structured optimization}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

This project is maintained by the MindOpt Team at Alibaba DAMO Academy.

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

admm-1.0.2604111441.tar.gz (748.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

admm-1.0.2604111441-cp313-cp313-win_amd64.whl (294.0 kB view details)

Uploaded CPython 3.13Windows x86-64

admm-1.0.2604111441-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

admm-1.0.2604111441-cp313-cp313-macosx_11_0_arm64.whl (308.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

admm-1.0.2604111441-cp312-cp312-win_amd64.whl (293.0 kB view details)

Uploaded CPython 3.12Windows x86-64

admm-1.0.2604111441-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

admm-1.0.2604111441-cp312-cp312-macosx_11_0_arm64.whl (310.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

admm-1.0.2604111441-cp311-cp311-win_amd64.whl (317.0 kB view details)

Uploaded CPython 3.11Windows x86-64

admm-1.0.2604111441-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

admm-1.0.2604111441-cp311-cp311-macosx_11_0_arm64.whl (319.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

admm-1.0.2604111441-cp310-cp310-win_amd64.whl (315.7 kB view details)

Uploaded CPython 3.10Windows x86-64

admm-1.0.2604111441-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

admm-1.0.2604111441-cp310-cp310-macosx_11_0_arm64.whl (324.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file admm-1.0.2604111441.tar.gz.

File metadata

  • Download URL: admm-1.0.2604111441.tar.gz
  • Upload date:
  • Size: 748.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for admm-1.0.2604111441.tar.gz
Algorithm Hash digest
SHA256 931c00c23c4b28dafa6d2e45aa4f24ab87b6d6a54232045b782c7ef5a8fb9ad7
MD5 cc45ad1c9172201ca24794fa6b5420f6
BLAKE2b-256 ba42647bfdb174f5860dc97d22188296870970f40bb4182303721a9a6bdae7fc

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2767348d38c97db8dcbf5ffd2e81b29f2ee03fe7e6aea60f5007bd40b415e41a
MD5 8da7daf63c7686223808432d2f1dbccf
BLAKE2b-256 5b40878cca1aad0c174494181033f531da090623c3a9d560d353efe9b4aef2f6

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ccd813d280f7a95bfaecdb055dc6f331eb1276b9ebc91353ec6872ca1ba8e23d
MD5 45a529a392232cff7493868e5fd932f5
BLAKE2b-256 b42ab7a10a7c06250b0e16029f7ac08dbcd1b5babe33285397f3bfc992b0940d

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ca82808ad44e172386352567f26fa4dbfbe748fd47e91523a472d9f70f99bb3
MD5 8b277597eb42a202fc22dc9ca1c07ed4
BLAKE2b-256 a1c049a0959c432019a9ac21a3410390304a01c93f73f1c20cb745ac71605354

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cf10aa8d6d27795e31dc2d06f095a73f2c2d492889035318ecd72d2818d2e38b
MD5 67e18b046962bac4d23a648bcd129a0a
BLAKE2b-256 a316dcc247265ecb2dd56e146c643867b4bcfe6b361c736622d30b54870d9789

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff52682df8ee3e07d5ccf614f47998451c973ee29667f4838f0e37c4082a983b
MD5 c97d668032c0c50b45c8498707785d8e
BLAKE2b-256 786449a1266fa666e769ecb778effc39e618f048f4299d089659d63010340a34

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f374a86a11b3d658d55890c853bbc7b18818acc966c9fc830b30824692295742
MD5 b9f38476d42d88ca1e3c3e5eb442808c
BLAKE2b-256 c0ab49939850bd04d1c391eb4465950ba068790a112437b96a320226b57d8231

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e3483c4e9585cfe6cd987c9411f689747d3aefbf00527bde4e2462ed0f0966ce
MD5 b4a367afbc1c20923eb683e65c7bbfbf
BLAKE2b-256 cca66581ca8b08a78186220e4906674e04042eab920df34d28b766da73335078

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66e3106762a39b54b039fa10f466df04abeb186668c9d0706f9e147cc18f4b49
MD5 3fc1be1ea1cb78a7cd03588e44d18e79
BLAKE2b-256 72040f3230a419393ee14d5c3fa7acfe342d8a82e972bf32cd411dfc5c58cc69

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48b73348ae621e05e1d6411edfc12ebeb8104bba15b6c4bafe8fea9e2529b824
MD5 52575efded663fe93599a3cf9e1b290b
BLAKE2b-256 5d64fb6185db2fbe0a1294c0b1e34c2299fc54759151b37d2eb9fd3598b46b67

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ce3831c7310fd07c7c413b2a46dcc4cdc1f85f70793c30490f3c4d2f2f3f51b2
MD5 6e4a19a15a4bd885e2804a4ee788c3d7
BLAKE2b-256 47acc886d05d8d2fa13b0de96307056eea20e890dc02961c7f13568240be6455

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8af141a8a599ffee35fae03f7b75c13d2e6b60c343afc80d7d0543f1965207e1
MD5 801c3c72973e4bf1baa36966959b2a2b
BLAKE2b-256 34cc9ad5277ab62a621783d9b62d06d584ec55f844a1d95df130d846f641946f

See more details on using hashes here.

File details

Details for the file admm-1.0.2604111441-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604111441-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a83f632aedb009879c4ff25e02420c039dae5641b1ea7150a00776a96466370f
MD5 efc3796cdb206d19f989c204ab76acd2
BLAKE2b-256 de2278c733361bfb5fe775626d4c879677b8c0871a53e1b4793a35d0711a5bff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page