this repo has no description
1% RUNS ON mzn20_fd
2% RUNS ON mzn-fzn_fd
3% RUNS ON mzn20_mip
4
5% vim: ft=zinc ts=4 sw=4 et
6% Ralph Becket <rafe@csse.unimelb.edu.au>
7% Wed Feb 25 16:43:52 EST 2009
8%
9% Langford's problem (see e.g., http://www.lclark.edu/~miller/langford.html)
10% ------------------
11%
12% Arrange k sets of 1..n such that successive occurrences of any number, k,
13% are separated by k other numbers.
14
15% There should be 26 solutions to this problem.
16int: k = 2;
17int: n = 7;
18int: nk = n * k;
19
20array [1..nk] of var 1..n: a; % The sequence.
21array [1..n] of var 1..nk: Fst; % Fst[k] is position of first k.
22
23 % Break some symmetry.
24 %
25constraint a[1] <= a[nk];
26
27 % Prune some domains.
28 %
29constraint
30 forall ( i in 1..n ) ( Fst[i] <= nk - (k - 1) * (i + 1) );
31
32 % The nitty gritty.
33 %
34constraint
35 forall ( i in 1..n, j in 0..(k - 1) ) ( a[Fst[i] + j * (i + 1)] = i );
36
37solve :: int_search(Fst, first_fail, indomain_min, complete) satisfy;
38
39output ["a = ", show(a), ";\n"];