Download
/*
Steiner triplets (using sets) in Comet.
This Comet model was created by Hakan Kjellerstrand (hakank@gmail.com)
Also, see my Comet page: http://www.hakank.org/comet
*/
// Licenced under CC-BY-4.0 : http://creativecommons.org/licenses/by/4.0/
import cotfd;
int t0 = System.getCPUTime();
Solver<CP> cp();
int n = 9;
int nb = n *(n-1) / 6;
cout << "nb: " << nb << endl;
int c = 3; // cardinality
var<CP>{set{int}} steiner[1..nb](cp, 1..n, c);
Integer num_solutions(0);
exploreall<cp>{
forall(i in 1..nb, j in 1..nb : i < j) {
cp.post(atmostIntersection(steiner[i], steiner[j], 1));
}
} using {
// label(cp);
forall(i in 1..nb)
label(steiner[i]);
cout << steiner << endl;
num_solutions := num_solutions + 1;
}
cout << "\nnum_solutions: " << num_solutions << endl;
int t1 = System.getCPUTime();
cout << "time: " << (t1-t0) << endl;
cout << "#choices = " << cp.getNChoice() << endl;
cout << "#fail = " << cp.getNFail() << endl;
cout << "#propag = " << cp.getNPropag() << endl;