1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
on-restart-benchmarks/tests/examples/steiner-triples.mzn
Jip J. Dekker f2a1c4e389 Squashed 'software/mza/' content from commit f970a59b17
git-subtree-dir: software/mza
git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
2021-07-11 16:34:30 +10:00

43 lines
1.3 KiB
MiniZinc

% RUNS ON mzn20_fd
% RUNS ON mzn-fzn_fd
% RUNS ON mzn20_fd_linear
% RUNS ON mzn20_mip
%-----------------------------------------------------------------------------%
% Steiner Triples (CSPlib problem 44)
%
% March 2008; Mark Wallace, based on the Eclipse version by Joachim Schimpf
%
% The following program computes so-called Steiner triplets. These are
% triplets of numbers from 1 to n such that any two triplets have at most one
% element in common.
%
% One possible solution for n=7 is
% { {1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6},
% {2, 5, 7}, {3, 4, 7}, {3, 5, 6} }.
%-----------------------------------------------------------------------------%
n = 7;
%-----------------------------------------------------------------------------%
int: n;
int: nb = n * (n-1) div 6 ;
array[1..nb] of var set of 1..n: sets;
constraint forall(i in 1..nb) ( card(sets[i]) = 3 );
constraint
forall(i in 1..nb, j in i+1..nb) ( card(sets[i] intersect sets[j]) <= 1 );
% Symmetry breaking:
constraint forall(i in 1..nb-1) ( sets[i] >= sets[i+1] );
solve :: set_search(sets, input_order, indomain_min, complete) satisfy;
output [ " " ++ show(sets[i]) | i in 1..nb ] ++ ["\n"];
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%