You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve and standardize the cuPDLPx Python API (#100)
* Fix: prevent lp_problem/result leak on exception in solve_once
* Fix: map FEAS_POLISH_SUCCESS status code and add missing constants
* Fix: avoid mutating caller's matrix and support scipy sparse arrays
* Fix: validate param names and fix setWarmStart semantics
* Cleanup: drop dead code in optimize() and fix pytest config
* Feat: make Status an int code
* Docs: align comment/docstring style
* Fix: validate sparse matrix structure in solve_once
* Feat: expose model data as validated properties
* Fix: update warm start test
* Docs: fix stale warm start and default-bound descriptions
* Docs: clean comments
* Fix: drop test use of nonexistent InfeasibleTol param
* Test: add API-surface coverage and ignore coverage artifacts
* Feat: model setter validation
* Fix: expose documented Python API exports
* Fix: validate solver result buffers
* Feat: validate Python solver params
* Fix: prevent in-place model data mutation
* Feat: add Python param reset helper
* Fix: disable presolve in limit test
* Fix: validate core solver params
* Fix: validate core model data
* Fix: reject NaN model bounds
* Feat: return model from optimize
* Docs: update Python API docs
* Feat: extend Params mapping helpers
* Fix: accept numpy scalars and 0/1 for solver params
* Fix: guard param validation and init ordering
-**constraint_matrix** (`A`): Coefficient matrix for the constraints. Both dense (`numpy.ndarray`) and sparse (`scipy.sparse.csr_matrix`) inputs are supported. Internally stored in double precision (`float64`).
99
99
-**constraint_lower_bound** (`l`): Lower bounds for each constraint. Use `-np.inf` or `None` for no lower bound.
100
100
-**constraint_upper_bound** (`u`): Upper bounds for each constraint. Use `+np.inf` or `None` for no upper bound.
101
-
-**variable_lower_bound** (`lb`, optional): Lower bounds for the decision variables. Defaults to `0` for all variables if not provided.
101
+
-**variable_lower_bound** (`lb`, optional): Lower bounds for the decision variables. Defaults to `-np.inf` for all variables if not provided.
102
102
-**variable_upper_bound** (`ub`, optional): Upper bounds for the decision variables. Defaults to `+np.inf` for all variables if not provided.
103
103
-**objective_constant** (`c0`, optional): Constant offset in the objective function. Defaults to `0.0`.
104
104
@@ -125,7 +125,7 @@ m = Model(objective_vector=c,
125
125
126
126
### Reading from MPS Files
127
127
128
-
A `Model` can also be created directly from an MPS file (plain or gzip-compressed) with `cupdlpx.read`, similar to `gurobipy.read`:
128
+
A `Model` can also be created directly from an MPS file (plain or gzip-compressed) with `cupdlpx.read`:
129
129
130
130
```python
131
131
import cupdlpx
@@ -174,7 +174,7 @@ Below is a list of commonly used parameters, their internal keys, and descriptio
After calling `m.optimize()`, the solver stores results in a set of read-only attributes. These attributes provide access to primal/dual solutions, objective values, residuals, and runtime statistics.
201
+
After calling `m.optimize()`, the solver stores results in a set of read-only attributes. `optimize()` returns the model itself, so chained access like `m.optimize().Status` is also supported. These attributes provide access to primal/dual solutions, objective values, residuals, and runtime statistics.
199
202
200
203
### Attribute Reference
201
204
202
205
| Attribute | Type | Description |
203
206
|---|---|---|
204
-
|`Status`|str|Human-readable solver status (`"OPTIMAL"`, `"INFEASIBLE"`, `"UNBOUNDED"`, `"TIME_LIMIT"`, etc.). |
205
-
|`StatusCode`|int|Numeric status code (`OPTIMAL=1`, `INFEASIBLE=2`, `UNBOUNDED=3`, `ITERATION_LIMIT=4`, `TIME_LIMIT=5`, `UNSPECIFIED=-1`). |
207
+
|`Status`|int|Integer termination status code; compare against `cupdlpx.PDLP` constants: `OPTIMAL=0`, `PRIMAL_INFEASIBLE=1`, `DUAL_INFEASIBLE=2`, `TIME_LIMIT=3`, `ITERATION_LIMIT=4`, `INFEASIBLE_OR_UNBOUNDED=5`, `FEAS_POLISH_SUCCESS=6`, `UNSPECIFIED=-1`. |
208
+
|`StatusName`|str|Human-readable status name, e.g. `"OPTIMAL"`, `"PRIMAL_INFEASIBLE"`. |
206
209
|`ObjVal`| float | Primal objective value at termination (sign-adjusted according to `ModelSense`). |
207
210
|`DualObj`| float | Dual objective value at termination. |
208
211
|`Gap`| float | Absolute primal-dual gap. |
@@ -225,7 +228,7 @@ All solution-related information can then be queried directly from the `Model` o
If the warm-start vectors have incorrect dimensions, the solver automatically falls back to a cold start and issues a warning.
274
+
If the warm-start vectors have incorrect dimensions, `setWarmStart` raises a `ValueError`. Omitting an argument leaves that side unchanged; passing `None` clears it.
0 commit comments