-
Notifications
You must be signed in to change notification settings - Fork 2.4k
TypeError in CP-SAT when evaluating x - y - 2*z #4654
Copy link
Copy link
Closed
Labels
BugLang: PythonPython wrapper issuePython wrapper issueOS: LinuxGNU/Linux OSGNU/Linux OSSolver: CP-SAT SolverRelates to the CP-SAT solverRelates to the CP-SAT solver
Milestone
Description
What version of OR-Tools and what language are you using?
Version: 9.12.4544
Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT
What operating system (Linux, Windows, ...) and version?
Linux
What did you do?
Steps to reproduce the behavior:
- Run the following script
from ortools.sat.python import cp_model
model = cp_model.CpModel();
x = model.NewIntVar(0,1,"x")
y = model.NewIntVar(0,2,"y")
z = model.NewIntVar(0,3,"z")
expr = x - y - 2*z- See error
TypeError Traceback (most recent call last)
[<ipython-input-6-688283dcb9b1>](https://localhost:8080/#) in <cell line: 0>()
5 y = model.NewIntVar(0,2,"y")
6 z = model.NewIntVar(0,3,"z")
----> 7 expr = x - y - 2*z
TypeError: __rsub__(): incompatible function arguments. The following argument types are supported:
1. (self: ortools.sat.python.cp_model_helper.IntAffine, cst: int) -> ortools.sat.python.cp_model_helper.LinearExpr
2. (self: ortools.sat.python.cp_model_helper.IntAffine, cst: float) -> ortools.sat.python.cp_model_helper.LinearExpr
What did you expect to see
No error occur.
Make sure you include information that can help us debug (full error message, model Proto).
Note that the expression x - y + 2*z does not produce an error.
from ortools.sat.python import cp_model
model = cp_model.CpModel();
x = model.NewIntVar(0,1,"x")
y = model.NewIntVar(0,2,"y")
z = model.NewIntVar(0,3,"z")
expr = x - y + 2*zReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugLang: PythonPython wrapper issuePython wrapper issueOS: LinuxGNU/Linux OSGNU/Linux OSSolver: CP-SAT SolverRelates to the CP-SAT solverRelates to the CP-SAT solver