Skip to content

optimalintellect/moreau-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moreau Examples

GPU-accelerated differentiable convex optimization — a visual gallery of notebooks showcasing Moreau.

Quick Start

git clone https://github.com/moreau-opt/moreau-examples.git
cd moreau-examples
pip install jupyter numpy scipy matplotlib seaborn torch cvxpy cvxpylayers Pillow
jupyter notebook notebooks/

Moreau install: Follow the install instructions to set up Moreau for your platform before running the notebooks.

Gallery

Notebook Description Features
Portfolio Optimization Markowitz mean-variance optimization: CVXPY, moreau.Solver, batched frontier via CompiledSolver, differentiable Jacobians via moreau.torch, warm-started rolling rebalancing. CompiledSolver moreau.torch batched differentiable warm-start GPU
MPC Trajectory Control Model Predictive Control for a 2D vehicle. Closed-loop simulation with warm starting, animated GIF, 16 initial states solved in parallel. CompiledSolver batched warm-start animation
Compressed Sensing 1D sparse recovery, 2D image reconstruction via TV minimization, and learning the measurement matrix by differentiating through the reconstruction solver. CVXPY cvxpylayers differentiable LP
Schrödinger Bridges Entropy-regularized optimal transport as a Schrödinger bridge. Batched sweep of 64 mass-conservation penalties via cvxpylayers. cvxpylayers batched exp-cones animation
Swarm Motion Planning 100 agents swap positions on a circle without collisions. SCP with batched GPU solves — each round is one CompiledSolver call. CompiledSolver batched GPU QP SCP
Predict, then Optimize Shortest path routing on a 20×20 grid with learned edge costs. End-to-end training through a differentiable LP layer achieves lower regret than two-stage. cvxpylayers batched differentiable GPU PyTorch animation
Sudoku Sudoku via LP relaxation — 729 variables, exact integer solution from convex relaxation. 256 puzzles solved simultaneously. CompiledSolver batched LP GPU
Differentiable Contact Learn friction from observed motion: Coulomb friction cones (SOC3), chain of differentiable contact solves. Shows why smoothed contact (MuJoCo-style) fails where moreau.torch succeeds. moreau.torch differentiable SOC
Fair Bandwidth Allocation Alpha-fairness via power cones: sweep the fairness-throughput tradeoff, then learn optimal link capacities by differentiating through the fair allocation solver. cvxpylayers differentiable GPU power-cones animation

Feature Matrix

Notebook Interface Batched Differentiable Warm Start GPU Cones
Portfolio CompiledSolver moreau.torch zero, nonneg
MPC CompiledSolver zero, nonneg
Compressed Sensing CVXPY cvxpylayers zero, nonneg
Schrödinger Bridges cvxpylayers zero, nonneg, exp
Swarm Planning CompiledSolver zero, nonneg
Predict, then Optimize cvxpylayers zero, nonneg
Sudoku CompiledSolver zero, nonneg
Contact Friction moreau.torch SOC
Bandwidth Allocation cvxpylayers zero, nonneg, power

Project Structure

moreau-examples/
├── README.md
├── pyproject.toml
├── assets/                    # Pre-rendered thumbnails and GIFs
├── utils/
│   ├── style.py               # Shared color palette + matplotlib theme
│   ├── animation.py           # GIF/animation helpers
│   └── sparse.py              # CSR matrix construction helpers
├── notebooks/
│   ├── portfolio_optimization.ipynb
│   ├── mpc_trajectory.ipynb
│   ├── compressed_sensing.ipynb
│   ├── optimal_transport.ipynb
│   ├── swarm_planning.ipynb
│   ├── predict_then_optimize.ipynb
│   ├── sudoku.ipynb
│   ├── contact_friction.ipynb
│   └── bandwidth_allocation.ipynb
└── scripts/
    └── render_notebooks.py    # Execute all notebooks + extract thumbnails

Requirements

  • Python 3.12+
  • Moreau
  • NumPy, SciPy, Matplotlib, Seaborn, PyTorch, CVXPY, cvxpylayers, Pillow

All notebooks use float64 precision and include committed outputs — you can browse the results on GitHub without running anything.

Links

License

Apache 2.0

About

Examples highlighting applications of the Moreau solver.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors