**What version of OR-Tools and what language are you using?**
Version: ortools==9.14.6206
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?**
Windows
**What did you do?**
Code:
from ortools.sat.python import cp_model
model = cp_model.CpModel()
# Working
print('Working')
print(sum([1 * model.NewBoolVar('a'), 2 * model.NewBoolVar('a')]) + 0 * model.NewBoolVar('a'))
# Not working
print('Not working')
print(0 * model.NewBoolVar('a') + sum([1 * model.NewBoolVar('a'), 2 * model.NewBoolVar('a')]))
Output:
Working
(a + (2 * a) + 0)
Not working
Traceback (most recent call last):
File "C:\Users\chiara.fanton\AppData\Roaming\JetBrains\PyCharm2025.1\scratches\scratch.py", line 10, in <module>
print(0 * model.NewBoolVar('a') + sum([1 * model.NewBoolVar('a'), 2 * model.NewBoolVar('a')]))
~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: __radd__(): incompatible function arguments. The following argument types are supported:
1. (self: object, cst: int) -> ortools.sat.python.cp_model_helper.LinearExpr
2. (self: object, cst: float) -> ortools.sat.python.cp_model_helper.LinearExpr
Invoked with: SumArray(a(0..1), IntAffine(expr=a(0..1), coeff=2, offset=0)), IntConstant(0)