Generated on Thu Mar 22 10:39:33 2012 for Gecode by doxygen 1.6.3

int.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2005
00009  *     Mikael Lagerkvist, 2006
00010  *
00011  *  Last modified:
00012  *     $Date: 2010-06-03 13:11:11 +0200 (Thu, 03 Jun 2010) $ by $Author: tack $
00013  *     $Revision: 11013 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #ifndef __GECODE_TEST_INT_HH__
00041 #define __GECODE_TEST_INT_HH__
00042 
00043 #include "test/test.hh"
00044 
00045 #include <gecode/int.hh>
00046 
00047 namespace Test {
00048 
00050   namespace Int {
00051 
00062 
00063     class Assignment {
00064     protected:
00065       int n;            
00066       Gecode::IntSet d; 
00067     public:
00069       Assignment(int n0, const Gecode::IntSet& d0);
00071       virtual bool operator()(void) const = 0;
00073       virtual void operator++(void) = 0;
00075       virtual int operator[](int i) const = 0;
00077       int size(void) const;
00079       virtual ~Assignment(void);
00080     };
00081 
00083     class CpltAssignment : public Assignment {
00084     protected:
00085       Gecode::IntSetValues* dsv; 
00086     public:
00088       CpltAssignment(int n, const Gecode::IntSet& d);
00090       virtual bool operator()(void) const;
00092       virtual void operator++(void);
00094       virtual int operator[](int i) const;
00096       virtual ~CpltAssignment(void);
00097     };
00098 
00100     class RandomAssignment : public Assignment {
00101     protected:
00102       int* vals; 
00103       int  a;    
00104 
00105       int randval(void);
00106     public:
00108       RandomAssignment(int n, const Gecode::IntSet& d, int a);
00110       virtual bool operator()(void) const;
00112       virtual void operator++(void);
00114       virtual int operator[](int i) const;
00116       virtual ~RandomAssignment(void);
00117     };
00118 
00120     class RandomMixAssignment : public Assignment {
00121     protected:
00122       int* vals; 
00123       int  a;    
00124       int _n1;   
00125       Gecode::IntSet _d1; 
00126 
00127       int randval(const Gecode::IntSet& d);
00128     public:
00130       RandomMixAssignment(int n0, const Gecode::IntSet& d0,
00131                           int n1, const Gecode::IntSet& d1, int a0);
00133       virtual bool operator()(void) const;
00135       virtual void operator++(void);
00137       virtual int operator[](int i) const;
00139       virtual ~RandomMixAssignment(void);
00140     };
00141 
00143     enum ConTestLevel {
00144       CTL_NONE,     
00145       CTL_DOMAIN,   
00146       CTL_BOUNDS_D, 
00147       CTL_BOUNDS_Z, 
00148     };
00149 
00150     class Test;
00151 
00153     class TestSpace : public Gecode::Space {
00154     public:
00156       Gecode::IntSet d;
00158       Gecode::IntVarArray x;
00160       Gecode::BoolVar b;
00162       bool reified;
00164       Test* test;
00165 
00174       TestSpace(int n, Gecode::IntSet& d0, bool r, Test* t, bool log=true);
00176       TestSpace(bool share, TestSpace& s);
00178       virtual Gecode::Space* copy(bool share);
00180       bool assigned(void) const;
00182       void post(void);
00184       bool failed(void);
00186       void rel(int i, Gecode::IntRelType irt, int n);
00188       void rel(bool sol);
00190       void assign(const Assignment& a, bool skip=false);
00192       void bound(void);
00198       void prune(int i, bool bounds_only);
00200       void prune(void);
00202       bool prune(const Assignment& a, bool testfix);
00203     };
00204 
00209     class Test : public Base {
00210     protected:
00212       int arity;
00214       Gecode::IntSet dom;
00216       bool reified;
00218       Gecode::IntConLevel icl;
00220       ConTestLevel contest;
00222       bool testsearch;
00224       bool testfix;
00225 
00226     public:
00235       Test(const std::string& s, int a, const Gecode::IntSet& d, bool r=false,
00236            Gecode::IntConLevel i=Gecode::ICL_DEF);
00245       Test(const std::string& s, int a, int min, int max, bool r=false,
00246            Gecode::IntConLevel i=Gecode::ICL_DEF);
00248       virtual Assignment* assignment(void) const;
00250       virtual bool solution(const Assignment&) const = 0;
00252       virtual bool ignore(const Assignment&) const;
00254       virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) = 0;
00256       virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
00257                         Gecode::BoolVar b);
00259       virtual bool run(void);
00261 
00262 
00263       static std::string str(Gecode::ExtensionalPropKind epk);
00265       static std::string str(Gecode::IntConLevel icl);
00267       static std::string str(Gecode::IntRelType irl);
00269       static std::string str(Gecode::BoolOpType bot);
00271       static std::string str(int i);
00273       static std::string str(const Gecode::IntArgs& i);
00275 
00276 
00277 
00278       template<class T> static bool cmp(T x, Gecode::IntRelType r, T y);
00280     };
00282 
00284     class IntConLevels {
00285     private:
00287       static const Gecode::IntConLevel icls[3];
00289       int i;
00290     public:
00292       IntConLevels(void);
00294       bool operator()(void) const;
00296       void operator++(void);
00298       Gecode::IntConLevel icl(void) const;
00299     };
00300 
00302     class IntRelTypes {
00303     private:
00305       static const Gecode::IntRelType irts[6];
00307       int i;
00308     public:
00310       IntRelTypes(void);
00312       void reset(void);
00314       bool operator()(void) const;
00316       void operator++(void);
00318       Gecode::IntRelType irt(void) const;
00319     };
00320 
00322     class BoolOpTypes {
00323     private:
00325       static const Gecode::BoolOpType bots[5];
00327       int i;
00328     public:
00330       BoolOpTypes(void);
00332       bool operator()(void) const;
00334       void operator++(void);
00336       Gecode::BoolOpType bot(void) const;
00337     };
00338 
00339   }
00340 }
00341 
00346 std::ostream& operator<<(std::ostream& os, const Test::Int::Assignment& a);
00347 
00348 #include "test/int.hpp"
00349 
00350 #endif
00351 
00352 // STATISTICS: test-int
00353