Python Version
This page shows how to use the Python interface of HPR-LP: run demos, build custom problems, adjust solver settings, and interpret results.
Running examples
The demo LP problem is:
Test problem (LP)
The default demo problem we ship is a small linear program of the form
After installing the environment, you can run the solver in two ways: model-based API or .mps API.
1. Model-based API
You can also build and solve a small demo script under demo/demo_model_api.py.
python demo/demo_model_api.py
2. MPS file API
python scripts/run_single_file.py
This calls run_single_file.py with its default arguments, which solve one LP model in MPS format.
You can also override any of these from the command line, for example:
python scripts/run_single_file.py \
--file_name /path/to/your_problem.mps \
--device_number 0 \
--stoptol 1e-8 \
--time_limit 3600 \
--check_iter 150 \
--warm_up True \
--use_Ruiz_scaling True \
--use_Pock_Chambolle_scaling True \
--use_bc_scaling True
Parameters
Below is a list of the parameters in HPR-LP along with their default values and usage:
Parameter |
Default Value |
Description |
|---|---|---|
|
|
Determines if a warm-up phase is performed before main execution. |
|
|
Maximum allowed runtime (seconds) for the algorithm. |
|
|
Stopping tolerance for convergence checks. |
|
|
GPU device number (only relevant if |
|
|
Maximum number of iterations allowed. |
|
|
Number of iterations to check residuals. |
|
|
Whether to apply Ruiz scaling. |
|
|
Whether to use the Pock-Chambolle scaling. |
|
|
Whether to use the scaling for b and c. |
|
|
Whether to use GPU or not. |
|
|
Print the log every |
Results
After solving an instance, you can access the result variables as shown below:
Category |
Variable |
Description |
|---|---|---|
Iteration Counts |
|
Total number of iterations performed by the algorithm. |
|
Number of iterations required to achieve an accuracy of |
|
|
Number of iterations required to achieve an accuracy of |
|
Time Metrics |
|
Total time in seconds taken by the algorithm. |
|
Time in seconds taken to achieve an accuracy of |
|
|
Time in seconds taken to achieve an accuracy of |
|
|
Time in seconds used by the power method. |
|
Objective Values |
|
The primal objective value obtained. |
|
The gap between the primal and dual objective values. |
|
Residuals |
|
Relative residuals of the primal feasibility, dual feasibility, and duality gap. |
Algorithm Status |
|
The final status of the algorithm:
|
Solution Vectors |
|
The final solution vector x. |
|
The final solution vector y. |
|
|
The final solution vector z. |