I'm new in CP problems and OR-Tools in Python and I want to do the follows:
# declare variables
for i in range(I):
for k in range(K):
x[i,k]=solver.IntVar(0,N,"x %i %i " % (i,k))
#constraints
solver.Add(CustomFunction[(x[i,k])] == 1) # only consider the values of x[i,k] evaluated in CustomFunction is equal to 1
BUT I get the error at the moment of evaluate the CustomFunction:
IndexError: only integers, slices (
:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
This is right because x is a IntVar.
By the otherhand, I saw in https://developers.google.com/optimization/reference/constraint_solver/constraint_solver/Solver/ that I could add a custom constraint, but I do not know how to do it in Python.
I appreciate your help :)