Skip to main content

ADMM - Automatic Decomposition Method by MindOpt

Project description

ADMM: Automatic Decomposition Method by MindOpt

PyPI version Documentation Status License: MIT

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.9
  • 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.2604102032.tar.gz (748.8 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.2604102032-cp314-cp314-win_amd64.whl (302.2 kB view details)

Uploaded CPython 3.14Windows x86-64

admm-1.0.2604102032-cp314-cp314-manylinux_2_17_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

admm-1.0.2604102032-cp314-cp314-macosx_11_0_arm64.whl (646.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

admm-1.0.2604102032-cp313-cp313-win_amd64.whl (293.9 kB view details)

Uploaded CPython 3.13Windows x86-64

admm-1.0.2604102032-cp313-cp313-manylinux_2_17_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

admm-1.0.2604102032-cp313-cp313-macosx_11_0_arm64.whl (644.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

admm-1.0.2604102032-cp312-cp312-win_amd64.whl (292.9 kB view details)

Uploaded CPython 3.12Windows x86-64

admm-1.0.2604102032-cp312-cp312-manylinux_2_17_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

admm-1.0.2604102032-cp312-cp312-macosx_11_0_arm64.whl (648.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

admm-1.0.2604102032-cp311-cp311-manylinux_2_17_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

admm-1.0.2604102032-cp311-cp311-macosx_11_0_arm64.whl (666.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

admm-1.0.2604102032-cp310-cp310-win_amd64.whl (315.6 kB view details)

Uploaded CPython 3.10Windows x86-64

admm-1.0.2604102032-cp310-cp310-manylinux_2_17_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

admm-1.0.2604102032-cp310-cp310-macosx_11_0_arm64.whl (675.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: admm-1.0.2604102032.tar.gz
  • Upload date:
  • Size: 748.8 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.2604102032.tar.gz
Algorithm Hash digest
SHA256 32250fab4088ae0e36dae295f689600af98bf54a61c128240129eed6c4b8bad2
MD5 e6044334a7f22a03bfb5873a269e6a06
BLAKE2b-256 e02b260cf2a794112bd8fa377bc8d43f372453c46ea96c531917e6b1f255891d

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 5cc6f592cbb3023c051425c716c582d64081e735f72b0b8b5da771a23340f305
MD5 e3b24e0b09b15e3cd0fb50357be4484a
BLAKE2b-256 0c8bd8e9a43868f8d7cb9879394740ff35bba4b17c4ba22f5ebcd16b012607a2

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp314-cp314-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp314-cp314-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c79fb14b6c4dd2a114fa3088f6580385396098a689292178fd9a4b33a58faf16
MD5 db9f258d14411bf0aa0ff12cd84241ac
BLAKE2b-256 ae25e7cbf70bbffb4d2e868b98e4f54a83971ed141ebd7539b2a929161d74fbf

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2be18889879ae30630c7b4b8ef348e3f879ba70668656a8ea087005a46cf00a9
MD5 79a4ec238044a842f198a7d745695d73
BLAKE2b-256 068616a9c0c345460d641e9fe152987375775ab6a9dd00bd03d7fee70d92f99e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8daeb4a1ed4b9c5b6bd51b89e9883dbe9b5f3abd3dcf0bf31abbef5d6efd1eab
MD5 bfab7fd3dcc12f7ea878bff27a9bb0c4
BLAKE2b-256 1c8a879ba021fec259f9c00174f8d784a69c268506959beef08738cde2ad524d

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp313-cp313-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 08a1e88e75e61e5932c2af774ec356b7c73890d566eebac025a868d58f751ee3
MD5 635577abffc29d6113ee3bc649505682
BLAKE2b-256 97f18f1ff52d9b9863a8d6a42482ca9f0990574a28f8718e4cd541f0c4e4496b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00deb45f6105ecedb751e0222c5767e426ce8140992f6c3122da378f91b2bd06
MD5 a89fd52cb7569167abc4dd4ce42e53bf
BLAKE2b-256 54da067fb2d130c904a4b4691e83ca1f1fb3701f3f42e5f66c609a2ec1121c8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e90afbc74b490dd84bbf47ec1cf43298582d83dadb6fedc14d2d17b308492d17
MD5 4e80b8099ee58b1c0680d3f81bba2e36
BLAKE2b-256 84ad9f887140ec7d6694bef049a41760c4d353734635f807701603b315c827b2

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp312-cp312-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 5a6d52c109f433dad522ac2e1f3e408c259d44896cdc1596bb47826695064eec
MD5 a5ab0237f01732e59e6c990c675e3cb1
BLAKE2b-256 6637abff2c6622ab6586fd7892f1cb80443faba5f551a57867353a919c25e284

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcef4efeef120d851e9af6c69155579a165079d1ae35aff3b3cb886c81cb66c2
MD5 4d28370b222d47c542a94bf4ef06cc40
BLAKE2b-256 20643771cd25ecedd0c053c4b027c68e3c1c78a071f9fc59b5c54d0606f1100b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d268da54508a0e81a4a47a612920970f74cecc6dd464a3d9a9b76c698480ab2d
MD5 9249cc6adc92f4023c4723eb44c0fcb0
BLAKE2b-256 e0b5f0653eb3df1d4da6847012f45f2cedba5464e1c7ca4f757a8da3aac59916

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp311-cp311-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d4a3a843204da5ca99cc9516381d75fc3f6afac7f2f8ab75bc316e682f21b93f
MD5 922aedc9bc38bce1dc87543073bc619e
BLAKE2b-256 d9fb4eeca27c07dc79153bac936e943d14831f43c21e80b4e92aa218ac613cd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c5af7025f503bbdeb33d42b97162144305a89d0827cb7d8492ec6fe67510b97
MD5 68b89f83a4b2235a4665673544dca7ab
BLAKE2b-256 afbf7b9c5a93c59c878d7281ab6456aeb0e30024b0669a55d9ba71307e4f5ced

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6ae978a1addae700951aac1b19e3dfc84c139cd018da3415eba55ce974db0f84
MD5 55235fc276f0bda2a69d46ad1d59f733
BLAKE2b-256 9b89d3d6516a8b972c23c388422f262f13ae8476172dac0a2c36e16d3ef02c8f

See more details on using hashes here.

File details

Details for the file admm-1.0.2604102032-cp310-cp310-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 66513b7fee8fd03408d5d359dfe060884583cada6440cae2c7f32937615457c3
MD5 120bffcdc18b799d4a682980632b5f88
BLAKE2b-256 9031a9f1643dfacba754fd6d8e247583a2238f9926320d7b04e4df851dedaa40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604102032-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52377d61752620d16fcc4e6404f6f7e5c1fbda5d8c6d82aa2c584d3d5864989e
MD5 41c4f247d55c736fd385234276e56361
BLAKE2b-256 4f7b130f217b735be4b9fdef6d3443e50ef3d34e420d59cc5162ca74a906121b

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