hi,
how can I check If an IntVar has a specific value?
I want to write the code as below:
+) It seems that "model.Add(bool == (var1 == target))" raises the TypeError.
# ortools-9.6.2534
# protobuf-4.23.4
##### Example code #####
model = cp_model.CpModel()
var1 = model.NewIntVar(0, 100, 'var1')
var2 = model.NewIntVar(0, 100*100, 'var2')
target = 24
for i in range(100):
bool = model.NewBoolVar('bool')
# check var1 has a value of target
# I want to check the value of var1 like this
model.Add(bool == (var1 == target))
# if var1 has a value of target, assign var1**2 to var2
# I want to use BoolVar like this
model.AddMultiplicationEquality(var2, [var1, var1]).OnlyEnforceIf(bool)