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.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.2604111420.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.2604111420-cp313-cp313-win_amd64.whl (293.9 kB view details)

Uploaded CPython 3.13Windows x86-64

admm-1.0.2604111420-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.2604111420-cp313-cp313-macosx_11_0_arm64.whl (308.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

admm-1.0.2604111420-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.2604111420-cp312-cp312-macosx_11_0_arm64.whl (310.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

admm-1.0.2604111420-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.2604111420-cp311-cp311-macosx_11_0_arm64.whl (319.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

admm-1.0.2604111420-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.2604111420-cp310-cp310-macosx_11_0_arm64.whl (324.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: admm-1.0.2604111420.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.2604111420.tar.gz
Algorithm Hash digest
SHA256 801ea65cc9d6b09667673205640b882bf6e6b89ec6f55c192aa47033fe04add3
MD5 59ebc75f738711bbea0980c820c919ae
BLAKE2b-256 e4d45001ebda834aec221d278a50cdd3b84e5a58a5423d59a888af141e08a93b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 823931ba1a5064573d5a7c662dd431edbaa58ed2b62b6b4ae9eb9004a1953388
MD5 9717c7198e490f336fe0a36c9420c7a4
BLAKE2b-256 1db5ed021594a0c92006b6deaf0a6eb7a9e4d02c2d25765fbc885a224f9f8b4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9200c143954010da0b59f341ff6ea8a943bef6f82c0dd3e4bf360d5741047e39
MD5 6c60eb2e3a1417f0512c4129f442f275
BLAKE2b-256 e7766de3bc78e6152d814160ba2fcaddd595daba84f4fd6813b8433367431a1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9c3891db60b8ce0b401a6206b71ccf05c319e3bb1475b7490ba459753966330
MD5 85717501b632de1c828bdd88e1bc48c8
BLAKE2b-256 cc5d316cb1a01b6204934f5f651e9b5c80512b4a1cc8d865b2980dc3b1c82e0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 892f4648616297a0e8ddbcd07080eda490c1b78137e9d800a1ca56c4bd182931
MD5 cbc0a58ae9a9b8a67209b24f5eb49fa8
BLAKE2b-256 7c509154d56a40ca83fa2c7758da0cdfe3ebba0eeea450097ecea95c9b08e5bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 866945dc2626c32d94aa5154bd59bea13268fc2fa319101135146f78931a8782
MD5 0228bc908931cfe0751d73fa880ca3fa
BLAKE2b-256 8c260f51dd9b7234f98532a5cf1f81b086dbc1f45d2be178a9ac86834674fae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d69bcd052a28371b939e0cb7ababdd6611a9a0dc2ba9dd7b2192a49e6c1d6473
MD5 821ddbfe97f5f7b3220bbb1dfa50f5aa
BLAKE2b-256 a0e34427d61cd244efbf08279b7029cf903eda4b2a014f6c126ec7ef82571137

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 98260fc152a7eb1e472ca52eb04ce055746f8d03e20f8a2eaacec68b6309e70e
MD5 92075b7056c2d4be9069b12292054b43
BLAKE2b-256 d68f7d58f4bb135fe1ee63439abb48320f3af8a50190e1bd1677b629b66fcb4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef2499a33e07488865eb4644d5d657e98ef6363d7e20feeb8e3d4b763f4b8885
MD5 08c1724cfa92ebf1aa3c4de364871a14
BLAKE2b-256 303ac0ee4a9dedeafc949a7dfa53c275c2c925ef4ade9be71085d0a90d7c0de5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df385ede5d0a757e343ea473a31346829b6fc62527002fbd01b35379c14dba62
MD5 603c4624674fcaa171f2467e9d34cf09
BLAKE2b-256 68967ac78fe259cd66f138ea0903442dfc7ae4d3954fb1921da57b86722b1470

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8daa770e130f7df9c9f0d8898cf7801159039cc9354be3a37a1174eef99c6fa4
MD5 6442e780f069f7967d0683191892f8e0
BLAKE2b-256 310e04dd57f89f819d7693506fdf199dfb242296c2a9cc878f5f66633479d68c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22691411f1e6b5a00b5eba57e67548b8020a99dcbb71d882c2c64f86aa8c3a41
MD5 18658536a72cd1750388c17384916c65
BLAKE2b-256 df5a15ab737c71832dfe4027150414ac7edbaae9b15d83ae3f4cc84482a66fc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604111420-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a175c8d8b220c0b4e38370ae0270123b12939fe216a5a6c76853dd0ed49ba8f
MD5 a6da3fb0b67c4447f56989a8f1bf08c9
BLAKE2b-256 a8bd27be7d16d723921ec6e272ed550f4436c4fec99cb5f9970c8e9f64e7dd3d

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