私の Minizinc プロジェクト内で、n セットの配列を生成しようとしています。t 個の異なる数字の配列
が与えられると、基数が配列 m で指定される n 個の異なるセットが生成されます。例: t = 10; n = 4; m = [3, 2, 2, 3]; セットの配列を生成したい x = [1..3, 4..5, 6..7, 8..10];
しかし、以下のコードから得られるのは x = [1..3, 4..5, {6,10}, 7..9]; です。(私の
目的はセットの中間配列を生成することだけなので、ソルブの最小化やその他のさまざまなソルブは使用したくありません。)
int: n = 4; % number of groups
array[1..n] of int: m = [3, 2, 2, 3]; % size of each group
int: t = sum(i in 1..n)(m[i]); % total members
array[1..n] of var set of 1..t: x; % the array of sets
constraint forall(i in 1..n-1)(x[i] > x[i+1]); % SORT .
constraint forall(i in 1..n)(card(x[i] ) = m[i]); % Size of each set
constraint forall(i in 1..n-1)( x[i] intersect x[i+1] = {}); %
% I can't see a way to keep the digits in order
%constraint array_intersect(x) = {}; % this didn't help
solve satisfy;
output [show(x)];