this repo has no description
at develop 1.3 kB view raw
1% RUNS ON mzn20_fd 2% RUNS ON mzn-fzn_fd 3% RUNS ON mzn20_fd_linear 4% RUNS ON mzn20_mip 5%-----------------------------------------------------------------------------% 6% Steiner Triples (CSPlib problem 44) 7% 8% March 2008; Mark Wallace, based on the Eclipse version by Joachim Schimpf 9% 10% The following program computes so-called Steiner triplets. These are 11% triplets of numbers from 1 to n such that any two triplets have at most one 12% element in common. 13% 14% One possible solution for n=7 is 15% { {1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6}, 16% {2, 5, 7}, {3, 4, 7}, {3, 5, 6} }. 17%-----------------------------------------------------------------------------% 18 19n = 7; 20 21%-----------------------------------------------------------------------------% 22 23int: n; 24 25int: nb = n * (n-1) div 6 ; 26 27array[1..nb] of var set of 1..n: sets; 28 29constraint forall(i in 1..nb) ( card(sets[i]) = 3 ); 30 31constraint 32 forall(i in 1..nb, j in i+1..nb) ( card(sets[i] intersect sets[j]) <= 1 ); 33 34% Symmetry breaking: 35constraint forall(i in 1..nb-1) ( sets[i] >= sets[i+1] ); 36 37solve :: set_search(sets, input_order, indomain_min, complete) satisfy; 38 39output [ " " ++ show(sets[i]) | i in 1..nb ] ++ ["\n"]; 40 41%-----------------------------------------------------------------------------% 42%-----------------------------------------------------------------------------%