forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignment6.fzn
104 lines (104 loc) · 6.93 KB
/
assignment6.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var int: INT____00001 :: is_defined_var :: var_is_introduced;
array [1..8] of var 1..8: assigned :: output_array([1..8]);
array [1..64] of var 3..54: c = [13, 21, 20, 12, 8, 26, 22, 11, 12, 36, 25, 41, 40, 11, 4, 8, 35, 32, 13, 36, 26, 21, 13, 37, 34, 54, 7, 8, 12, 22, 11, 40, 21, 6, 45, 18, 24, 34, 12, 48, 42, 19, 39, 15, 14, 16, 28, 46, 16, 34, 38, 3, 34, 40, 22, 24, 26, 20, 5, 17, 45, 31, 37, 43];
array [1..8] of var int: costs :: output_array([1..8]);
array [1..64] of var int: x :: output_array([1..8, 1..8]);
var int: z :: output_var = INT____00001;
constraint int_le(0, x[1]);
constraint int_le(0, x[2]);
constraint int_le(0, x[3]);
constraint int_le(0, x[4]);
constraint int_le(0, x[5]);
constraint int_le(0, x[6]);
constraint int_le(0, x[7]);
constraint int_le(0, x[8]);
constraint int_le(0, x[9]);
constraint int_le(0, x[10]);
constraint int_le(0, x[11]);
constraint int_le(0, x[12]);
constraint int_le(0, x[13]);
constraint int_le(0, x[14]);
constraint int_le(0, x[15]);
constraint int_le(0, x[16]);
constraint int_le(0, x[17]);
constraint int_le(0, x[18]);
constraint int_le(0, x[19]);
constraint int_le(0, x[20]);
constraint int_le(0, x[21]);
constraint int_le(0, x[22]);
constraint int_le(0, x[23]);
constraint int_le(0, x[24]);
constraint int_le(0, x[25]);
constraint int_le(0, x[26]);
constraint int_le(0, x[27]);
constraint int_le(0, x[28]);
constraint int_le(0, x[29]);
constraint int_le(0, x[30]);
constraint int_le(0, x[31]);
constraint int_le(0, x[32]);
constraint int_le(0, x[33]);
constraint int_le(0, x[34]);
constraint int_le(0, x[35]);
constraint int_le(0, x[36]);
constraint int_le(0, x[37]);
constraint int_le(0, x[38]);
constraint int_le(0, x[39]);
constraint int_le(0, x[40]);
constraint int_le(0, x[41]);
constraint int_le(0, x[42]);
constraint int_le(0, x[43]);
constraint int_le(0, x[44]);
constraint int_le(0, x[45]);
constraint int_le(0, x[46]);
constraint int_le(0, x[47]);
constraint int_le(0, x[48]);
constraint int_le(0, x[49]);
constraint int_le(0, x[50]);
constraint int_le(0, x[51]);
constraint int_le(0, x[52]);
constraint int_le(0, x[53]);
constraint int_le(0, x[54]);
constraint int_le(0, x[55]);
constraint int_le(0, x[56]);
constraint int_le(0, x[57]);
constraint int_le(0, x[58]);
constraint int_le(0, x[59]);
constraint int_le(0, x[60]);
constraint int_le(0, x[61]);
constraint int_le(0, x[62]);
constraint int_le(0, x[63]);
constraint int_le(0, x[64]);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[1], x[9], x[17], x[25], x[33], x[41], x[49], x[57]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[2], x[10], x[18], x[26], x[34], x[42], x[50], x[58]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[3], x[11], x[19], x[27], x[35], x[43], x[51], x[59]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[4], x[12], x[20], x[28], x[36], x[44], x[52], x[60]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[5], x[13], x[21], x[29], x[37], x[45], x[53], x[61]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[6], x[14], x[22], x[30], x[38], x[46], x[54], x[62]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[7], x[15], x[23], x[31], x[39], x[47], x[55], x[63]], 1);
constraint int_lin_eq([1, 1, 1, 1, 1, 1, 1, 1], [x[8], x[16], x[24], x[32], x[40], x[48], x[56], x[64]], 1);
constraint int_lin_eq([1, -42, -19, -39, -15, -14, -16, -28, -46], [costs[6], x[41], x[42], x[43], x[44], x[45], x[46], x[47], x[48]], 0);
constraint int_lin_eq([1, -35, -32, -13, -36, -26, -21, -13, -37], [costs[3], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]], 0);
constraint int_lin_eq([1, -34, -54, -7, -8, -12, -22, -11, -40], [costs[4], x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32]], 0);
constraint int_lin_eq([1, -26, -20, -5, -17, -45, -31, -37, -43], [costs[8], x[57], x[58], x[59], x[60], x[61], x[62], x[63], x[64]], 0);
constraint int_lin_eq([1, -21, -6, -45, -18, -24, -34, -12, -48], [costs[5], x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40]], 0);
constraint int_lin_eq([1, -16, -34, -38, -3, -34, -40, -22, -24], [costs[7], x[49], x[50], x[51], x[52], x[53], x[54], x[55], x[56]], 0);
constraint int_lin_eq([1, -13, -21, -20, -12, -8, -26, -22, -11], [costs[1], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8]], 0);
constraint int_lin_eq([1, -12, -36, -25, -41, -40, -11, -4, -8], [costs[2], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[1], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[2], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[3], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[4], x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[5], x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[6], x[41], x[42], x[43], x[44], x[45], x[46], x[47], x[48]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[7], x[49], x[50], x[51], x[52], x[53], x[54], x[55], x[56]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4, -5, -6, -7, -8], [assigned[8], x[57], x[58], x[59], x[60], x[61], x[62], x[63], x[64]], 0);
constraint int_lin_eq([-1, 13, 21, 20, 12, 8, 26, 22, 11, 12, 36, 25, 41, 40, 11, 4, 8, 35, 32, 13, 36, 26, 21, 13, 37, 34, 54, 7, 8, 12, 22, 11, 40, 21, 6, 45, 18, 24, 34, 12, 48, 42, 19, 39, 15, 14, 16, 28, 46, 16, 34, 38, 3, 34, 40, 22, 24, 26, 20, 5, 17, 45, 31, 37, 43], [INT____00001, x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24], x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32], x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40], x[41], x[42], x[43], x[44], x[45], x[46], x[47], x[48], x[49], x[50], x[51], x[52], x[53], x[54], x[55], x[56], x[57], x[58], x[59], x[60], x[61], x[62], x[63], x[64]], 0) :: defines_var(INT____00001);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[41], x[42], x[43], x[44], x[45], x[46], x[47], x[48]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[49], x[50], x[51], x[52], x[53], x[54], x[55], x[56]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1], [x[57], x[58], x[59], x[60], x[61], x[62], x[63], x[64]], 1);
solve minimize INT____00001;