Actual model
| 63 | |
| 64 | /// Actual model |
| 65 | Steiner(const SizeOptions& opt) |
| 66 | : Script(opt), n(opt.size()), noOfTriples((n*(n-1))/6), |
| 67 | triples(*this, noOfTriples, IntSet::empty, 1, n, 3U, 3U) { |
| 68 | |
| 69 | for (int i=0; i<noOfTriples; i++) { |
| 70 | for (int j=i+1; j<noOfTriples; j++) { |
| 71 | SetVar x = triples[i]; |
| 72 | SetVar y = triples[j]; |
| 73 | |
| 74 | SetVar atmostOne(*this,IntSet::empty,1,n,0U,1U); |
| 75 | rel(*this, (x & y) == atmostOne); |
| 76 | |
| 77 | IntVar x1(*this,1,n); |
| 78 | IntVar x2(*this,1,n); |
| 79 | IntVar x3(*this,1,n); |
| 80 | IntVar y1(*this,1,n); |
| 81 | IntVar y2(*this,1,n); |
| 82 | IntVar y3(*this,1,n); |
| 83 | |
| 84 | if (opt.model() == MODEL_NONE) { |
| 85 | /* Naive alternative: |
| 86 | * just including the ints in the set |
| 87 | */ |
| 88 | rel(*this, singleton(x1) <= x); |
| 89 | rel(*this, singleton(x2) <= x); |
| 90 | rel(*this, singleton(x3) <= x); |
| 91 | rel(*this, singleton(y1) <= y); |
| 92 | rel(*this, singleton(y2) <= y); |
| 93 | rel(*this, singleton(y3) <= y); |
| 94 | |
| 95 | } else if (opt.model() == MODEL_MATCHING) { |
| 96 | /* Smart alternative: |
| 97 | * Using matching constraints |
| 98 | */ |
| 99 | |
| 100 | channelSorted(*this, {x1,x2,x3}, x); |
| 101 | channelSorted(*this, {y1,y2,y3}, y); |
| 102 | } else if (opt.model() == MODEL_SEQ) { |
| 103 | SetVar sx1 = expr(*this, singleton(x1)); |
| 104 | SetVar sx2 = expr(*this, singleton(x2)); |
| 105 | SetVar sx3 = expr(*this, singleton(x3)); |
| 106 | SetVar sy1 = expr(*this, singleton(y1)); |
| 107 | SetVar sy2 = expr(*this, singleton(y2)); |
| 108 | SetVar sy3 = expr(*this, singleton(y3)); |
| 109 | sequence(*this,{sx1,sx2,sx3},x); |
| 110 | sequence(*this,{sy1,sy2,sy3},y); |
| 111 | } |
| 112 | |
| 113 | /* Breaking symmetries */ |
| 114 | rel(*this, x1 < x2); |
| 115 | rel(*this, x2 < x3); |
| 116 | rel(*this, x1 < x3); |
| 117 | |
| 118 | rel(*this, y1 < y2); |
| 119 | rel(*this, y2 < y3); |
| 120 | rel(*this, y1 < y3); |
| 121 | |
| 122 | linear(*this, |
nothing calls this directly
no test coverage detected