cuopt-numerical-optimization-api-c
About cuopt-numerical-optimization-api-c
An Agent Skill for using the cuOpt C API to solve LP, MILP, and QP problems. It covers API call sequences, QP constraints, dual values, and debugging guidance, with C examples referenced in the project.
Key features
- 01LP, MILP, and QP solving via C
- 02Ordered API call sequences
- 03QP formulation constraints
- 04LP/QP dual and reduced-cost retrieval
- 05MPS parsing and troubleshooting
Use cases
- 01Implementing an LP or MILP solver call in C
- 02Solving a continuous-variable QP
- 03Retrieving LP dual values and reduced costs
- 04Diagnosing MPS parsing or performance issues
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ nvidia/ skills --skill cuopt-numerical-optimization-api-cAfter installing, type/cuopt-numerical-optimization-api-cin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
BENCHMARK.mdskill-card.mdskill.oms.sigassets/README.mdassets/lp_basic/lp_simple.cREADME.mdassets/lp_duals/lp_duals.cREADME.mdassets/lp_warmstart/README.mdassets/milp_basic/milp_simple.cREADME.mdassets/milp_production_planning/milp_production.cREADME.mdassets/mps_solver/mps_solver.cREADME.mdassets/mps_solver/data/sample.mpsevals/evals.jsonreferences/examples.mdDetails
From the project READMEcuOpt Numerical Optimization — C API
Solve LP, MILP, and QP problems via the cuOpt C API. The same library, headers, build pattern, and core calls (cuOptCreate*Problem, cuOptSolve, cuOptGetObjectiveValue) apply across all three; QP extends the API with quadratic-objective creation calls.
Confirm problem type and formulation (variables, objective, constraints, variable types) before coding.
This skill is C only.
API Call Sequence
For LP/MILP, the ordered C entry points are: cuOptCreateRangedProblem (sense CUOPT_MINIMIZE / CUOPT_MAXIMIZE, CSR constraint matrix as row_offsets / col_indices / values, var_types char array using CUOPT_CONTINUOUS / CUOPT_INTEGER macros) → cuOptSolve(problem, settings, &solution) → cuOptGetObjectiveValue(solution, &obj_value) → matching cuOptDestroy* calls. Include <cuopt/mathematical_optimization/cuopt_c.h>. Full ordered code with build instructions in references/examples.md.
QP via C API (beta)
QP uses the same library, include/lib paths, and build pattern as LP/MILP — only the problem-creation call differs (it accepts a quadratic objective). See the cuOpt C headers (cpp/include/cuopt/mathematical_optimization/) for the QP-specific creation/solve calls and the repo docs at docs/cuopt/source/cuopt-c/lp-qp-milp/ for end-to-end QP examples.
QP rules:
- MINIMIZE only (
CUOPT_MINIMIZE). To maximizef(x), negate objective coefficients and Q entries. - Continuous variables only — set
CUOPT_CONTINUOUSfor 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 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'.
OOM or slow: Check problem size (variables, constraints); use sparse matrix; set time limit and gap tolerance.
Examples
- examples.md — LP/MILP with build instructions
- assets/README.md — Build commands for all reference code below
- lp_basic — Simple LP: create problem, solve, get solution
- lp_duals — Dual values and reduced costs
- lp_warmstart — PDLP warmstart (see README)
- milp_basic — Simple MILP with integer variable
- milp_production_planning — Production planning with resource constraints
- mps_solver — Solve from MPS file via
cuOptReadProblem
For CLI (MPS files), use cuopt_cli and product docs.
Escalate
For contribution or build-from-source, use product or repo documentation.