cuopt-qp-api-python
$
npx mdskill add NVIDIA/skills/cuopt-qp-api-pythonSolve quadratic minimization problems in Python using cuOpt.
- Handles portfolio optimization with squared or cross terms.
- Depends exclusively on the cuOpt Python API library.
- Negates maximization objectives to fit minimization requirements.
- Returns optimal values when status is Optimal or PrimalFeasible.
SKILL.md
.github/skills/cuopt-qp-api-pythonView on GitHub ↗
---
name: cuopt-qp-api-python
version: "26.06.00"
description: Quadratic Programming (QP) with cuOpt — Python API only (beta). Use when the user is building or solving QP in Python.
---
# cuOpt QP — Python API (beta)
Confirm the objective has squared or cross terms (QP); if purely linear, use LP/MILP. QP must be minimization.
This skill is **Python only**. **QP is beta.**
## CRITICAL: MINIMIZE only
```python
# ❌ WRONG
problem.setObjective(x*x + y*y, sense=MAXIMIZE)
# ✅ CORRECT — negate for maximization
problem.setObjective(-(x*x + y*y), sense=MINIMIZE)
```
## Portfolio Example
```python
from cuopt.linear_programming.problem import Problem, CONTINUOUS, MINIMIZE
from cuopt.linear_programming.solver_settings import SolverSettings
problem = Problem("Portfolio")
x1 = problem.addVariable(lb=0, ub=1, vtype=CONTINUOUS, name="stock_a")
x2 = problem.addVariable(lb=0, ub=1, vtype=CONTINUOUS, name="stock_b")
x3 = problem.addVariable(lb=0, ub=1, vtype=CONTINUOUS, name="stock_c")
r1, r2, r3 = 0.12, 0.08, 0.05 # expected returns (12%, 8%, 5%)
problem.setObjective(
0.04*x1*x1 + 0.02*x2*x2 + 0.01*x3*x3 + 0.02*x1*x2 + 0.01*x1*x3 + 0.016*x2*x3,
sense=MINIMIZE
)
problem.addConstraint(x1 + x2 + x3 == 1, name="budget")
problem.addConstraint(r1*x1 + r2*x2 + r3*x3 >= 0.08, name="min_return")
problem.solve(SolverSettings())
```
## Status (PascalCase)
```python
if problem.Status.name in ["Optimal", "PrimalFeasible"]:
print(problem.ObjValue)
```
## Debugging
**Diagnostic:** `print(f"Actual status: '{problem.Status.name}'")`. For numerical issues, check Q is PSD and variables are scaled.
## Examples
- [examples.md](resources/examples.md) — portfolio, least squares, maximization workaround
- **Reference models:** This skill's `assets/` — [portfolio](assets/portfolio/), [least_squares](assets/least_squares/), [maximization_workaround](assets/maximization_workaround/). See [assets/README.md](assets/README.md).
## Escalate
If the problem is linear (no squared or cross terms), use LP/MILP. For contribution or build-from-source, see the developer skill.
More from NVIDIA/skills
- accessing-mlflowQuery and browse evaluation results stored in MLflow. Use when the user wants to look up runs by invocation ID, compare metrics across models, fetch artifacts (configs, logs, results), or set up the MLflow MCP server. ALWAYS triggers on mentions of MLflow, experiment results, run comparison, invocation IDs in the context of results, or MLflow MCP setup.
- ad-add-fusion-transformation>
- ad-conf-check>
- ad-graph-dump>
- ad-model-onboard>
- ad-pipeline-failure-pr>
- add-benchmark>
- aiq-deploy|
- aiq-research|
- byobCreate custom LLM evaluation benchmarks using the BYOB decorator framework. Use when the user wants to (1) create a new benchmark from a dataset, (2) pick or write a scorer, (3) compile and run a BYOB benchmark, (4) containerize a benchmark, or (5) use LLM-as-Judge evaluation. Triggers on mentions of BYOB, custom benchmark, bring your own benchmark, scorer, or benchmark compilation.