How ethanswang/mlxpdlp works
mlxPDLP is a C++ linear-programming solver implementing PDHG on MLX CPU or Metal, with C++ and Python interfaces, MPS ingestion, optional presolve, and shared-matrix batch solving. The principal workflow supplies a CSR LP (or loads an MPS model), prepares and solves it, then returns solution and termination diagnostics. The README documents capabilities beyond the sampled excerpts; links for those subsystems are included only where their paths and roles are supported.
Main entry points: solver.cpp PDHG solver · __init__.py Python API · batch_solver.cpp Shared matrix plan · batch_bindings.h Batch bindings
Components 20
User interfaces
- Python API
python/mlxpdlp/__init__.py - Native bindings
python/src/module.cpp - Solver API
include/mlxPDLP/solver.h - Batch API
include/mlxPDLP/batch_solver.h
LP ingestion
- MPS loader API
include/mlxPDLP/mps_loader.h - MPS loading
src/mps_loader.c - MPS parsing
src/mps_parser.c
Solve engine
- Presolve adapter
src/presolve_adapter.cpp - Matrix preparation
src/shared_matrix.cpp - PDHG solver
src/solver.cpp - CPU sparse ops
src/cpu_sparse_matrix.h - Metal sparse ops
src/metal_spmv.h - FP64 correction
src/host_double_polish.cpp
Batch solving
- Shared matrix plan
src/batch_solver.cpp - Batch bindings
python/src/batch_bindings.h - Batch results
include/mlxPDLP/batch_solver.h
Other components
- C++ caller
- Python caller
- MPS model
- Solve result
include/mlxPDLP/solver.h
Connections 22
- C++ caller → Solver API: supplies CSR
- Python caller → Python API: calls
- Python API → Native bindings: delegates
- Native bindings → Solver API: constructs solver
- Python API → MPS loader API: loads MPS
- MPS model → MPS loader API: input model
- MPS loader API → MPS loading: loads
- MPS loading → MPS parsing: parses
- Solver API → PDHG solver: invokes
- PDHG solver → Presolve adapter: optionally presolves
- PDHG solver → Matrix preparation: prepares operator
- PDHG solver → CPU sparse ops: uses on CPU
- PDHG solver → Metal sparse ops: uses on Metal
- PDHG solver → FP64 correction: optionally corrects
- PDHG solver → Solve result: returns
- C++ caller → Batch API: submits batch
- Python API → Batch bindings: exposes batch
- Batch bindings → Shared matrix plan: submits
- Batch API → Shared matrix plan: executes batch
- Shared matrix plan → PDHG solver: runs members
- Shared matrix plan → Batch results: assembles
- Batch bindings → Batch results: converts results