forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
another_kind_of_magic_square.fzn
41 lines (41 loc) · 3.5 KB
/
another_kind_of_magic_square.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
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);
var 4..36: INT____00001 :: is_defined_var :: var_is_introduced;
var 6..54: INT____00003 :: is_defined_var :: var_is_introduced;
var 4..36: INT____00005 :: is_defined_var :: var_is_introduced;
var 6..54: INT____00007 :: is_defined_var :: var_is_introduced;
var 9..81: INT____00009 :: is_defined_var :: var_is_introduced;
var 6..54: INT____00011 :: is_defined_var :: var_is_introduced;
var 4..36: INT____00013 :: is_defined_var :: var_is_introduced;
var 6..54: INT____00015 :: is_defined_var :: var_is_introduced;
var 4..36: INT____00017 :: is_defined_var :: var_is_introduced;
array [1..9] of var 1..9: magic :: output_array([1..3, 1..3]);
constraint fzn_all_different_int([magic[1], magic[2], magic[3], magic[4], magic[5], magic[6], magic[7], magic[8], magic[9]]) :: domain;
constraint int_lin_eq([-1, 1, 1, 1, 1], [INT____00001, magic[1], magic[2], magic[4], magic[5]], 0) :: defines_var(INT____00001);
constraint int_lin_eq([-1, 1, 1, 1, 1], [INT____00005, magic[2], magic[3], magic[5], magic[6]], 0) :: defines_var(INT____00005);
constraint int_lin_eq([-1, 1, 1, 1, 1], [INT____00013, magic[4], magic[5], magic[7], magic[8]], 0) :: defines_var(INT____00013);
constraint int_lin_eq([-1, 1, 1, 1, 1], [INT____00017, magic[5], magic[6], magic[8], magic[9]], 0) :: defines_var(INT____00017);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1], [INT____00003, magic[1], magic[2], magic[3], magic[4], magic[5], magic[6]], 0) :: defines_var(INT____00003);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1], [INT____00007, magic[1], magic[2], magic[4], magic[5], magic[7], magic[8]], 0) :: defines_var(INT____00007);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1], [INT____00011, magic[2], magic[3], magic[5], magic[6], magic[8], magic[9]], 0) :: defines_var(INT____00011);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1], [INT____00015, magic[4], magic[5], magic[6], magic[7], magic[8], magic[9]], 0) :: defines_var(INT____00015);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [INT____00009, magic[1], magic[2], magic[3], magic[4], magic[5], magic[6], magic[7], magic[8], magic[9]], 0) :: defines_var(INT____00009);
constraint int_mod(INT____00001, magic[1], 0);
constraint int_mod(INT____00003, magic[2], 0);
constraint int_mod(INT____00005, magic[3], 0);
constraint int_mod(INT____00007, magic[4], 0);
constraint int_mod(INT____00009, magic[5], 0);
constraint int_mod(INT____00011, magic[6], 0);
constraint int_mod(INT____00013, magic[7], 0);
constraint int_mod(INT____00015, magic[8], 0);
constraint int_mod(INT____00017, magic[9], 0);
solve :: int_search([magic[1], magic[2], magic[3], magic[4], magic[5], magic[6], magic[7], magic[8], magic[9]], largest, indomain_min, complete) satisfy;