-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The cuOpt python API errors when building an expression starting with <op>x, where x is a Variable and <op> is a unary operator such as + or -.
Steps/Code to reproduce bug
from cuopt.linear_programming.problem import Problem, CONTINUOUS, MINIMIZE
from cuopt.linear_programming.solver_settings import SolverSettings
problem = Problem("lp")
x = problem.addVariable(lb=0.0, vtype=CONTINUOUS, name="x")
y = problem.addVariable(lb=0.0, vtype=CONTINUOUS, name="y")
# The following commands will error with message
# bad operand type for unary -: 'Variable'
# More generally, any expression that starts with `-x` or `+x` will error
-x
+x
problem.addConstraint( x >= 0) # OK
problem.addConstraint(+x >= 0) # not OK
problem.addConstraint(-x <= 0) # not OK
problem.addConstraint(-x + y <= 1) # not OK
problem.addConstraint( y - x <= 1) # ... but this is OK
# Adding explicit coeffs works
problem.addConstraint(-1 * x + y <= 1)
problem.setObjective(-x, sense=MINIMIZE) # also errors within objectiveExpected behavior
I expect that -x or +x would return a LinearExpression object
Environment details (please complete the following information):
- Environment location: DGX Spark with GB10 GPU and CUDA 13
- Method of cuOpt install: python virtual environment with
uv, then install viapipas in official instructions.
Additional context
While the error materializes in calls to addConstraint and setObjective, the root cause appears to be in the underlying expression construction/manipulation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working