Metadata-Version: 2.5
Name: proxax
Version: 0.3.1
Summary: Certified first-order proximal point methods for composite optimization in JAX and Optax.
Project-URL: Homepage, https://github.com/wwkong/proxax
Project-URL: Documentation, https://proxax.readthedocs.io/
Project-URL: Repository, https://github.com/wwkong/proxax
Project-URL: Issues, https://github.com/wwkong/proxax/issues
Author-email: William Kong <wwkong92@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: augmented-lagrangian,composite-optimization,jax,nonconvex-optimization,optax,optimization,proximal
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: jax>=0.4.30
Requires-Dist: optax>=0.2.2
Provides-Extra: benchmarks
Requires-Dist: matplotlib>=3.8; extra == 'benchmarks'
Provides-Extra: cuda12
Requires-Dist: jax[cuda12]>=0.4.30; extra == 'cuda12'
Provides-Extra: cuda13
Requires-Dist: jax[cuda13]>=0.5.0; extra == 'cuda13'
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: docs
Requires-Dist: myst-parser>=3.0; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=2.2; extra == 'docs'
Requires-Dist: sphinx-book-theme>=1.1; extra == 'docs'
Requires-Dist: sphinx-copybutton>=0.5; extra == 'docs'
Requires-Dist: sphinx-design>=0.6; extra == 'docs'
Requires-Dist: sphinx>=7.4; extra == 'docs'
Provides-Extra: plot
Requires-Dist: matplotlib>=3.8; extra == 'plot'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/wwkong/proxax/main/docs/_static/logo.png" alt="Proxax logo" width="180" />
</p>

# Proxax

