Python Wrapper API
Source: official HPR-QP-C documentation.
Setup
cd python
make setup
Test:
make test
Direct demo commands:
python examples/build_qabc_demo.py
python examples/solve_mps_demo.py
python examples/cvxpy_demo.py
Equivalent Makefile shortcuts:
make demo-qabc
make demo-mps
make demo-cvxpy
Public API
Types
Model: opaque model handleParameters: solver parameter objectResult: solve result with copied Python-owned listsCVXPYBuildInfo: metadata returned bybuild_from_cvxpy_problem
Model Construction
read_from_mps(path) -> Modelbuild_from_mps(path) -> ModelAlias ofread_from_mpsbuild_from_qabc(Q, c, A, AL, AU, l, u, obj_constant=0.0) -> Modelbuild_from_QAbc(...) -> ModelAlias ofbuild_from_qabc
Q and A may be dense row-major matrices or SciPy sparse matrices.
Parameters
Parameters(**kwargs)
Keyword |
Method |
Values |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Also available:
set_defaults()
Solve
optimize(model, params=None) -> Result
Field |
Meaning |
|---|---|
|
Integer solver status code |
|
String solver status |
|
Final iteration count |
|
Iteration when residual first reached |
|
Iteration when residual first reached |
|
Total solve time in seconds |
|
Time when residual first reached |
|
Time when residual first reached |
|
Final primal objective |
|
Final residual metric |
|
Final relative gap |
|
Primal variable list |
|
Constraint dual list |
|
Lower/upper bound dual helper list |
|
Auxiliary dual list |
CVXPY Integration
build_from_cvxpy_problem(problem) -> (Model, CVXPYBuildInfo)solve_cvxpy_problem(problem, params=None, assign_values=True) -> Result
Field |
Meaning |
|---|---|
|
Map from CVXPY variable id to flat solver offset |
|
Original CVXPY variable shapes |
|
Total flattened variable count |
|
Total canonical constraint count |
|
Constant objective offset |