4d26a735
Pedro Roque
Increased recogni...
|
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
|
% latin-squares-hybrid.mzn
% vim: ft=zinc ts=4 sw=4 et
%
%https://raw.githubusercontent.com/MiniZinc/minizinc-benchmarks/master/latin-squares/latin-squares-fd2.mzn
%
% By Peter Stuckey
% Edited to conform to FD/LP hybrid by Ralph Becket.
%
% Latin squares FD version.
%
% A latin square of size n is an n x n square
% where each row and column is a permutation of the numbers 1..n.
%
% A latin square of size 3 is
% 1 2 3
% 2 3 1
% 3 1 2
%
% This model uses alldifferent.
include "globals.mzn";
int: n;
set of int: rg = 1..n;
array [rg, rg] of var rg: x;
constraint forall (i in rg) (alldifferent (j in rg) (x[i, j]));
constraint forall (j in rg) (alldifferent (i in rg) (x[i, j]));
solve
:: int_search(
[x[i, j] | i, j in rg],
input_order,
indomain_max,
complete
)
satisfy;
output [show(x[r, c]) ++ if c = n then "\n" else " " endif | r in rg, c in rg];
|