diff --git a/skills/cuopt-numerical-optimization-api-c/SKILL.md b/skills/cuopt-numerical-optimization-api-c/SKILL.md index b25acc14ba..9362936b88 100644 --- a/skills/cuopt-numerical-optimization-api-c/SKILL.md +++ b/skills/cuopt-numerical-optimization-api-c/SKILL.md @@ -35,6 +35,10 @@ QP uses the same library, include/lib paths, and build pattern as LP/MILP — on - **Continuous variables only** — set `CUOPT_CONTINUOUS` for every variable; integer QP is not supported. - **Q should be PSD** for a convex problem. +## Dual values (LP / QP) + +`cuOptGetDualSolution` and `cuOptGetReducedCosts` return duals and reduced costs for **LP and QP**. They are not returned for a problem with quadratic constraints (the arrays are filled with `NaN`), so read them only when all constraints are linear. See [assets/lp_duals](assets/lp_duals/) for the call sequence. + ## Debugging (MPS / C) **MPS parsing:** Required sections in order: NAME, ROWS, COLUMNS, RHS, (optional) BOUNDS, ENDATA. Integer markers: `'MARKER'`, `'INTORG'`, `'INTEND'`. diff --git a/skills/cuopt-numerical-optimization-api-python/SKILL.md b/skills/cuopt-numerical-optimization-api-python/SKILL.md index a7460c7c7c..87d3d247f9 100644 --- a/skills/cuopt-numerical-optimization-api-python/SKILL.md +++ b/skills/cuopt-numerical-optimization-api-python/SKILL.md @@ -253,13 +253,14 @@ settings.set_parameter("log_to_console", 1) | QP rejected with MAXIMIZE | QP only supports MINIMIZE | Negate the objective: minimize `-f(x)` | | QP returns non-optimal | Q not PSD or variables badly scaled | Check Q is PSD; rescale variables to similar magnitudes | -## Getting Dual Values (LP only) +## Getting Dual Values (LP / QP) + +Duals and reduced costs are returned for **LP and QP**. They are not returned for a problem with quadratic constraints (every value comes back as `NaN`), so read them only when all constraints are linear. MILP returns no duals. ```python if problem.Status.name == "Optimal": - constraint = problem.getConstraint("resource_a") - shadow_price = constraint.DualValue - print(f"Shadow price: {shadow_price}") + constraint = problem.getConstraint("resource_a") # linear constraint + print(f"Dual value: {constraint.DualValue}") # NaN if the model has quadratic constraints ``` ## Reference Models