forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binary_matrix2array.fzn
27 lines (27 loc) · 1.15 KB
/
binary_matrix2array.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
array [1..4] of var 1..4: a :: output_array([1..4]);
array [1..16] of var 0..1: x :: output_array([1..4, 1..4]);
constraint int_eq(x[1], 0);
constraint int_eq(x[2], 0);
constraint int_eq(x[3], 1);
constraint int_eq(x[4], 0);
constraint int_eq(x[5], 0);
constraint int_eq(x[6], 1);
constraint int_eq(x[7], 0);
constraint int_eq(x[8], 0);
constraint int_eq(x[9], 0);
constraint int_eq(x[10], 0);
constraint int_eq(x[11], 0);
constraint int_eq(x[12], 1);
constraint int_eq(x[13], 1);
constraint int_eq(x[14], 0);
constraint int_eq(x[15], 0);
constraint int_eq(x[16], 0);
constraint int_lin_eq([1, 1, 1, 1], [x[1], x[2], x[3], x[4]], 1);
constraint int_lin_eq([1, 1, 1, 1], [x[5], x[6], x[7], x[8]], 1);
constraint int_lin_eq([1, 1, 1, 1], [x[9], x[10], x[11], x[12]], 1);
constraint int_lin_eq([1, 1, 1, 1], [x[13], x[14], x[15], x[16]], 1);
constraint int_lin_eq([1, -1, -2, -3, -4], [a[1], x[1], x[2], x[3], x[4]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [a[2], x[5], x[6], x[7], x[8]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [a[3], x[9], x[10], x[11], x[12]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [a[4], x[13], x[14], x[15], x[16]], 0);
solve satisfy;