Generated on Mon Aug 25 11:35:33 2008 for Gecode by doxygen 1.5.6

cpltset.hh

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2005
00008  *     Christian Schulte, 2005
00009  *
00010  *  Last modified:
00011  *     $Date: 2007-11-08 15:53:26 +0100 (Thu, 08 Nov 2007) $ by $Author: tack $
00012  *     $Revision: 5219 $
00013  *
00014  *  This file is part of Gecode, the generic constraint
00015  *  development environment:
00016  *     http://www.gecode.org
00017  *
00018  *  Permission is hereby granted, free of charge, to any person obtaining
00019  *  a copy of this software and associated documentation files (the
00020  *  "Software"), to deal in the Software without restriction, including
00021  *  without limitation the rights to use, copy, modify, merge, publish,
00022  *  distribute, sublicense, and/or sell copies of the Software, and to
00023  *  permit persons to whom the Software is furnished to do so, subject to
00024  *  the following conditions:
00025  *
00026  *  The above copyright notice and this permission notice shall be
00027  *  included in all copies or substantial portions of the Software.
00028  *
00029  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00030  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00031  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00032  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00033  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00034  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00035  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00036  *
00037  */
00038 
00039 #ifndef __GECODE_TEST_CPLTSET_HH__
00040 #define __GECODE_TEST_CPLTSET_HH__
00041 
00042 #include "gecode/cpltset.hh"
00043 
00044 #include "test/test.hh"
00045 #include "test/set.hh"
00046 #include "test/int.hh"
00047 
00048 namespace Test {
00049   
00051   namespace CpltSet {
00052 
00063 
00068     class CpltSetTest : public Base {
00069     private:
00070       int     arity;
00071       Gecode::IntSet  lub;
00072       bool    reified;
00073       int    withInt;
00074       int ivs;
00075       int ics;
00076 
00077       void removeFromLub(int, Gecode::CpltSetVar&, int,
00078                          const Gecode::IntSet&);
00079       void addToGlb(int, Gecode::CpltSetVar&, int, const Gecode::IntSet&);
00080     public:
00081       CpltSetTest(const std::string& s, int a, const Gecode::IntSet& d,
00082                   bool r=false, int w=0, int mn=10000, int mc=1000) 
00083         : Base("CpltSet::"+s), arity(a), lub(d), reified(r), withInt(w), 
00084           ivs(mn), ics(mc)  {
00085         Gecode::CpltSet::manager.dispose();
00086         Gecode::CpltSet::manager.init(mn, mc);
00087       }
00088 
00090       virtual bool solution(const Test::Set::SetAssignment&) const = 0;
00092       virtual void post(Gecode::Space* home, Gecode::CpltSetVarArray& x,
00093                         Gecode::IntVarArray& y) = 0;
00095       virtual void post(Gecode::Space*, Gecode::CpltSetVarArray&,
00096                         Gecode::IntVarArray&, Gecode::BoolVar) {}
00098       virtual bool run(void);
00099 
00100       template <class I>
00101       int iter2int(I& r, int) const{
00102         if (!r()) {
00103           return 0;
00104         }
00105         int v = 0;
00106         // compute the bit representation of the assignment 
00107         // and convert it to the corresponding integer
00108         while(r()) {
00109           v  |= (1 << r.val()); // due to reversed lex ordering
00110           ++r;
00111         }
00112         return v;
00113       }
00114   
00116       int varsize(void) { return ivs; }
00117       int cachesize(void) { return ics; }
00118 
00119     };
00121 }}
00122 
00123 #endif
00124 
00125 // STATISTICS: test-cpltset