cuopt-numerical-optimization-api-c
Original:🇺🇸 English
Translated
LP, MILP, and QP (beta) with cuOpt — C API only. Use when the user is embedding LP, MILP, or QP in C/C++.
6installs
Sourcenvidia/skills
Added on
NPX Install
npx skill4agent add nvidia/skills cuopt-numerical-optimization-api-cTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →cuOpt Numerical Optimization — C API
Solve LP, MILP, and QP problems via the cuOpt C API. The same library, headers, build pattern, and core calls (, , ) apply across all three; QP extends the API with quadratic-objective creation calls.
cuOptCreate*ProblemcuOptSolvecuOptGetObjectiveValueConfirm problem type and formulation (variables, objective, constraints, variable types) before coding.
This skill is C only.
Quick Reference: C API
c
#include <cuopt/linear_programming/cuopt_c.h>
// CSR format for constraints
cuopt_int_t row_offsets[] = {0, 2, 4};
cuopt_int_t col_indices[] = {0, 1, 0, 1};
cuopt_float_t values[] = {2.0, 3.0, 4.0, 2.0};
char var_types[] = {CUOPT_CONTINUOUS, CUOPT_INTEGER};
cuOptCreateRangedProblem(
num_constraints, num_variables, CUOPT_MINIMIZE,
0.0, objective_coefficients,
row_offsets, col_indices, values,
constraint_lower, constraint_upper,
var_lower, var_upper, var_types,
&problem
);
cuOptSolve(problem, settings, &solution);
cuOptGetObjectiveValue(solution, &obj_value);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 () for the QP-specific creation/solve calls and the repo docs at for end-to-end QP examples.
cpp/include/cuopt/linear_programming/docs/cuopt/source/cuopt-c/lp-qp-milp/QP rules:
- MINIMIZE only (). To maximize
CUOPT_MINIMIZE, negate objective coefficients and Q entries.f(x) - Continuous variables only — set for every variable; integer QP is not supported.
CUOPT_CONTINUOUS - Q should be PSD for a convex problem.
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 and product docs.
cuopt_cliEscalate
For contribution or build-from-source, use product or repo documentation.