forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alldifferent_interval.fzn
49 lines (49 loc) · 3.33 KB
/
alldifferent_interval.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
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);
var bool: BOOL____00001 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00002 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00003 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00004 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00005 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00006 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00007 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00008 :: is_defined_var :: var_is_introduced;
var bool: BOOL____00009 :: is_defined_var :: var_is_introduced;
array [1..6] of var 0..20: intervals :: output_array([1..3, 1..2]);
var 1..9: size_interval :: output_var;
array [1..3] of var 1..10: x :: output_array([1..3]);
constraint all_different_int(x);
constraint array_bool_and([BOOL____00001, BOOL____00002], BOOL____00007) :: defines_var(BOOL____00007);
constraint array_bool_and([BOOL____00003, BOOL____00004], BOOL____00008) :: defines_var(BOOL____00008);
constraint array_bool_and([BOOL____00005, BOOL____00006], BOOL____00009) :: defines_var(BOOL____00009);
constraint array_bool_or([BOOL____00009, BOOL____00007, BOOL____00008], true);
constraint int_eq(2, x[1]);
constraint int_eq(3, x[2]);
constraint int_eq(10, x[3]);
constraint int_eq_reif(intervals[1], size_interval, BOOL____00001) :: defines_var(BOOL____00001);
constraint int_le(intervals[1], x[1]);
constraint int_le(intervals[3], x[2]);
constraint int_le(intervals[5], x[3]);
constraint int_le(x[1], intervals[2]);
constraint int_le(x[2], intervals[4]);
constraint int_le(x[3], intervals[6]);
constraint int_lin_eq([-1, -1, 1], [size_interval, intervals[1], intervals[2]], -1);
constraint int_lin_eq([-1, -1, 1], [size_interval, intervals[3], intervals[4]], -1);
constraint int_lin_eq([-1, -1, 1], [size_interval, intervals[5], intervals[6]], -1);
constraint int_lin_eq_reif([-4, 1], [size_interval, intervals[6]], -1, BOOL____00006) :: defines_var(BOOL____00006);
constraint int_lin_eq_reif([-3, 1], [size_interval, intervals[4]], -1, BOOL____00004) :: defines_var(BOOL____00004);
constraint int_lin_eq_reif([-3, 1], [size_interval, intervals[5]], 0, BOOL____00005) :: defines_var(BOOL____00005);
constraint int_lin_eq_reif([-2, 1], [size_interval, intervals[2]], -1, BOOL____00002) :: defines_var(BOOL____00002);
constraint int_lin_eq_reif([-2, 1], [size_interval, intervals[3]], 0, BOOL____00003) :: defines_var(BOOL____00003);
constraint int_lt(intervals[2], intervals[3]);
constraint int_lt(intervals[4], intervals[5]);
solve satisfy;