% % Power set in Minizinc. % % Creates a power set of 1..n. % % % Model created by Hakan Kjellerstrand, hakank@bonetmail.com % See also my MiniZinc page: http://www.hakank.org/minizinc % include "globals.mzn"; % % p should be pow(2,n) but the integer version of pow don't work in % MiniZinc version 0.7.1 . % predicate powerset(int: n, array[int] of var set of int: x) = let { int: p = ceil(pow(2.0, int2float(n))), % p = 2^n array[1..p] of var set of 1..n: z } in all_different(z) /\ x = z ; solve satisfy; int: n = 3; int: size = ceil(pow(2.0, int2float(n))); % 2^n; array[1..8] of var set of 1..8: a; % This gives a power set of 1..n constraint powerset(n, a) % symmetry breaking: order the sets % /\ increasing(a) % don't work in minizinc/flatzinc 0.7.1 ; output [ show(a) ];