I'm getting back into Google's OR tools and trying a (relatively) simple optimization. I'm using the CP SAT solver and I'm probably missing something elementary here. I have some variables x, y and some constant c. I'd like x to be equal to 1 if y is smaller than that c, and 0 otherwise.
from ortools.sat.python import cp_model
solver = cp_model.CpSolver()
model = cp_model.CpModel()
c = 50
x = model.NewBoolVar(name='x')
y = model.NewIntVar(name='y', lb=0, ub=2**10)
model.Add(x == (y < c))
model.Maximize(x+y)
status = solver.Solve(model)
I'm getting an error message
TypeError: bad operand type for unary -: 'BoundedLinearExpression'
It seems I'm misusing OR tools syntax for my constraint here. I'm having difficulties understanding the documentation for OR tools online, and I seem to have forgotten quite a bit more about it than I thought.