[BUG] Python: Problem.addConstraint accepts the same Constraint twice
维护者通常 1 天内回复
评估
调研方向
从 Python 的 Problem.addConstraint 方法开始,它应当拒绝已经存在于 Problem.constrs 中的 Constraint 对象,因为原生求解器只接收 CSR 矩阵。使用 issue 中的代码片段复现,然后检查第二次添加是否抛出 ValueError,并且 p.constrs 和 c.index 保持不变。#2224 对应的 Java 修复 #2226 可作为预期行为的参考。
由索引模型根据 Issue 内容生成。
描述
In the Python API, Problem.addConstraint accepts the same Constraint object twice. The second call overwrites constr.index and appends the constraint to Problem.constrs again, so the problem has two rows for one Constraint, and both rows map to the second index.
from cuopt.linear_programming.problem import Problem
p = Problem("dup")
x = p.addVariable(lb=0, ub=1, name="x")
c = x <= 1
p.addConstraint(c)
p.addConstraint(c) # accepted; c.index becomes 1 and p.constrs holds c twice
Expected: ValueError, with p.constrs and c.index left unchanged.
Same bug as the Java one in #2224 (fixed in #2226). The check belongs in Problem.addConstraint, because the native solver only receives a CSR matrix.
🤖 Generated with Claude Code
- 主要语言
- Cuda
- 星标
- 1.1k
- 派生
- 266
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 54
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/cuopt 的其他 Issue
-
[BUG] cuDSS 1.0 rejects libcudss_mtlayer_cuopt.so (status = 3): missing cudssThreadingGetProperty未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
维护者通常 1 天内回复
-
[BUG] Fully presolved MILP returns FeasibleFound with an infinite bound since 26.10.0可能已有人在做 @j3soon 于 7 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 15/100
维护者通常 1 天内回复
相似的 Issue
-
enhancement good first issue shields parity
难度 2/5 1-3 小时 新手友好度 88/100
seuthootDev/terminal-shields#125 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
bug:unconfirmed
难度 2/5 1-3 小时 新手友好度 76/100
Heroic-Games-Launcher/HeroicGamesLauncher#6187 ·
维护者通常 1 天内回复
-
task
难度 2/5 1-3 小时 新手友好度 78/100
freelawproject/litigant-portal#1285 ·
维护者通常 2 天内回复