$ $ Discrete tomography in Essence'. $ $ Problem from http://eclipse.crosscoreop.com/examples/tomo.ecl.txt $ """ $ This is a little "tomography" problem, taken from an old issue $ of Scientific American. $ $ A matrix which contains zeroes and ones gets "x-rayed" vertically and $ horizontally, giving the total number of ones in each row and column. $ The problem is to reconstruct the contents of the matrix from this $ information. Sample run: $ $ ?- go. $ 0 0 7 1 6 3 4 5 2 7 0 0 $ 0 $ 0 $ 8 * * * * * * * * $ 2 * * $ 6 * * * * * * $ 4 * * * * $ 5 * * * * * $ 3 * * * $ 7 * * * * * * * $ 0 $ 0 $ $ $ Eclipse solution by Joachim Schimpf, IC-Parc $ """ $ $ Compare with the following models: $ * Comet: http://www.hakank.org/comet/discrete_tomography.co $ * Gecode: http://www.hakank.org/gecode/discrete_tomography.cpp $ * MiniZinc: http://www.hakank.org/minizinc/tomography.mzn $ $ Model created by Hakan Kjellerstrand, hakank@bonetmail.com $ See also my Essence'/Tailor page: http://www.hakank.org/minion_tailor $ ESSENCE' 1.0 given r : int $ number of rows given c : int $ number of columns given row_sums : matrix indexed by [int(1..r)] of int(1..100) given col_sums : matrix indexed by [int(1..c)] of int(1..100) $ decision variable find x : matrix indexed by [int(1..r), int(1..c)] of bool such that $ the rows forall i : int(1..r) . ( row_sums[i] = sum j : int(1..c) . x[i,j] ), $ the columns forall j : int(1..c) . ( col_sums[j] = sum i : int(1..r) . x[i,j] )