cuOptCreateProblem fails on num_constraints=0 (zero-row problems)
维护者通常 1 天内回复
@aliceb-nv 已经在做这个了。
开始于 2026年9月29日。
评估
这个 Issue 还没有评估数据。
描述
Summary
cuOptCreateProblem fails with CUOPT_INVALID_ARGUMENT for any problem with zero linear constraints — including pure bound-constrained LPs and QCQP-style problems (quadratic constraints only, no linear rows).
Repro (Java, but this is a C API issue)
try (Problem problem = new Problem("no-constraint")) {
Variable x = problem.addVariable(0.0, 10.0, 1.0, VariableType.CONTINUOUS, "x");
problem.setObjective(x, ObjectiveSense.MINIMIZE);
try (Solution solution = problem.solve()) { // throws here
System.out.println(solution.getTerminationStatus());
}
}
Exception in thread "main" com.nvidia.cuopt.mathematicaloptimization.CuOptException: cuOptCreateProblem failed with status 1
at com.nvidia.cuopt.mathematicaloptimization.NativeCuOpt.createProblem(Native Method)
...
Same failure with any zero-linear-constraint problem, e.g. a QuadraticExpression constraint with no linear rows, or a single SEMI_CONTINUOUS variable with no addConstraint calls at all.
Root cause (traced, not fixed)
cuOptCreateProblem (cpp/src/pdlp/cuopt_c.cpp:338) has no explicit num_constraints <= 0 check itself — unlike sibling functions such as cuOptSetInitialDualSolution, which does. The failure comes from a raft::exception thrown somewhere inside problem->set_csr_constraint_matrix(...) (or a related setter) on a zero-row CSR matrix, caught and converted to CUOPT_INVALID_ARGUMENT. Not traced further than that.
Why this looks unintentional
- No explicit validation rejects it at the API boundary (contrast with the
num_constraints <= 0check present elsewhere in the same file). - Pure bound-constrained LPs and quadratic-only-constrained problems are mathematically valid; other solvers support them.
Impact
Found while writing/testing Java doc examples for #1999 — had to add an artificial non-binding linear constraint to two examples (quadratic-constraint-only, and a semi-continuous variable with no other constraints) purely to work around this.
Ask
Could someone with more context on the CSR/problem construction path confirm whether zero-row problems are meant to be supported, and if so where the fix belongs?
- 主要语言
- Cuda
- 星标
- 1.1k
- 派生
- 249
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 126
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。