Moreau

Gemfury

High-performance batched differentiable convex optimization

Moreau is a GPU-accelerated conic optimization solver with full support for automatic differentiation. Solve thousands of convex problems in parallel and backpropagate through the solutions.


Frameworks

NumPy

Just solve. Standard NumPy/SciPy interface for straightforward optimization without framework overhead.

Core API
PyTorch

Full autograd support with differentiable optimization. Embed optimization in your neural networks.

PyTorch API
JAX

Compatible with jax.grad, jax.vmap, and jax.jit. Functional API for composable transformations.

JAX API
CVXPY

Use Moreau as a CVXPY solver backend, or combine with cvxpylayers for differentiable convex optimization.

CVXPY Integration

Get Started in 30 Seconds

import moreau
import numpy as np
from scipy import sparse

# Define a simple QP
P = sparse.diags([1.0, 1.0], format='csr')
q = np.array([2.0, 1.0])
A = sparse.csr_matrix([
    [1.0, 1.0], [1.0, 0.0], [0.0, 1.0]
])
b = np.array([1.0, 0.7, 0.7])
cones = moreau.Cones(
    num_zero_cones=1, num_nonneg_cones=2
)

# Solve
solver = moreau.Solver(P, q, A, b, cones=cones)
solution = solver.solve()
print(f"x = {solution.x}")
print(f"status = {solver.info.status}")

Install

Setup access, then:

pip install moreau

What’s happening?

  1. Define a convex conic problem

  2. Create a solver with problem data

  3. Solve and get the optimal solution

  4. Access solver metadata via solver.info

Quickstart Guide


Why Moreau?

GPU Accelerated

Native CUDA implementation keeps everything on GPU. Zero host-device transfers during solving for maximum throughput.

Batched Solving

Solve thousands of problems in parallel with shared structure. The CompiledSolver API is optimized for high-throughput workloads.

Differentiable

Full gradient support via implicit differentiation. Backpropagate through optimization layers in PyTorch and JAX.

Production Ready

Double precision numerics, robust convergence, and comprehensive error handling for reliable production deployment.


Used For

Control

MPC, trajectory optimization

Finance

Portfolio optimization

ML

Constrained learning

Robotics

Motion planning

Browse Examples


Problem Formulation

Moreau solves convex conic programs of the form:

minimize    (1/2)x'Px + q'x
subject to  Ax + s = b
            s in K

Where K is a product of cones:

  • Zero cone: Equality constraints

  • Nonnegative cone: Inequality constraints

  • Second-order cone: Norm constraints (dim 3)

  • Exponential cone: Log/exp constraints

  • Power cone: Power function constraints