[![CI](https://github.com/wwkong/proxax/actions/workflows/ci.yml/badge.svg)](https://github.com/wwkong/proxax/actions/workflows/ci.yml)
[![PyPI version](https://img.shields.io/pypi/v/proxax.svg)](https://pypi.org/project/proxax/)
[![Documentation Status](https://img.shields.io/readthedocs/proxax)](https://proxax.readthedocs.io/en/latest/?badge=latest)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

**Proxax** is a Python library of **certified first-order proximal, spectral,
penalty, and augmented Lagrangian solvers** for smooth, nonsmooth, and
constrained optimization in **JAX** and **Optax**.

*   **Certified stationarity:** Solvers handle both convex and $(m, M)$-weakly
    convex (nonconvex) objectives and return exact subdifferential and KKT
    certificates $(\hat{x}, \hat{p}, \hat{v})$ rather than heuristic step-size
    checks.
*   **JAX-native & scalable:** Operates directly on arbitrary JAX PyTrees
    (`jax.Array`, nested `dict`/`tuple`, or registered dataclasses), compiles
    end-to-end under `jax.jit`, vectorizes across batches via `jax.vmap`, and
    differentiates through solutions via `px.implicit_solve`.
*   **Modular & lightweight:** Clean single-facade API (`from proxax import px`),
    single-step `optax.GradientTransformation` wrappers in `px.optax_compat`,
    and only `jax` and `optax` as runtime dependencies.

[Documentation](https://proxax.readthedocs.io/en/latest/) ·
[User Guide](https://proxax.readthedocs.io/en/latest/guide/solving_problems.html) ·
[API Reference](https://proxax.readthedocs.io/en/latest/api.html) ·
[Changelog](https://github.com/wwkong/proxax/blob/main/CHANGELOG.md) ·
[Open an Issue](https://github.com/wwkong/proxax/issues)

## Installation

```bash
pip install proxax
```

Or with `uv`:

```bash
uv add proxax
```

## Quick Example

Minimize an indefinite (nonconvex) quadratic over the unit box with a linear
equality constraint:

$$\min_{x \in [0, 1]^3} \; \frac{1}{2} x^\top Q x + \langle c, x \rangle \quad \text{s.t.} \quad \sum_{i=1}^3 x_i = 1$$

```python
import jax.numpy as jnp
from proxax import px

q_mat = jnp.array([[4.0, -1.5, 0.5], [-1.5, -2.0, 0.3], [0.5, 0.3, 2.5]])
c_vec = jnp.array([-0.6, 0.2, -0.4])


def smooth_fn(x):
  return 0.5 * jnp.dot(x, q_mat @ x) + jnp.dot(c_vec, x)


problem = px.CompositeProblem(
    smooth=smooth_fn,
    proximal=px.prox.Box(lower=0.0, upper=1.0),
    constraints=px.constraints.equality(jnp.sum, rhs=1.0),
)

sol = px.solve(
    problem,
    jnp.ones(3) / 3.0,
    solver=px.solvers.IALM(opt_tol=1e-5, feas_tol=1e-5),
)
print(sol)
print("x =", sol.x)
# Solution(
#   status=CONVERGED,
#   obj=-8.090005e-01,
#   opt_res=7.039e-06,
#   feas_res=2.384e-07,
#   iters=8 (inner=423),
#   evals=(smooth=991, grad=892, prox=449),
#   x=float32[3],
#   dual=float32[],
# )
# x = [0.06000054 0.9399997  0.        ]
```

## Problem Classes

1. **Unconstrained Composite Optimization (`px.CompositeProblem`):**

   $$\min_{x \in \mathbb{R}^n} \; f(x) + h(x)$$

   where $f$ (`smooth`) is differentiable and $(m, M)$-weakly convex/smooth,
   $h$ (`proximal`) is proper, closed, convex, and proximable, and $x$ can be a
   vector in $\mathbb{R}^n$ or any JAX PyTree of arrays.

2. **Set- and Cone-Constrained Optimization (`px.CompositeProblem`):**

   $$\min_{x \in \mathbb{R}^n} \; f(x) + h(x) \quad \text{s.t.} \quad \mathcal{A}(x) \in \mathcal{C}$$

   where $\mathcal{A}: \mathbb{R}^n \to \mathbb{R}^m$ is a matrix or callable
   PyTree linear map and $\mathcal{C} \subseteq \mathbb{R}^m$ is a closed convex
   set with Euclidean projection $\Pi_{\mathcal{C}}$.

3. **Min-Max & Saddle-Point Optimization (`px.MinMaxProblem`):**

   $$\min_{x \in \mathcal{X}} \max_{y \in \mathcal{Y}} \; \Phi(x, y) + h(x) - g(y)$$

   where $\Phi(x, y)$ (`coupling`) is differentiable and $(h, g)$ (`prox_x`,
   `prox_y`) are proper, closed, convex, and proximable over arbitrary JAX
   PyTrees $(x, y)$.

4. **Matrix Spectral Composite Optimization (`px.SpectralProblem`):**

   $$\min_{X \in \mathbb{R}^{p \times q}} \; f_1(X) + (f_2^{\mathcal{V}} \circ \sigma)(X) + (h^{\mathcal{V}} \circ \sigma)(X)$$

   where $\sigma(X)$ denotes the singular values of $X$ and $(f_2^{\mathcal{V}},
   h^{\mathcal{V}})$ are absolutely symmetric functions on
   $\mathbb{R}^{\min(p, q)}$.

5. **Block-Constrained Composite Optimization (`px.BlockProblem`):**

   $$\min_{x_1, \dots, x_K} \; \sum_{i=1}^K \big(f_i(x_i) + h_i(x_i)\big) \quad \text{s.t.} \quad \sum_{i=1}^K \mathcal{A}_i(x_i) = b$$

   where each block is a `px.BlockTerm` over arbitrary JAX PyTrees coupled
   through linear maps $\mathcal{A}_i$.

## Available Solvers (`px.solvers`)

*   **Unconstrained Composite (`px.CompositeProblem`):** `APD`, `AIPP`, `ACACG`,
    `AdapFISTA`, `NCFISTA`, `AdapAPG`, `UPFAG`, `AG`, `ECG`
*   **Set / Cone-Constrained (`px.CompositeProblem` with `constraints`):**
    `IALM`, `QPAPD`, `QPAIPP`, `IAIPAL`, `SProxALM`
*   **Block-Constrained Splitting (`px.BlockProblem`):** `ADMM`, `DPADMM`,
    `PAdaptADMM`
*   **Min-Max & Saddle-Point (`px.MinMaxProblem`):** `ExtraGradient`, `PDHG`,
    `ProxPointMinMax`
*   **Matrix Spectral (`px.SpectralProblem` / `px.prox.NuclearNorm`):** `DAICG`,
    `IAICG`
*   **Optax Single-Step Transforms (`px.optax_compat`):** `proximal`, `apd`,
    `aipp`, `ialm`, `qp_apd`, `qp_aipp`

## Runnable Examples

Self-contained benchmark scripts live in
[`examples/`](https://github.com/wwkong/proxax/tree/main/examples):

*   [`examples/unconstrained.py`](https://github.com/wwkong/proxax/blob/main/examples/unconstrained.py) — univariate convex QP, nonconvex simplex QP across 7 solvers, and nonconvex `tanh` margin classification.
*   [`examples/constrained.py`](https://github.com/wwkong/proxax/blob/main/examples/constrained.py) — linearly-constrained nonconvex simplex QP across all 5 constrained solvers, MCP Sparse PCA on the $k$-Fantope, and box-constrained matrix completion.
*   [`examples/minmax.py`](https://github.com/wwkong/proxax/blob/main/examples/minmax.py) — bilinear zero-sum matrix game over simplices (`ExtraGradient`, `PDHG`) and weakly nonconvex–strongly concave minimax (`ProxPointMinMax`).
*   [`examples/block.py`](https://github.com/wwkong/proxax/blob/main/examples/block.py) — two-block Lasso consensus splitting and three-block nonconvex quadratic splitting (`ADMM`, `DPADMM`, `PAdaptADMM`).
*   [`examples/spectral_matrix_completion.py`](https://github.com/wwkong/proxax/blob/main/examples/spectral_matrix_completion.py) — nonconvex log-sum spectral matrix completion (`DAICG`, `IAICG`, `APD`) vs convex `NuclearNorm`.
*   [`examples/optax_and_vmap.py`](https://github.com/wwkong/proxax/blob/main/examples/optax_and_vmap.py) — single-step trajectory tracking with `px.optax_compat` and parallel solving via `jax.jit(jax.vmap(...))`.
*   [`examples/implicit_solve.py`](https://github.com/wwkong/proxax/blob/main/examples/implicit_solve.py) — bilevel $\ell_1$ hyperparameter tuning with `optax.adam` and primal-dual KKT sensitivity via `px.implicit_solve`.

## Citing Proxax

If Proxax was helpful for a publication, please cite this repository:

```bibtex
@software{proxax2026github,
  author = {Weiwei Kong},
  title = {{Proxax}: Certified first-order proximal point methods for composite optimization in JAX and Optax.},
  url = {https://github.com/wwkong/proxax},
  version = {0.3.1},
  year = {2026},
}
```
