Consider the following puzzle:
A cell is either marked or unmarked. Numbers along the right and bottom side of the puzzle denote the total sum for a certain row or column. Cells contribute (if marked) to the sum in its row and column: a cell in position (i,j)
contributes i
to the column sum and j
to the row sum. For example, in the first row in the picture above, the 1st, 2nd and 5th cell are marked. These contribute 1 + 2 + 5
to the row sum (thus totalling 8), and 1 each to their column sum.
I've written a solver in ECLiPSe CLP. It works perfectly, but it exhibits very strange behaviour for different value/variable choice methods and I have no idea why. (Note: each field in the puzzle is a decision variable with domain [0,1], 1 if marked, 0 otherwise. Constraints are obvious.)
If I use input_order (see search/6), first_fail, occurences or max_constrained, puzzles solve almost instantly with little memory usage. If I use anti_first_fail, largest or smallest, puzzles may take several minutes to complete and may eat up to 16GB ram. Why? Why do most constraints remain active for so long for these methods?
Why is there a difference between e.g. smallest and first_fail? If the domain consists of only 2 elements, and all variables have the same domain, then first_fail, anti_first_fail, largest, smallest and most_constrained should be equivalent, no? Removal of one value in the domain will attach a single value to that variable, so no more propagation is required. So search in this case will always deal with variables whose domain consists of exactly 2 items. No?