MCPcopy Create free account
hub / github.com/Gecode/gecode / rndrel

Method rndrel

test/int.cpp:179–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177 }
178
179 void
180 TestSpace::rndrel(const Assignment& a, int i, Gecode::IntRelType& irt, int& v,
181 Gecode::Support::RandomGenerator& rand) {
182 using namespace Gecode;
183 // Select mode for pruning
184 irt = IRT_EQ; // Means do nothing!
185 switch (rand(3)) {
186 case 0:
187 if (a[i] < x[i].max()) {
188 v=a[i]+1+
189 static_cast<int>(rand(static_cast<unsigned int>(x[i].max()-a[i])));
190 assert((v > a[i]) && (v <= x[i].max()));
191 irt = IRT_LE;
192 }
193 break;
194 case 1:
195 if (a[i] > x[i].min()) {
196 v=x[i].min()+
197 static_cast<int>(rand(static_cast<unsigned int>(a[i]-x[i].min())));
198 assert((v < a[i]) && (v >= x[i].min()));
199 irt = IRT_GR;
200 }
201 break;
202 default:
203 {
204 Gecode::Int::ViewRanges<Gecode::Int::IntView> it(x[i]);
205 unsigned int skip = rand(static_cast<unsigned int>(x[i].size()-1));
206 while (true) {
207 if (it.width() > skip) {
208 v = it.min() + static_cast<int>(skip);
209 if (v == a[i]) {
210 if (it.width() == 1) {
211 ++it; v = it.min();
212 } else if (v < it.max()) {
213 ++v;
214 } else {
215 --v;
216 }
217 }
218 break;
219 }
220 skip -= it.width(); ++it;
221 }
222 irt = IRT_NQ;
223 break;
224 }
225 }
226 }
227
228 void
229 TestSpace::rel(int i, Gecode::IntRelType irt, int n) {

Callers

nothing calls this directly

Calls 4

maxMethod · 0.45
minMethod · 0.45
sizeMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected