forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
best_shuffle.fzn
65 lines (65 loc) · 4.8 KB
/
best_shuffle.fzn
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
predicate fzn_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_fzn_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_fzn_cumulative(array [int] of var int: s, array [int] of int: d, array [int] of int: r, var int: b);
array [1..8] of int: word = [1, 1, 2, 2, 2, 2, 1, 1];
var bool: BOOL____00002 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00005 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00008 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00011 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00014 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00017 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00020 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00023 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00001 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00003 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00004 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00006 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00007 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00009 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00010 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00012 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00013 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00015 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00016 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00018 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00019 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00021 :: is_defined_var :: var_is_introduced;
var 1..2: INT____00022 :: is_defined_var :: var_is_introduced;
var 0..1: INT____00024 :: is_defined_var :: var_is_introduced;
var 0..8: num_same :: output_var = 0;
array [1..8] of var 1..8: shuffle :: output_array([1..8]);
constraint fzn_all_different_int(shuffle);
constraint array_int_element(shuffle[1], word, INT____00001) :: defines_var(INT____00001);
constraint array_int_element(shuffle[2], word, INT____00004) :: defines_var(INT____00004);
constraint array_int_element(shuffle[3], word, INT____00007) :: defines_var(INT____00007);
constraint array_int_element(shuffle[4], word, INT____00010) :: defines_var(INT____00010);
constraint array_int_element(shuffle[5], word, INT____00013) :: defines_var(INT____00013);
constraint array_int_element(shuffle[6], word, INT____00016) :: defines_var(INT____00016);
constraint array_int_element(shuffle[7], word, INT____00019) :: defines_var(INT____00019);
constraint array_int_element(shuffle[8], word, INT____00022) :: defines_var(INT____00022);
constraint bool2int(BOOL____00002, INT____00003) :: defines_var(INT____00003);
constraint bool2int(BOOL____00005, INT____00006) :: defines_var(INT____00006);
constraint bool2int(BOOL____00008, INT____00009) :: defines_var(INT____00009);
constraint bool2int(BOOL____00011, INT____00012) :: defines_var(INT____00012);
constraint bool2int(BOOL____00014, INT____00015) :: defines_var(INT____00015);
constraint bool2int(BOOL____00017, INT____00018) :: defines_var(INT____00018);
constraint bool2int(BOOL____00020, INT____00021) :: defines_var(INT____00021);
constraint bool2int(BOOL____00023, INT____00024) :: defines_var(INT____00024);
constraint int_eq_reif(INT____00001, 1, BOOL____00002) :: defines_var(BOOL____00002);
constraint int_eq_reif(INT____00004, 1, BOOL____00005) :: defines_var(BOOL____00005);
constraint int_eq_reif(INT____00007, 2, BOOL____00008) :: defines_var(BOOL____00008);
constraint int_eq_reif(INT____00010, 2, BOOL____00011) :: defines_var(BOOL____00011);
constraint int_eq_reif(INT____00013, 2, BOOL____00014) :: defines_var(BOOL____00014);
constraint int_eq_reif(INT____00016, 2, BOOL____00017) :: defines_var(BOOL____00017);
constraint int_eq_reif(INT____00019, 1, BOOL____00020) :: defines_var(BOOL____00020);
constraint int_eq_reif(INT____00022, 1, BOOL____00023) :: defines_var(BOOL____00023);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1, 1, 1], [0, INT____00003, INT____00006, INT____00009, INT____00012, INT____00015, INT____00018, INT____00021, INT____00024], 0);
solve :: int_search(shuffle, first_fail, indomain_min, complete) satisfy;