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.2604112129.tar.gz (749.0 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.2604112129-cp313-cp313-win_amd64.whl (294.3 kB view details)

Uploaded CPython 3.13Windows x86-64

admm-1.0.2604112129-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.2604112129-cp313-cp313-macosx_11_0_arm64.whl (308.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

admm-1.0.2604112129-cp312-cp312-win_amd64.whl (293.2 kB view details)

Uploaded CPython 3.12Windows x86-64

admm-1.0.2604112129-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.2604112129-cp312-cp312-macosx_11_0_arm64.whl (310.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

admm-1.0.2604112129-cp311-cp311-win_amd64.whl (317.3 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

admm-1.0.2604112129-cp310-cp310-win_amd64.whl (315.9 kB view details)

Uploaded CPython 3.10Windows x86-64

admm-1.0.2604112129-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.2604112129-cp310-cp310-macosx_11_0_arm64.whl (324.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: admm-1.0.2604112129.tar.gz
  • Upload date:
  • Size: 749.0 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.2604112129.tar.gz
Algorithm Hash digest
SHA256 e7b7e3c701e6af7ccbb2db832806653f7f62f2e15fc68f5eb22af6e1ac7a5ba8
MD5 50bdaee963b5f77387c5c07fc111747e
BLAKE2b-256 eaedede7bcf454a281bb33e24c1c54c1b3b92029e5d3247649c7ddb91a14ea0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c1fdbc069583f414836cd291ce7804f389f27024aaa9964d8d1d8e37b58d0cf2
MD5 80abe1e57b7555e65b4d390774d905c0
BLAKE2b-256 cbe00b4db687f0b160a7d97a2bc78e757208002eaf23b1c8343b887aa8679856

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b54c729bfbcd1a1b24eb5066d2e965eb1091d78d36391debe39037cf145c5bd
MD5 aef4db8e2268424468af38abbf5f3a2c
BLAKE2b-256 64679533d59cca211336c6a0a204d486fd1761baaf25b23b73f67f20025b2ed5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e4f351e854283f7a06bff11a73f287f6e2cabad2ec6c88fe307feb66e4e698f2
MD5 16073bf07b8b18e06e4a4ba0a7f0d3ff
BLAKE2b-256 ef6486e0b034cd062e52bdf1654423d5e44bf25fb54c943a7c2daa95f3de343a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 78212aadbff4eaeef30176eebb61328f69858425804d0a79ca90b2af9cf19cee
MD5 fd75946410b1693eaae76cc9d82e57d7
BLAKE2b-256 656ca48ee9836d560ad47c329c50ab4ea16084919b9ef87d640606176b7e86d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a64c81ab911f5a4d11f0f14fd875d34091025b1e81fa078d5500e6d603903a13
MD5 b5eac6f91c5482b49541a7312b4604d5
BLAKE2b-256 046439161c32135f67623d0f39f0fa58abec8bed423f0687f7d94447699c31a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 64cf2a240cf5fc8e8a832f892662c306b62e619ca3c7473d850712ccc0028d64
MD5 bb2817b8044cb536f441b01e8ee4671d
BLAKE2b-256 4de7e45088ef25f707685cd6eed13c7acb3afba03748ceb78a9bed0fdf8cf391

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f2a63842efa0895b47e783f4f29219085c56cdb05748624e0b5ae47a0049d54e
MD5 fa0fe2974b46b96a4833a7c9f707b402
BLAKE2b-256 6cd94676f0502e1671a7f8597be1755e51f1e880283452dcbaf9ea61924db1b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4e03bffb0bd9221c6e25853c48abcf057f66059e9986980068cc7eea173d42f
MD5 ae86c6e9df23021bcf382a217a10e7ea
BLAKE2b-256 a01eb29d2ca824e4a0506e63940f3360ddd6022f2e4f9ccb15275faec2266545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9e010609a878c29b53a2526c93f6d20fde13dd5b2e0d598fe95c6ed10171444
MD5 5ad84a98652bcf8d33d7bf54af21266d
BLAKE2b-256 5edebfcf33a2040e1d6e85c248fb2a912a86ec1e89328e845bc21e6073a9cbfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 202ec992147ea3957856cfd33da734bc7f4a16a05a0e4e670aea1a0607e9e098
MD5 3238edcdfa860e6cf91fe678c709fd06
BLAKE2b-256 e9393c10e6cbde06274d31cfa93a14a713d0a33b42b139bc0954a5fa337385eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 17e60637dfc3a52b6e6f57b717f6440ec36756723d6492b1616e28331b668e3d
MD5 3a35fa3f0dfd8f5c98b96a921b115107
BLAKE2b-256 1f0b4256580634b5073fcb2ea384f68ffb609b2e67304336a2fc1e472b9ecef6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for admm-1.0.2604112129-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87864935d35c8ed32569a3bfaf7d77664ef17225452228425c7c2e5fdf5fc85c
MD5 0365587f19e78f0ec7fbf75d05daf6d5
BLAKE2b-256 cbb77d7aa80cec2e2640c608027c0e7831ff36c8349342ae25a545da4819cad5

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