torchPDLP


NametorchPDLP JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryUses a PyTorch-implemented restarted PDHG algorithm with enhancements to solve primal-dual linear programs.
upload_time2025-08-20 02:39:08
maintainerNone
docs_urlNone
authorXiyan Hu, Titus Parker, Connor Phillips, Yifa Yu
requires_python>=3.6
licenseMIT
keywords optimization primal-dual linear programming pdhg torch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:
```bash
pip install torchPDLP
```

Or install directly from GitHub:
```bash
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:

```bash
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:

```python
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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "torchPDLP",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "optimization, primal-dual, linear programming, PDHG, torch",
    "author": "Xiyan Hu, Titus Parker, Connor Phillips, Yifa Yu",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/f6/61/27a86e48bc7e8424fbb8b60e16d8dd9745e2ebd36146d6fbfd3702db4b23/torchpdlp-0.1.2.tar.gz",
    "platform": null,
    "description": "# torchPDLP\n\ntorchPDLP is a PyTorch-based solver for linear programs, using a restarted PDHG algorithm with enhancements for stability and performance.\n\n## Features\n\n- Efficient primal-dual LP solving with PyTorch acceleration\n- Directory and single-file solving modes\n- Outputs results and solver status in accessible formats\n- Enhanced algorithmic stability and speed\n\n## Installation\n\nInstall from PyPI:\n```bash\npip install torchPDLP\n```\n\nOr install directly from GitHub:\n```bash\npip install git+https://github.com/SimplySnap/torchPDLP.git@pypi-package#subdirectory=torchPDLP\n```\n\n## Usage\n\n### 1. Solving a Directory of Problems from Command Line\n\nYou can use the provided command-line script to solve all MPS files in a directory and output a summary CSV file:\n\n```bash\ntorchPDLP \\\n  --device gpu \\\n  --instance_path /path/to/mps/files \\\n  --tolerance 1e-4 \\\n  --output_path /path/to/save/results \\\n  --precondition \\\n  --fishnet \\\n  --primal_weight_update \\\n  --adaptive_stepsize \\\n  --max_kkt 100000\n```\n Argument Reference:\n\n| Argument                 | Description                                                                  |\n| ------------------------ | ---------------------------------------------------------------------------- |\n| `--device`               | `'cpu'`, `'gpu'`, or `'auto'`. Uses GPU if available as default.             |\n| `--instance_path`        | Path to folder with `.mps` files.                                            |\n| `--tolerance`            | Convergence tolerance (default: `1e-4`).                                     |\n| `--output_path`          | Folder to save outputs and Excel results.                                    |\n| `--precondition`         | Enable Ruiz preconditioning (optional).                                      |\n| `--primal_weight_update` | Enable primal weight updates (optional).                                     |\n| `--adaptive_stepsize`    | Enable adaptive step sizes (optional).                                       |\n| `--fishnet`              | Enable fishnet casting (optional).                                           |\n| `--verbose`              | Enable verbose logging (optional).                                           |\n| `--support_sparse`       | Use sparse matrices if supported (optional).                                 |\n| `--max_kkt`              | Maximum number of KKT passes (default: `None`).                              |\n\n### 2. Solving a Single Problem in Python\n\nTo solve a single MPS problem file and retrieve the solution, objective value, and solver status:\n\n```python\nimport torchPDLP\n\nresult = torchPDLP.solve(\"path/to/file.mps\")\n```\ntorchPDLP.solve has all the same optional arguments as the command line function.\nResult is a dictionary with keys:\n\n| Key               | Description                                                                                   |\n| ----------------- | --------------------------------------------------------------------------------------------- |\n| `optimal_point`   | The optimal solution found by the solver (PyTorch tensor).                                    |\n| `objective_value` | The value of the objective function at the optimal point (float).                             |\n| `status`          | Solver status, either `\"solved\"` or `\"unsolved\"` (string).                                    |\n| `time`            | Total time taken to solve the problem (in seconds, float).                                    |\n| `iterations`      | Number of main algorithm iterations performed (integer).                                      |\n| `restarts`        | Number of times the PDHG algorithm was restarted (integer).                                   |\n| `kkt_passes`      | Number of KKT passes performed during solving (integer).                                      |\n\n\n## Authors\n\n- Xiyan Hu, Colgate University\n- Titus Parker, Stanford University\n- Connor Phillips, James Madison University\n- Yifa Yu, University of California, Davis\n\n## License\n\nMIT License\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Uses a PyTorch-implemented restarted PDHG algorithm with enhancements to solve primal-dual linear programs.",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/SimplySnap/torchPDLP"
    },
    "split_keywords": [
        "optimization",
        " primal-dual",
        " linear programming",
        " pdhg",
        " torch"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b0bbae8f7dfdefdbe1b90c70993e18b2f8bb96f161d04c3cc3734e67aa28f6c5",
                "md5": "1c88bb5c378d4c0482fc9aff74af213b",
                "sha256": "b4092040dcde1e2fe3bfe9463751cb3d2e6ec00c4aba36e4632b1f439fa132d2"
            },
            "downloads": -1,
            "filename": "torchpdlp-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1c88bb5c378d4c0482fc9aff74af213b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 33508,
            "upload_time": "2025-08-20T02:39:07",
            "upload_time_iso_8601": "2025-08-20T02:39:07.448699Z",
            "url": "https://files.pythonhosted.org/packages/b0/bb/ae8f7dfdefdbe1b90c70993e18b2f8bb96f161d04c3cc3734e67aa28f6c5/torchpdlp-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f66127a86e48bc7e8424fbb8b60e16d8dd9745e2ebd36146d6fbfd3702db4b23",
                "md5": "81d0b24790045fa97621d327cc80a30c",
                "sha256": "388373c2072faf06f4d4d9b442a3a8ef3aa304e5989f0908ff483b381f9560fb"
            },
            "downloads": -1,
            "filename": "torchpdlp-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "81d0b24790045fa97621d327cc80a30c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 30702,
            "upload_time": "2025-08-20T02:39:08",
            "upload_time_iso_8601": "2025-08-20T02:39:08.514014Z",
            "url": "https://files.pythonhosted.org/packages/f6/61/27a86e48bc7e8424fbb8b60e16d8dd9745e2ebd36146d6fbfd3702db4b23/torchpdlp-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-20 02:39:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SimplySnap",
    "github_project": "torchPDLP",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "torchpdlp"
}
        
Elapsed time: 1.97633s