I want to do a simple constraint over all values of a list, I want each index of each row of an array to have the following (ic) constraint:
500 #= 2^X1 + 2^X2 + 2^X3 + ... + 2^X9
I try to do the code below. Array is a 9x9 matrix and for every row I want the above constraint to be satisfied. However, this does not seem to work, the program does not find any possible values that satisfy the constraint.
model(Array) :-
Array :: 1..9,
(for(I,1,9), param(Array)
do
X1 is Array[I,1],
X2 is Array(I,2],
X3 is Array[I,3],
X4 is Array[I,4],
X5 is Array[I,5],
X6 is Array[I,6],
X7 is Array[I,7],
X8 is Array[I,8],
X9 is Array[I,9],
500 #= 2^X1 + 2^X2 + 2^X3 + 2^X4 + 2^X5 + 2x^X6 + 2^X7 + 2^X8 + 2^X9
),
term_variables(Array,L),
labeling(L),
printBoard(Array).