00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "test/int.hh"
00039
00040 #include <gecode/minimodel.hh>
00041 #include <climits>
00042
00043 namespace Test { namespace Int {
00044
00046 namespace Extensional {
00047
00053
00054 class RegSimpleA : public Test {
00055 public:
00057 RegSimpleA(void) : Test("Extensional::Reg::Simple::A",4,2,2) {}
00059 virtual bool solution(const Assignment& x) const {
00060 return (((x[0] == 0) || (x[0] == 2)) &&
00061 ((x[1] == -1) || (x[1] == 1)) &&
00062 ((x[2] == 0) || (x[2] == 1)) &&
00063 ((x[3] == 0) || (x[3] == 1)));
00064 }
00066 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00067 using namespace Gecode;
00068 extensional(home, x,
00069 (REG(0) | REG(2)) +
00070 (REG(-1) | REG(1)) +
00071 (REG(7) | REG(0) | REG(1)) +
00072 (REG(0) | REG(1)));
00073 }
00074 };
00075
00077 class RegSimpleB : public Test {
00078 public:
00080 RegSimpleB(void) : Test("Extensional::Reg::Simple::B",4,2,2) {}
00082 virtual bool solution(const Assignment& x) const {
00083 return (x[0]<x[1]) && (x[1]<x[2]) && (x[2]<x[3]);
00084 }
00086 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00087 using namespace Gecode;
00088 extensional(home, x,
00089 (REG(-2) + REG(-1) + REG(0) + REG(1)) |
00090 (REG(-2) + REG(-1) + REG(0) + REG(2)) |
00091 (REG(-2) + REG(-1) + REG(1) + REG(2)) |
00092 (REG(-2) + REG(0) + REG(1) + REG(2)) |
00093 (REG(-1) + REG(0) + REG(1) + REG(2)));
00094 }
00095 };
00096
00098 class RegSimpleC : public Test {
00099 public:
00101 RegSimpleC(void) : Test("Extensional::Reg::Simple::C",6,0,1) {}
00103 virtual bool solution(const Assignment& x) const {
00104 int pos = 0;
00105 int s = x.size();
00106
00107 while (pos < s && x[pos] == 0) ++pos;
00108 if (pos + 4 > s) return false;
00109
00110 for (int i = 0; i < 2; ++i, ++pos)
00111 if (x[pos] != 1) return false;
00112 if (pos + 2 > s) return false;
00113
00114 for (int i = 0; i < 1; ++i, ++pos)
00115 if (x[pos] != 0) return false;
00116 while (pos < s && x[pos] == 0) ++pos;
00117 if (pos + 1 > s) return false;
00118
00119 for (int i = 0; i < 1; ++i, ++pos)
00120 if (x[pos] != 1) return false;
00121 while (pos < s) if (x[pos++] != 0) return false;
00122 return true;
00123
00124 }
00126 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00127 using namespace Gecode;
00128 extensional(home, x,
00129 *REG(0) + REG(1)(2,2) + +REG(0) + REG(1)(1,1) + *REG(0));
00130 }
00131 };
00132
00134 class RegDistinct : public Test {
00135 public:
00137 RegDistinct(void) : Test("Extensional::Reg::Distinct",4,-1,4) {}
00139 virtual bool solution(const Assignment& x) const {
00140 for (int i=0; i<x.size(); i++) {
00141 if ((x[i] < 0) || (x[i] > 3))
00142 return false;
00143 for (int j=i+1; j<x.size(); j++)
00144 if (x[i]==x[j])
00145 return false;
00146 }
00147 return true;
00148 }
00150 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00151 using namespace Gecode;
00152 extensional(home, x,
00153 (REG(0)+REG(1)+REG(2)+REG(3)) |
00154 (REG(0)+REG(1)+REG(3)+REG(2)) |
00155 (REG(0)+REG(2)+REG(1)+REG(3)) |
00156 (REG(0)+REG(2)+REG(3)+REG(1)) |
00157 (REG(0)+REG(3)+REG(1)+REG(2)) |
00158 (REG(0)+REG(3)+REG(2)+REG(1)) |
00159 (REG(1)+REG(0)+REG(2)+REG(3)) |
00160 (REG(1)+REG(0)+REG(3)+REG(2)) |
00161 (REG(1)+REG(2)+REG(0)+REG(3)) |
00162 (REG(1)+REG(2)+REG(3)+REG(0)) |
00163 (REG(1)+REG(3)+REG(0)+REG(2)) |
00164 (REG(1)+REG(3)+REG(2)+REG(0)) |
00165 (REG(2)+REG(0)+REG(1)+REG(3)) |
00166 (REG(2)+REG(0)+REG(3)+REG(1)) |
00167 (REG(2)+REG(1)+REG(0)+REG(3)) |
00168 (REG(2)+REG(1)+REG(3)+REG(0)) |
00169 (REG(2)+REG(3)+REG(0)+REG(1)) |
00170 (REG(2)+REG(3)+REG(1)+REG(0)) |
00171 (REG(3)+REG(0)+REG(1)+REG(2)) |
00172 (REG(3)+REG(0)+REG(2)+REG(1)) |
00173 (REG(3)+REG(1)+REG(0)+REG(2)) |
00174 (REG(3)+REG(1)+REG(2)+REG(0)) |
00175 (REG(3)+REG(2)+REG(0)+REG(1)) |
00176 (REG(3)+REG(2)+REG(1)+REG(0)));
00177 }
00178 };
00179
00181 class RegRoland : public Test {
00182 public:
00184 RegRoland(int n)
00185 : Test("Extensional::Reg::Roland::"+str(n),n,0,1) {}
00187 virtual bool solution(const Assignment& x) const {
00188 int n = x.size();
00189 return
00190 ((n > 1) && (x[n-2] == 0)) ||
00191 ((n > 0) && (x[n-1] == 0));
00192 }
00194 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00195 using namespace Gecode;
00196 REG r0(0), r1(1);
00197 REG r01 = r0 | r1;
00198 extensional(home, x, *r01 + r0 + r01(0,1));
00199 }
00200 };
00201
00203 class RegSharedA : public Test {
00204 public:
00206 RegSharedA(void) : Test("Extensional::Reg::Shared::A",4,2,2) {}
00208 virtual bool solution(const Assignment& x) const {
00209 return (((x[0] == 0) || (x[0] == 2)) &&
00210 ((x[1] == -1) || (x[1] == 1)) &&
00211 ((x[2] == 0) || (x[2] == 1)) &&
00212 ((x[3] == 0) || (x[3] == 1)));
00213 }
00215 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00216 using namespace Gecode;
00217 IntVarArgs y(8);
00218 for (int i=0; i<4; i++)
00219 y[i]=y[i+4]=x[i];
00220 unshare(home,y);
00221 extensional(home, y,
00222 ((REG(0) | REG(2)) +
00223 (REG(-1) | REG(1)) +
00224 (REG(7) | REG(0) | REG(1)) +
00225 (REG(0) | REG(1)))(2,2));
00226 }
00227 };
00228
00230 class RegSharedB : public Test {
00231 public:
00233 RegSharedB(void) : Test("Extensional::Reg::Shared::B",4,2,2) {}
00235 virtual bool solution(const Assignment& x) const {
00236 return (((x[0] == 0) || (x[0] == 2)) &&
00237 ((x[1] == -1) || (x[1] == 1)) &&
00238 ((x[2] == 0) || (x[2] == 1)) &&
00239 ((x[3] == 0) || (x[3] == 1)));
00240 }
00242 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00243 using namespace Gecode;
00244 IntVarArgs y(12);
00245 for (int i=0; i<4; i++)
00246 y[i]=y[i+4]=y[i+8]=x[i];
00247 unshare(home,y);
00248 extensional(home, y,
00249 ((REG(0) | REG(2)) +
00250 (REG(-1) | REG(1)) +
00251 (REG(7) | REG(0) | REG(1)) +
00252 (REG(0) | REG(1)))(3,3));
00253 }
00254 };
00255
00257 class RegSharedC : public Test {
00258 public:
00260 RegSharedC(void) : Test("Extensional::Reg::Shared::C",4,0,1) {}
00262 virtual bool solution(const Assignment& x) const {
00263 return (x[1]==1) && (x[2]==0) && (x[3]==1);
00264 }
00266 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00267 using namespace Gecode;
00268 Gecode::BoolVarArgs y(8);
00269 for (int i=0; i<4; i++)
00270 y[i]=y[i+4]=channel(home,x[i]);
00271 unshare(home,y);
00272 extensional(home,y,
00273 ((REG(0) | REG(1)) + REG(1) + REG(0) + REG(1))(2,2));
00274 }
00275 };
00276
00278 class RegSharedD : public Test {
00279 public:
00281 RegSharedD(void) : Test("Extensional::Reg::Shared::D",4,0,1) {}
00283 virtual bool solution(const Assignment& x) const {
00284 return (x[1]==1) && (x[2]==0) && (x[3]==1);
00285 }
00287 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00288 using namespace Gecode;
00289 Gecode::BoolVarArgs y(12);
00290 for (int i=0; i<4; i++)
00291 y[i]=y[i+4]=y[i+8]=channel(home,x[i]);
00292 unshare(home, y);
00293 extensional(home, y,
00294 ((REG(0) | REG(1)) + REG(1) + REG(0) + REG(1))(3,3));
00295 }
00296 };
00297
00299 class RegEmptyDFA : public Test {
00300 public:
00302 RegEmptyDFA(void) : Test("Extensional::Reg::Empty::DFA",1,0,0) {
00303 testsearch = false;
00304 }
00306 virtual bool solution(const Assignment& x) const {
00307 (void)x;
00308 return false;
00309 }
00311 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00312 Gecode::DFA d;
00313 Gecode::extensional(home, x, d);
00314 }
00315 };
00316
00318 class RegEmptyREG : public Test {
00319 public:
00321 RegEmptyREG(void) : Test("Extensional::Reg::Empty::REG",1,0,0) {
00322 testsearch = false;
00323 }
00325 virtual bool solution(const Assignment& x) const {
00326 (void)x;
00327 return false;
00328 }
00330 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00331 Gecode::REG r;
00332 Gecode::extensional(home, x, r);
00333 }
00334 };
00335
00337 class RegOpt : public Test {
00338 protected:
00340 int n;
00341 public:
00343 RegOpt(int n0)
00344 : Test("Extensional::Reg::Opt::"+str(n0),1,0,15), n(n0) {}
00346 virtual bool solution(const Assignment& x) const {
00347 return (x[0] < n) && ((x[0] & 1) == 0);
00348 }
00350 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00351 using namespace Gecode;
00352 DFA::Transition* t = new DFA::Transition[n+1];
00353 DFA::Transition* ti = t;
00354 int* f = new int[n+1];
00355 int* fi = f;
00356 for (int i=0; i<n; i++) {
00357 ti->i_state = 0;
00358 ti->symbol = i;
00359 ti->o_state = i+1;
00360 ti++;
00361 if ((i & 1) == 0) {
00362 *fi = i+1; fi++;
00363 }
00364 }
00365 ti->i_state = -1;
00366 *fi = -1;
00367 DFA d(0, t, f, false);
00368 delete [] t;
00369 delete [] f;
00370 extensional(home, x, d);
00371 }
00372
00373 };
00374
00376 Gecode::DFA tupleset2dfa(Gecode::TupleSet ts) {
00377 using namespace Gecode;
00378 REG expression;
00379 for (int i = 0; i<ts.tuples(); i++) {
00380 REG r;
00381 for (int j = 0; j<ts.arity(); j++) {
00382 r += REG(ts[i][j]);
00383 }
00384 expression |= r;
00385 }
00386 DFA dfa(expression);
00387 return dfa;
00388 }
00389
00391 class TupleSetBase : public Test {
00392 protected:
00394 Gecode::TupleSet t;
00396 bool pos;
00397 public:
00399 TupleSetBase(bool p)
00400 : Test("Extensional::TupleSet::" + str(p) + "::Base",
00401 4,1,5,true,Gecode::IPL_DOM), t(4), pos(p) {
00402 using namespace Gecode;
00403 IntArgs t1({2, 1, 2, 4});
00404 IntArgs t2({2, 2, 1, 4});
00405 IntArgs t3({4, 3, 4, 1});
00406 IntArgs t4({1, 3, 2, 3});
00407 IntArgs t5({3, 3, 3, 2});
00408 t.add(t1).add(t1).add(t2).add(t2)
00409 .add(t3).add(t3).add(t4).add(t4)
00410 .add(t5).add(t5).add(t5).add(t5)
00411 .add(t5).add(t5).add(t5).add(t5)
00412 .add(t1).add(t1).add(t2).add(t2)
00413 .add(t3).add(t3).add(t4).add(t4)
00414 .add(t5).add(t5).add(t5).add(t5)
00415 .add(t5).add(t5).add(t5).add(t5)
00416 .finalize();
00417 }
00419 virtual bool solution(const Assignment& x) const {
00420 return pos == ((x[0] == 1 && x[1] == 3 && x[2] == 2 && x[3] == 3) ||
00421 (x[0] == 2 && x[1] == 1 && x[2] == 2 && x[3] == 4) ||
00422 (x[0] == 2 && x[1] == 2 && x[2] == 1 && x[3] == 4) ||
00423 (x[0] == 3 && x[1] == 3 && x[2] == 3 && x[3] == 2) ||
00424 (x[0] == 4 && x[1] == 3 && x[2] == 4 && x[3] == 1));
00425 }
00427 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00428 using namespace Gecode;
00429 TupleSet ts = TupleSet(t.arity(),tupleset2dfa(t));
00430 assert(t == ts);
00431 extensional(home, x, t, pos, ipl);
00432 }
00434 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
00435 Gecode::Reify r) {
00436 extensional(home, x, t, pos, r, ipl);
00437 }
00438 };
00439
00441 class TupleSetTest : public Test {
00442 protected:
00444 bool pos;
00446 Gecode::TupleSet ts;
00448 bool toDFA;
00449 public:
00451 TupleSetTest(const std::string& s, bool p,
00452 Gecode::IntSet d0, Gecode::TupleSet ts0, bool td)
00453 : Test("Extensional::TupleSet::" + str(p) + "::" + s,
00454 ts0.arity(),d0,true,Gecode::IPL_DOM),
00455 pos(p), ts(ts0), toDFA(td) {
00456 }
00458 virtual bool solution(const Assignment& x) const {
00459 using namespace Gecode;
00460 for (int i=ts.tuples(); i--; ) {
00461 TupleSet::Tuple t = ts[i];
00462 bool same = true;
00463 for (int j=0; (j < ts.arity()) && same; j++)
00464 if (t[j] != x[j])
00465 same = false;
00466 if (same)
00467 return pos;
00468 }
00469 return !pos;
00470 }
00472 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00473 using namespace Gecode;
00474 if (toDFA) {
00475 TupleSet t = TupleSet(ts.arity(),tupleset2dfa(ts));
00476 assert(ts == t);
00477 }
00478 extensional(home, x, ts, pos, ipl);
00479 }
00481 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
00482 Gecode::Reify r) {
00483 using namespace Gecode;
00484 extensional(home, x, ts, pos, r, ipl);
00485 }
00486 };
00487
00488 class RandomTupleSetTest : public TupleSetTest {
00489 public:
00491 RandomTupleSetTest(const std::string& s, bool p,
00492 Gecode::IntSet d0, Gecode::TupleSet ts0)
00493 : TupleSetTest(s,p,d0,ts0,false) {
00494 testsearch = false;
00495 }
00497 virtual Assignment* assignment(void) const {
00498 using namespace Gecode;
00499 return new RandomAssignment(arity,dom,1000);
00500 }
00501 };
00502
00504 class TupleSetLarge : public Test {
00505 protected:
00507 bool pos;
00509 mutable Gecode::TupleSet t;
00510 public:
00512 TupleSetLarge(double prob, bool p)
00513 : Test("Extensional::TupleSet::" + str(p) + "::Large",
00514 5,1,5,true,Gecode::IPL_DOM), pos(p), t(5) {
00515 using namespace Gecode;
00516
00517 CpltAssignment ass(5, IntSet(1, 5));
00518 while (ass()) {
00519 if (Base::rand(100) <= prob*100) {
00520 IntArgs tuple(5);
00521 for (int i = 5; i--; ) tuple[i] = ass[i];
00522 t.add(tuple);
00523 }
00524 ++ass;
00525 }
00526 t.finalize();
00527 }
00529 virtual bool solution(const Assignment& x) const {
00530 using namespace Gecode;
00531 for (int i = 0; i < t.tuples(); ++i) {
00532 TupleSet::Tuple l = t[i];
00533 bool same = true;
00534 for (int j = 0; j < t.arity() && same; ++j)
00535 if (l[j] != x[j]) same = false;
00536 if (same)
00537 return pos;
00538 }
00539 return !pos;
00540 }
00542 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00543 using namespace Gecode;
00544 extensional(home, x, t, pos, ipl);
00545 }
00547 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
00548 Gecode::Reify r) {
00549 using namespace Gecode;
00550 extensional(home, x, t, pos, r, ipl);
00551 }
00552 };
00553
00555 class TupleSetBool : public Test {
00556 protected:
00558 bool pos;
00560 mutable Gecode::TupleSet t;
00561 public:
00563 TupleSetBool(double prob, bool p)
00564 : Test("Extensional::TupleSet::" + str(p) + "::Bool",
00565 5,0,1,true), pos(p), t(5) {
00566 using namespace Gecode;
00567
00568 CpltAssignment ass(5, IntSet(0, 1));
00569 while (ass()) {
00570 if (Base::rand(100) <= prob*100) {
00571 IntArgs tuple(5);
00572 for (int i = 5; i--; ) tuple[i] = ass[i];
00573 t.add(tuple);
00574 }
00575 ++ass;
00576 }
00577 t.finalize();
00578 }
00580 virtual bool solution(const Assignment& x) const {
00581 using namespace Gecode;
00582 for (int i = 0; i < t.tuples(); ++i) {
00583 TupleSet::Tuple l = t[i];
00584 bool same = true;
00585 for (int j = 0; j < t.arity() && same; ++j)
00586 if (l[j] != x[j])
00587 same = false;
00588 if (same)
00589 return pos;
00590 }
00591 return !pos;
00592 }
00594 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
00595 using namespace Gecode;
00596 BoolVarArgs y(x.size());
00597 for (int i = x.size(); i--; )
00598 y[i] = channel(home, x[i]);
00599 extensional(home, y, t, pos, ipl);
00600 }
00602 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
00603 Gecode::Reify r) {
00604 using namespace Gecode;
00605 BoolVarArgs y(x.size());
00606 for (int i = x.size(); i--; )
00607 y[i] = channel(home, x[i]);
00608 extensional(home, y, t, pos, r, ipl);
00609 }
00610 };
00611
00613 class TupleSetTestSize {
00614 public:
00616 TupleSetTestSize(int size, bool pos) {
00617 using namespace Gecode;
00619 int arity = 2;
00620 int n_tuples = 5*5;
00621 while (n_tuples < size) {
00622 arity++;
00623 n_tuples*=5;
00624 }
00626 TupleSet ts(arity);
00627 CpltAssignment ass(arity, IntSet(0, 4));
00628 for (int i = size; i--; ) {
00629 assert(ass());
00630 IntArgs tuple(arity);
00631 for (int j = arity; j--; ) tuple[j] = ass[j];
00632 ts.add(tuple);
00633 ++ass;
00634 }
00635 ts.finalize();
00636 assert(ts.tuples() == size);
00637
00638 (void) new TupleSetTest(std::to_string(size),pos,IntSet(0,4),ts,
00639 size <= 128);
00640 }
00641 };
00642
00643 Gecode::TupleSet randomTupleSet(int n, int min, int max, double prob) {
00644 using namespace Gecode;
00645 TupleSet t(n);
00646 CpltAssignment ass(n, IntSet(min, max));
00647 while (ass()) {
00648 if (Base::rand(100) <= prob*100) {
00649 IntArgs tuple(n);
00650 for (int i = n; i--; ) tuple[i] = ass[i];
00651 t.add(tuple);
00652 }
00653 ++ass;
00654 }
00655 t.finalize();
00656 return t;
00657 }
00658
00660 class Create {
00661 public:
00663 Create(void) {
00664 using namespace Gecode;
00665 for (bool pos : { false, true }) {
00666 {
00667 TupleSet ts(4);
00668 ts.add({2, 1, 2, 4}).add({2, 2, 1, 4})
00669 .add({4, 3, 4, 1}).add({1, 3, 2, 3})
00670 .add({3, 3, 3, 2}).add({5, 1, 4, 4})
00671 .add({2, 5, 1, 5}).add({4, 3, 5, 1})
00672 .add({1, 5, 2, 5}).add({5, 3, 3, 2})
00673 .finalize();
00674 (void) new TupleSetTest("A",pos,IntSet(0,6),ts,true);
00675 }
00676 {
00677 TupleSet ts(4);
00678 ts.finalize();
00679 (void) new TupleSetTest("Empty",pos,IntSet(1,2),ts,true);
00680 }
00681 {
00682 TupleSet ts(4);
00683 for (int n=1024*16; n--; )
00684 ts.add({1,2,3,4});
00685 ts.finalize();
00686 (void) new TupleSetTest("Assigned",pos,IntSet(1,4),ts,true);
00687 }
00688 {
00689 TupleSet ts(1);
00690 ts.add({1}).add({2}).add({3}).finalize();
00691 (void) new TupleSetTest("Single",pos,IntSet(-4,4),ts,true);
00692 }
00693 {
00694 int m = Gecode::Int::Limits::min;
00695 TupleSet ts(3);
00696 ts.add({m+0,m+1,m+2}).add({m+4,m+1,m+3})
00697 .add({m+2,m+3,m+0}).add({m+2,m+3,m+0})
00698 .add({m+1,m+2,m+5}).add({m+2,m+3,m+0})
00699 .add({m+3,m+6,m+5}).finalize();
00700 (void) new TupleSetTest("Min",pos,IntSet(m,m+7),ts,true);
00701 }
00702 {
00703 int M = Gecode::Int::Limits::max;
00704 TupleSet ts(3);
00705 ts.add({M-0,M-1,M-2}).add({M-4,M-1,M-3})
00706 .add({M-2,M-3,M-0}).add({M-2,M-3,M-0})
00707 .add({M-1,M-2,M-5}).add({M-2,M-3,M-0})
00708 .add({M-3,M-6,M-5}).finalize();
00709 (void) new TupleSetTest("Max",pos,IntSet(M-7,M),ts,true);
00710 }
00711 {
00712 int m = Gecode::Int::Limits::min;
00713 int M = Gecode::Int::Limits::max;
00714 TupleSet ts(3);
00715 ts.add({M-0,m+1,M-2}).add({m+4,M-1,M-3})
00716 .add({m+2,M-3,m+0}).add({M-2,M-3,M-0})
00717 .finalize();
00718 (void) new TupleSetTest("MinMax",pos,
00719 IntSet(IntArgs({m,m+1,m+4,M-3,M-2,M})),
00720 ts,true);
00721 }
00722 {
00723 TupleSet ts(7);
00724 for (int i = 0; i < 10000; i++) {
00725 IntArgs tuple(7);
00726 for (int j = 0; j < 7; j++) {
00727 tuple[j] = Base::rand(j+1);
00728 }
00729 ts.add(tuple);
00730 }
00731 ts.finalize();
00732 (void) new RandomTupleSetTest("Triangle",pos,IntSet(0,6),ts);
00733 }
00734 {
00735 for (int i = 0; i <= 64*6; i+=32)
00736 (void) new TupleSetTestSize(i,pos);
00737 }
00738 {
00739 (void) new RandomTupleSetTest("Rand(10,-1,2)", pos,
00740 IntSet(-1,2),
00741 randomTupleSet(10,-1,2,0.05));
00742 (void) new RandomTupleSetTest("Rand(5,-10,10)", pos,
00743 IntSet(-10,10),
00744 randomTupleSet(5,-10,10,0.05));
00745 }
00746 {
00747 TupleSet t(5);
00748 CpltAssignment ass(4, IntSet(1, 4));
00749 while (ass()) {
00750 IntArgs tuple(5);
00751 tuple[4] = 1;
00752 for (int i = 4; i--; ) tuple[i] = ass[i];
00753 t.add(tuple);
00754 ++ass;
00755 }
00756 t.add({2,2,4,3,4});
00757 t.finalize();
00758 (void) new TupleSetTest("FewLast",pos,IntSet(1,4),t,false);
00759 }
00760 {
00761 TupleSet t(4);
00762 CpltAssignment ass(4, IntSet(1, 6));
00763 while (ass()) {
00764 t.add({ass[0],0,ass[1],ass[2]});
00765 ++ass;
00766 }
00767 t.add({2,-1,3,4});
00768 t.finalize();
00769 (void) new TupleSetTest("FewMiddle",pos,IntSet(-1,6),t,false);
00770 }
00771 {
00772 TupleSet t(10);
00773 CpltAssignment ass(9, IntSet(1, 4));
00774 while (ass()) {
00775 if (Base::rand(100) <= 0.25*100) {
00776 IntArgs tuple(10);
00777 tuple[0] = 2;
00778 for (int i = 9; i--; ) tuple[i+1] = ass[i];
00779 t.add(tuple);
00780 }
00781 ++ass;
00782 }
00783 t.add({1,1,1,1,1,1,1,1,1,1});
00784 t.add({1,2,3,4,4,2,1,2,3,3});
00785 t.finalize();
00786 (void) new RandomTupleSetTest("FewHuge",pos,IntSet(1,4),t);
00787 }
00788 (void) new TupleSetBase(pos);
00789 (void) new TupleSetLarge(0.05,pos);
00790 (void) new TupleSetBool(0.3,pos);
00791 }
00792 }
00793 };
00794
00795 Create c;
00796
00797 RegSimpleA ra;
00798 RegSimpleB rb;
00799 RegSimpleC rc;
00800
00801 RegDistinct rd;
00802
00803 RegRoland rr1(1);
00804 RegRoland rr2(2);
00805 RegRoland rr3(3);
00806 RegRoland rr4(4);
00807
00808 RegSharedA rsa;
00809 RegSharedB rsb;
00810 RegSharedC rsc;
00811 RegSharedD rsd;
00812
00813 RegEmptyDFA redfa;
00814 RegEmptyREG rereg;
00815
00816 RegOpt ro0(CHAR_MAX-1);
00817 RegOpt ro1(CHAR_MAX);
00818 RegOpt ro2(static_cast<int>(UCHAR_MAX-1));
00819 RegOpt ro3(static_cast<int>(UCHAR_MAX));
00820 RegOpt ro4(SHRT_MAX-1);
00821 RegOpt ro5(SHRT_MAX);
00822 RegOpt ro6(static_cast<int>(USHRT_MAX-1));
00823 RegOpt ro7(static_cast<int>(USHRT_MAX));
00825
00826 }
00827 }}
00828
00829
00830