building_blocks.fzn 2.04 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
predicate all_different_int(array [int] of var int: x);
predicate count(array [int] of var int: x, var int: y, var int: c);
predicate fixed_cumulative(array [int] of var int: s, array [int] of int: d, array [int] of int: r, int: b);
predicate global_cardinality(array [int] of var int: x, array [int] of int: cover, array [int] of var int: counts);
predicate maximum_int(var int: m, array [int] of var int: x);
predicate minimum_int(var int: m, array [int] of var int: x);
predicate sliding_sum(int: low, int: up, int: seq, array [int] of var int: vs);
predicate sort(array [int] of var int: x, array [int] of var int: y);
predicate table_bool(array [int] of var bool: x, array [int, int] of bool: t);
predicate table_int(array [int] of var int: x, array [int, int] of int: t);
predicate var_cumulative(array [int] of var int: s, array [int] of int: d, array [int] of int: r, var int: b);
array [1..48] of int: words = [2, 1, 11, 5, 15, 14, 24, 23, 5, 3, 8, 15, 15, 21, 1, 12, 7, 9, 17, 4, 18, 13, 20, 7, 10, 20, 13, 16, 19, 15, 17, 14, 12, 20, 3, 11, 21, 9, 14, 24, 12, 20, 18, 8, 22, 17, 1, 16];
array [1..24] of var 1..4: dice :: output_array([1..24]);
constraint all_different_int([dice[2], dice[1], dice[11], dice[5]]);
constraint all_different_int([dice[5], dice[3], dice[8], dice[15]]);
constraint all_different_int([dice[7], dice[9], dice[17], dice[4]]);
constraint all_different_int([dice[10], dice[20], dice[13], dice[16]]);
constraint all_different_int([dice[12], dice[20], dice[3], dice[11]]);
constraint all_different_int([dice[12], dice[20], dice[18], dice[8]]);
constraint all_different_int([dice[15], dice[14], dice[24], dice[23]]);
constraint all_different_int([dice[15], dice[21], dice[1], dice[12]]);
constraint all_different_int([dice[18], dice[13], dice[20], dice[7]]);
constraint all_different_int([dice[19], dice[15], dice[17], dice[14]]);
constraint all_different_int([dice[21], dice[9], dice[14], dice[24]]);
constraint all_different_int([dice[22], dice[17], dice[1], dice[16]]);
constraint global_cardinality(dice, [1, 2, 3, 4], [6, 6, 6, 6]);
solve satisfy;