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):

pip install -r docs/requirements.txt
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}
}

Troubleshooting

ImportError after installing admm

If import admm fails after a successful pip install admm, the most likely cause is that admmlib was not installed correctly. admmlib ships the native C library that admm depends on at runtime, and is normally installed automatically as a dependency.

To check whether admmlib is installed:

pip show admmlib

If it is missing, reinstall it explicitly:

pip install --force-reinstall admmlib

If the problem persists, please open an issue with the output of pip install admm -v and your platform information.

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.2604122332.tar.gz (749.4 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.2604122332-cp313-cp313-win_amd64.whl (294.4 kB view details)

Uploaded CPython 3.13Windows x86-64

admm-1.0.2604122332-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.2604122332-cp313-cp313-macosx_11_0_arm64.whl (308.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

admm-1.0.2604122332-cp312-cp312-win_amd64.whl (293.4 kB view details)

Uploaded CPython 3.12Windows x86-64

admm-1.0.2604122332-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.2604122332-cp312-cp312-macosx_11_0_arm64.whl (310.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

admm-1.0.2604122332-cp311-cp311-win_amd64.whl (317.4 kB view details)

Uploaded CPython 3.11Windows x86-64

admm-1.0.2604122332-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.2604122332-cp311-cp311-macosx_11_0_arm64.whl (319.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

admm-1.0.2604122332-cp310-cp310-win_amd64.whl (316.0 kB view details)

Uploaded CPython 3.10Windows x86-64

admm-1.0.2604122332-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.2604122332-cp310-cp310-macosx_11_0_arm64.whl (325.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: admm-1.0.2604122332.tar.gz
  • Upload date:
  • Size: 749.4 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.2604122332.tar.gz
Algorithm Hash digest
SHA256 403fc402bd242b03b9ceff66e683e92680f92ae14972d8c27f1fab39a32fd637
MD5 8f46a1e191b30aab860a164992520c98
BLAKE2b-256 28c7a641daf5356e633d1e7892c3bff1948b7564e627c3e93aff654c350269f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 12035909bf7ae7a1b6789634bbe06b7e732f9440c87c79c6883f6be7b3d6e814
MD5 9971130e80282c3f991cc125c9f0e95d
BLAKE2b-256 eea0e9a9d22f41a950595910a22c1344a53ef46b804577c88e419dac2775d279

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b99078922d2c08e8f176698d02a9a9d5366822493be8aa440cfd28e32e5af052
MD5 7622c69a5f8188c8ec5b111c56471b96
BLAKE2b-256 ca1e9aa1b174ab26da1c024e97d5b9aca0e2c5e1e0cf583ee54dde8f9e3f0d47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c75f0364f137ff8ff3ebf1d914243672b06722ed66c90481fdfb3fbd8512d955
MD5 bd24a23962665a889ff49af77e1f60e7
BLAKE2b-256 0910189f759dc7fd2c77b04ff4200ef2fc05b814241bfebc00c792906b840079

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6daea28bd17e2593050362433626413b8ac171203917448d0e183ff23bf1fcac
MD5 e2658ac5830355f17e2413ce575bdcac
BLAKE2b-256 84756e2d961562f76ce08b2212bfc46920fc30f7e8a32febdb790be5dd0376b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 60a47c0e2500d6257d9b90a8d65e437e50e29cf347c8c28f5c39e6689c14579f
MD5 1a7e67eb885036d31849bde8bbb37b9c
BLAKE2b-256 3c04b69ed5a18eca24b0e1af8b3bdac6a832c65410dcb02f231d1f4915fb0f00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6c60843a86d558d7e681f4b79e36a1da94594ed315fdcaf6edc966dad9756ff
MD5 1d6506271d14619c3f42156f84a33fd4
BLAKE2b-256 ce3edc11c64aecd5a78ee016a5d73326c20bc43eb1a3700ee0ac16114f28e582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 666a41bbac93ab5e4e85e085bb85d36c5e936892334bc15b750312606420a966
MD5 9768585db2f9de8379e0568690eb7d06
BLAKE2b-256 19c83364bd5d0031842b852d017173b2a298955527a302a753d16e25584577b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21a4c4ac159adf7e52f7ca260a1e81ca85cdc961d18b271638cc6a25585befeb
MD5 b0faec58543ea99eb0aeaa7537221d1b
BLAKE2b-256 7f256504f38d6a3a2d924254158437eb454d03fc036346d5897ab3866cfd29bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38ab3c97e644f18c03c91d1608ff71ac4a7b353a190fce9c30c2ac6946140664
MD5 fcd217c122a0d7c9851125bddd157e6a
BLAKE2b-256 32d960788186481c347c3d71e4195fc23f2be050ec07853fd210d206a01514c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5ee7042b6567c52e756266a89900b250ecba2771ae4cc0c12d5e7f8de66b9479
MD5 e99c580bb3c33d0bbaa211cc672eaa29
BLAKE2b-256 ff48b171ee4c58c33923a1aeffda17a4e54eccc73691fae9832d17fdbc32beaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0624bc210fc2e10cb3a634197aca86118ee326d58551ced15dded290bc75d45f
MD5 f8814ef24543f904cdf41934ca14a819
BLAKE2b-256 3257f1c42f02d4b252125b19d34ac792e2d06aa1a35d0ad8c80447c80569b9ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604122332-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 afba05e6749164b8f06cec721ff2920e52d5495d8cfd3bc5755f9c890dc4f249
MD5 2a6c1753a888037424f476c70e5c5f33
BLAKE2b-256 2c7d324dd7cb3f13a3fce12f1995aa4b98b419ad76b9d7f088b85761a26f972f

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