Uses a PyTorch-implemented restarted PDHG algorithm with enhancements to solve primal-dual linear programs.
Project description
torchPDLP
torchPDLP is a PyTorch-based solver for linear programs, using a restarted PDHG algorithm with enhancements for stability and performance.
Features
- Efficient primal-dual LP solving with PyTorch acceleration
- Directory and single-file solving modes
- Outputs results and solver status in accessible formats
- Enhanced algorithmic stability and speed
Installation
Install from PyPI:
pip install torchPDLP
Or install directly from GitHub:
pip install git+https://github.com/SimplySnap/torchPDLP.git@pypi-package#subdirectory=torchPDLP
Usage
1. Solving a Directory of Problems from Command Line
You can use the provided command-line script to solve all MPS files in a directory and output a summary CSV file:
torchPDLP \
--device gpu \
--instance_path /path/to/mps/files \
--tolerance 1e-4 \
--output_path /path/to/save/results \
--precondition \
--fishnet \
--primal_weight_update \
--adaptive_stepsize \
--max_kkt 100000
Argument Reference:
| Argument | Description |
|---|---|
--device |
'cpu', 'gpu', or 'auto'. Uses GPU if available as default. |
--instance_path |
Path to folder with .mps files. |
--tolerance |
Convergence tolerance (default: 1e-4). |
--output_path |
Folder to save outputs and Excel results. |
--precondition |
Enable Ruiz preconditioning (optional). |
--primal_weight_update |
Enable primal weight updates (optional). |
--adaptive_stepsize |
Enable adaptive step sizes (optional). |
--fishnet |
Enable fishnet casting (optional). |
--verbose |
Enable verbose logging (optional). |
--support_sparse |
Use sparse matrices if supported (optional). |
--max_kkt |
Maximum number of KKT passes (default: None). |
2. Solving a Single Problem in Python
To solve a single MPS problem file and retrieve the solution, objective value, and solver status:
import torchPDLP
result = torchPDLP.solve("path/to/file.mps")
torchPDLP.solve has all the same optional arguments as the command line function. Result is a dictionary with keys:
| Key | Description |
|---|---|
optimal_point |
The optimal solution found by the solver (PyTorch tensor). |
objective_value |
The value of the objective function at the optimal point (float). |
status |
Solver status, either "solved" or "unsolved" (string). |
time |
Total time taken to solve the problem (in seconds, float). |
iterations |
Number of main algorithm iterations performed (integer). |
restarts |
Number of times the PDHG algorithm was restarted (integer). |
kkt_passes |
Number of KKT passes performed during solving (integer). |
Authors
- Xiyan Hu, Colgate University
- Titus Parker, Stanford University
- Connor Phillips, James Madison University
- Yifa Yu, University of California, Davis
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torchpdlp-0.1.2.tar.gz.
File metadata
- Download URL: torchpdlp-0.1.2.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
388373c2072faf06f4d4d9b442a3a8ef3aa304e5989f0908ff483b381f9560fb
|
|
| MD5 |
81d0b24790045fa97621d327cc80a30c
|
|
| BLAKE2b-256 |
f66127a86e48bc7e8424fbb8b60e16d8dd9745e2ebd36146d6fbfd3702db4b23
|
File details
Details for the file torchpdlp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: torchpdlp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 33.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4092040dcde1e2fe3bfe9463751cb3d2e6ec00c4aba36e4632b1f439fa132d2
|
|
| MD5 |
1c88bb5c378d4c0482fc9aff74af213b
|
|
| BLAKE2b-256 |
b0bbae8f7dfdefdbe1b90c70993e18b2f8bb96f161d04c3cc3734e67aa28f6c5
|