Generated on Tue Jul 27 2010 21:59:10 for Gecode by doxygen 1.7.1

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  *     Guido Tack <tack@gecode.org>
00006  *
00007  *  Contributing authors:
00008  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00009  *     David Rijsman <David.Rijsman@quintiq.com>
00010  *
00011  *  Copyright:
00012  *     David Rijsman, 2009
00013  *     Mikael Lagerkvist, 2006
00014  *     Christian Schulte, 2002
00015  *     Guido Tack, 2004
00016  *
00017  *  Last modified:
00018  *     $Date: 2010-07-13 22:35:02 +0200 (Tue, 13 Jul 2010) $ by $Author: tack $
00019  *     $Revision: 11183 $
00020  *
00021  *  This file is part of Gecode, the generic constraint
00022  *  development environment:
00023  *     http://www.gecode.org
00024  *
00025  *  Permission is hereby granted, free of charge, to any person obtaining
00026  *  a copy of this software and associated documentation files (the
00027  *  "Software"), to deal in the Software without restriction, including
00028  *  without limitation the rights to use, copy, modify, merge, publish,
00029  *  distribute, sublicense, and/or sell copies of the Software, and to
00030  *  permit persons to whom the Software is furnished to do so, subject to
00031  *  the following conditions:
00032  *
00033  *  The above copyright notice and this permission notice shall be
00034  *  included in all copies or substantial portions of the Software.
00035  *
00036  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00037  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00038  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00039  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00040  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00041  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00042  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00043  *
00044  */
00045 
00046 #ifndef __GECODE_INT_HH__
00047 #define __GECODE_INT_HH__
00048 
00049 #include <climits>
00050 #include <cfloat>
00051 #include <iostream>
00052 
00053 #include <vector>
00054 
00055 #include <gecode/kernel.hh>
00056 #include <gecode/iter.hh>
00057 
00058 /*
00059  * Configure linking
00060  *
00061  */
00062 #if !defined(GECODE_STATIC_LIBS) && \
00063     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00064 
00065 #ifdef GECODE_BUILD_INT
00066 #define GECODE_INT_EXPORT __declspec( dllexport )
00067 #else
00068 #define GECODE_INT_EXPORT __declspec( dllimport )
00069 #endif
00070 
00071 #else
00072 
00073 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00074 #define GECODE_INT_EXPORT __attribute__ ((visibility("default")))
00075 #else
00076 #define GECODE_INT_EXPORT
00077 #endif
00078 
00079 #endif
00080 
00081 // Configure auto-linking
00082 #ifndef GECODE_BUILD_INT
00083 #define GECODE_LIBRARY_NAME "Int"
00084 #include <gecode/support/auto-link.hpp>
00085 #endif
00086 
00098 #include <gecode/int/exception.hpp>
00099 
00100 namespace Gecode { namespace Int {
00101 
00109   namespace Limits {
00111     const int max =  INT_MAX - 1;
00113     const int min = -max;
00115     const int infinity = max + 1;
00117     bool valid(int n);
00119     bool valid(double n);
00121     void check(int n, const char* l);
00123     void check(double n, const char* l);
00125     void positive(int n, const char* l);
00127     void positive(double n, const char* l);
00129     void nonnegative(int n, const char* l);
00131     void nonnegative(double n, const char* l);
00133     const double double_max = 9007199254740991.0;
00135     const double double_min = -9007199254740991.0;
00137     void double_check(double n, const char* l);
00139     const double double_infinity = DBL_MAX;
00140   }
00141 
00142 }}
00143 
00144 #include <gecode/int/limits.hpp>
00145 
00146 namespace Gecode {
00147 
00148   class IntSetRanges;
00149 
00157   class IntSet : public SharedHandle {
00158     friend class IntSetRanges;
00159   private:
00161     class Range {
00162     public:
00163       int min, max;
00164     };
00165     class IntSetObject : public SharedHandle::Object {
00166     public:
00168       unsigned int size;
00170       int n;
00172       Range* r;
00174       GECODE_INT_EXPORT static IntSetObject* allocate(int m);
00176       GECODE_INT_EXPORT SharedHandle::Object* copy(void) const;
00178       GECODE_INT_EXPORT bool in(int n) const;
00180       GECODE_INT_EXPORT virtual ~IntSetObject(void);
00181     };
00183     class MinInc;
00185     GECODE_INT_EXPORT void normalize(Range* r, int n);
00187     GECODE_INT_EXPORT void init(int n, int m);
00189     GECODE_INT_EXPORT void init(const int r[], int n);
00191     GECODE_INT_EXPORT void init(const int r[][2], int n);
00192   public:
00194 
00195 
00196     IntSet(void);
00201     IntSet(int n, int m);
00203     IntSet(const int r[],   int n);
00209     IntSet(const int r[][2], int n);
00211     template<class I>
00212     explicit IntSet(I& i);
00213 #ifdef __INTEL_COMPILER
00214 
00215     IntSet(const IntSet& s);
00217     IntSet(IntSet& s);
00219     IntSet(const PrimArgArray<int>& i);
00221     IntSet(PrimArgArray<int>& i);
00222 #endif
00223 
00224 
00226 
00227 
00228     int ranges(void) const;
00230     int min(int i) const;
00232     int max(int i) const;
00234     unsigned int width(int i) const;
00236 
00238 
00239 
00240     bool in(int n) const;
00242     unsigned int size(void) const;
00244     unsigned int width(void) const;
00246     int min(void) const;
00248     int max(void) const;
00250 
00252 
00253 
00254     GECODE_INT_EXPORT static const IntSet empty;
00256   };
00257 
00263   class IntSetRanges {
00264   private:
00266     const IntSet::Range* i;
00268     const IntSet::Range* e;
00269   public:
00271 
00272 
00273     IntSetRanges(void);
00275     IntSetRanges(const IntSet& s);
00277     void init(const IntSet& s);
00279 
00281 
00282 
00283     bool operator ()(void) const;
00285     void operator ++(void);
00287 
00289 
00290 
00291     int min(void) const;
00293     int max(void) const;
00295     unsigned int width(void) const;
00297   };
00298 
00304   class IntSetValues : public Iter::Ranges::ToValues<IntSetRanges> {
00305   public:
00307 
00308 
00309     IntSetValues(void);
00311     IntSetValues(const IntSet& s);
00313     void init(const IntSet& s);
00315   };
00316 
00321   template<class Char, class Traits>
00322   std::basic_ostream<Char,Traits>&
00323   operator <<(std::basic_ostream<Char,Traits>& os, const IntSet& s);
00324 
00325 }
00326 
00327 #include <gecode/int/int-set-1.hpp>
00328 
00329 #include <gecode/int/var-imp.hpp>
00330 
00331 namespace Gecode {
00332 
00333   namespace Int {
00334     class IntView;
00335   }
00336 
00342   class IntVar : public Var<Int::IntVarImp> {
00343     friend class IntVarArray;
00344     friend class IntVarArgs;
00345   private:
00346     using Var<Int::IntVarImp>::x;
00353     void _init(Space& home, int min, int max);
00360     void _init(Space& home, const IntSet& d);
00361   public:
00363 
00364 
00365     IntVar(void);
00367     IntVar(const IntVar& y);
00369     IntVar(const Int::IntView& y);
00381     GECODE_INT_EXPORT IntVar(Space& home, int min, int max);
00393     GECODE_INT_EXPORT IntVar(Space& home, const IntSet& d);
00395 
00397 
00398 
00399     int min(void) const;
00401     int max(void) const;
00403     int med(void) const;
00411     int val(void) const;
00412 
00414     unsigned int size(void) const;
00416     unsigned int width(void) const;
00418     unsigned int regret_min(void) const;
00420     unsigned int regret_max(void) const;
00422 
00424 
00425 
00426     bool range(void) const;
00428     bool in(int n) const;
00430   };
00431 
00436   template<class Char, class Traits>
00437   std::basic_ostream<Char,Traits>&
00438   operator <<(std::basic_ostream<Char,Traits>& os, const IntVar& x);
00439 
00444   class IntVarRanges : public Int::IntVarImpFwd {
00445   public:
00447 
00448 
00449     IntVarRanges(void);
00451     IntVarRanges(const IntVar& x);
00453     void init(const IntVar& x);
00455   };
00456 
00461   class IntVarValues : public Iter::Ranges::ToValues<IntVarRanges> {
00462   public:
00464 
00465 
00466     IntVarValues(void);
00468     IntVarValues(const IntVar& x);
00470     void init(const IntVar& x);
00472   };
00473 
00474   namespace Int {
00475     class BoolView;
00476   }
00477 
00483   class BoolVar : public Var<Int::BoolVarImp> {
00484     friend class BoolVarArray;
00485     friend class BoolVarArgs;
00486   private:
00487     using Var<Int::BoolVarImp>::x;
00494     void _init(Space& home, int min, int max);
00495   public:
00497 
00498 
00499     BoolVar(void);
00501     BoolVar(const BoolVar& y);
00503     BoolVar(const Int::BoolView& y);
00515     GECODE_INT_EXPORT BoolVar(Space& home, int min, int max);
00517 
00519 
00520 
00521     int min(void) const;
00523     int max(void) const;
00525     int med(void) const;
00533     int val(void) const;
00534 
00536     unsigned int size(void) const;
00538     unsigned int width(void) const;
00540     unsigned int regret_min(void) const;
00542     unsigned int regret_max(void) const;
00544 
00546 
00547 
00548     bool range(void) const;
00550     bool in(int n) const;
00552 
00554 
00555 
00556     bool zero(void) const;
00558     bool one(void) const;
00560     bool none(void) const;
00562   };
00563 
00568   template<class Char, class Traits>
00569   std::basic_ostream<Char,Traits>&
00570   operator <<(std::basic_ostream<Char,Traits>& os, const BoolVar& x);
00571 
00572 }
00573 
00574 
00575 #include <gecode/int/view.hpp>
00576 #include <gecode/int/propagator.hpp>
00577 
00578 namespace Gecode {
00579 
00589 
00590   typedef ArgArray<IntSet> IntSetArgs;
00591 
00592 }
00593 
00594 #include <gecode/int/array-traits.hpp>
00595 
00596 namespace Gecode {
00597 
00599   class IntArgs : public PrimArgArray<int> {
00600   public:
00602 
00603 
00604     IntArgs(void);
00606     explicit IntArgs(int n);
00608     IntArgs(const SharedArray<int>& x);
00610     IntArgs(const std::vector<int>& x);
00612     IntArgs(int n, int e0, ...);
00614     IntArgs(int n, const int* e);
00616     IntArgs(const PrimArgArray<int>& a);
00617 
00619     static IntArgs create(int n, int start, int inc=1);
00621   };
00622 
00624   class IntVarArgs : public VarArgArray<IntVar> {
00625   public:
00627 
00628 
00629     IntVarArgs(void) {}
00631     explicit IntVarArgs(int n) : VarArgArray<IntVar>(n) {}
00633     IntVarArgs(const IntVarArgs& a) : VarArgArray<IntVar>(a) {}
00635     IntVarArgs(const VarArray<IntVar>& a) : VarArgArray<IntVar>(a) {}
00647     GECODE_INT_EXPORT
00648     IntVarArgs(Space& home, int n, int min, int max);
00660     GECODE_INT_EXPORT
00661     IntVarArgs(Space& home, int n, const IntSet& s);
00663   };
00672   class BoolVarArgs : public VarArgArray<BoolVar> {
00673   public:
00675 
00676 
00677     BoolVarArgs(void) {}
00679     explicit BoolVarArgs(int n) : VarArgArray<BoolVar>(n) {}
00681     BoolVarArgs(const BoolVarArgs& a) : VarArgArray<BoolVar>(a) {}
00683     BoolVarArgs(const VarArray<BoolVar>& a)
00684      : VarArgArray<BoolVar>(a) {}
00696     GECODE_INT_EXPORT
00697     BoolVarArgs(Space& home, int n, int min, int max);
00699   };
00701 
00717   class IntVarArray : public VarArray<IntVar> {
00718   public:
00720 
00721 
00722     IntVarArray(void);
00724     IntVarArray(Space& home, int n);
00726     IntVarArray(const IntVarArray& a);
00728     IntVarArray(Space& home, const IntVarArgs& a);
00740     GECODE_INT_EXPORT
00741     IntVarArray(Space& home, int n, int min, int max);
00753     GECODE_INT_EXPORT
00754     IntVarArray(Space& home, int n, const IntSet& s);
00756   };
00757 
00762   class BoolVarArray : public VarArray<BoolVar> {
00763   public:
00765 
00766 
00767     BoolVarArray(void);
00769     BoolVarArray(Space& home, int n);
00771     BoolVarArray(const BoolVarArray& a);
00773     BoolVarArray(Space& home, const BoolVarArgs& a);
00785     GECODE_INT_EXPORT
00786     BoolVarArray(Space& home, int n, int min, int max);
00788   };
00789 
00790 }
00791 
00792 #include <gecode/int/int-set-2.hpp>
00793 
00794 #include <gecode/int/array.hpp>
00795 
00796 namespace Gecode {
00797 
00802   enum IntRelType {
00803     IRT_EQ, 
00804     IRT_NQ, 
00805     IRT_LQ, 
00806     IRT_LE, 
00807     IRT_GQ, 
00808     IRT_GR  
00809   };
00810 
00815   enum BoolOpType {
00816     BOT_AND, 
00817     BOT_OR,  
00818     BOT_IMP, 
00819     BOT_EQV, 
00820     BOT_XOR  
00821   };
00822 
00836   enum IntConLevel {
00837     ICL_VAL, 
00838     ICL_BND, 
00839     ICL_DOM, 
00840     ICL_DEF  
00841   };
00842 
00843 
00851 
00852   GECODE_INT_EXPORT void
00853   dom(Home home, IntVar x, int n,
00854       IntConLevel icl=ICL_DEF);
00856   GECODE_INT_EXPORT void
00857   dom(Home home, const IntVarArgs& x, int n,
00858       IntConLevel icl=ICL_DEF);
00859 
00861   GECODE_INT_EXPORT void
00862   dom(Home home, IntVar x, int l, int m,
00863       IntConLevel icl=ICL_DEF);
00865   GECODE_INT_EXPORT void
00866   dom(Home home, const IntVarArgs& x, int l, int m,
00867       IntConLevel icl=ICL_DEF);
00868 
00870   GECODE_INT_EXPORT void
00871   dom(Home home, IntVar x, const IntSet& s,
00872       IntConLevel icl=ICL_DEF);
00874   GECODE_INT_EXPORT void
00875   dom(Home home, const IntVarArgs& x, const IntSet& s,
00876       IntConLevel icl=ICL_DEF);
00877 
00879   GECODE_INT_EXPORT void
00880   dom(Home home, IntVar x, int n, BoolVar b,
00881       IntConLevel icl=ICL_DEF);
00883   GECODE_INT_EXPORT void
00884   dom(Home home, IntVar x, int l, int m, BoolVar b,
00885       IntConLevel icl=ICL_DEF);
00887   GECODE_INT_EXPORT void
00888   dom(Home home, IntVar x, const IntSet& s, BoolVar b,
00889       IntConLevel icl=ICL_DEF);
00891 
00892 
00903   GECODE_INT_EXPORT void
00904   rel(Home home, IntVar x0, IntRelType r, IntVar x1,
00905       IntConLevel icl=ICL_DEF);
00912   GECODE_INT_EXPORT void
00913   rel(Home home, const IntVarArgs& x, IntRelType r, IntVar y,
00914       IntConLevel icl=ICL_DEF);
00918   GECODE_INT_EXPORT void
00919   rel(Home home, IntVar x, IntRelType r, int c,
00920       IntConLevel icl=ICL_DEF);
00924   GECODE_INT_EXPORT void
00925   rel(Home home, const IntVarArgs& x, IntRelType r, int c,
00926       IntConLevel icl=ICL_DEF);
00933   GECODE_INT_EXPORT void
00934   rel(Home home, IntVar x0, IntRelType r, IntVar x1, BoolVar b,
00935       IntConLevel icl=ICL_DEF);
00942   GECODE_INT_EXPORT void
00943   rel(Home home, IntVar x, IntRelType r, int c, BoolVar b,
00944       IntConLevel icl=ICL_DEF);
00963   GECODE_INT_EXPORT void
00964   rel(Home home, const IntVarArgs& x, IntRelType r,
00965       IntConLevel icl=ICL_DEF);
00978   GECODE_INT_EXPORT void
00979   rel(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
00980       IntConLevel icl=ICL_DEF);
00981 
00989   GECODE_INT_EXPORT void
00990   rel(Home home, BoolVar x0, IntRelType r, BoolVar x1,
00991       IntConLevel icl=ICL_DEF);
00995   GECODE_INT_EXPORT void
00996   rel(Home home, BoolVar x0, IntRelType r, BoolVar x1, BoolVar b,
00997       IntConLevel icl=ICL_DEF);
01001   GECODE_INT_EXPORT void
01002   rel(Home home, const BoolVarArgs& x, IntRelType r, BoolVar y,
01003       IntConLevel icl=ICL_DEF);
01011   GECODE_INT_EXPORT void
01012   rel(Home home, BoolVar x, IntRelType r, int n,
01013       IntConLevel icl=ICL_DEF);
01021   GECODE_INT_EXPORT void
01022   rel(Home home, BoolVar x, IntRelType r, int n, BoolVar b,
01023       IntConLevel icl=ICL_DEF);
01031   GECODE_INT_EXPORT void
01032   rel(Home home, const BoolVarArgs& x, IntRelType r, int n,
01033       IntConLevel icl=ICL_DEF);
01043   GECODE_INT_EXPORT void
01044   rel(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01045       IntConLevel icl=ICL_DEF);
01057   GECODE_INT_EXPORT void
01058   rel(Home home, const BoolVarArgs& x, IntRelType r,
01059       IntConLevel icl=ICL_DEF);
01065   GECODE_INT_EXPORT void
01066   rel(Home home, BoolVar x0, BoolOpType o, BoolVar x1, BoolVar x2,
01067       IntConLevel icl=ICL_DEF);
01076   GECODE_INT_EXPORT void
01077   rel(Home home, BoolVar x0, BoolOpType o, BoolVar x1, int n,
01078       IntConLevel icl=ICL_DEF);
01088   GECODE_INT_EXPORT void
01089   rel(Home home, BoolOpType o, const BoolVarArgs& x, BoolVar y,
01090       IntConLevel icl=ICL_DEF);
01103   GECODE_INT_EXPORT void
01104   rel(Home home, BoolOpType o, const BoolVarArgs& x, int n,
01105       IntConLevel icl=ICL_DEF);
01116   GECODE_INT_EXPORT void
01117   clause(Home home, BoolOpType o, const BoolVarArgs& x, const BoolVarArgs& y,
01118          BoolVar z, IntConLevel icl=ICL_DEF);
01132   GECODE_INT_EXPORT void
01133   clause(Home home, BoolOpType o, const BoolVarArgs& x, const BoolVarArgs& y,
01134          int n, IntConLevel icl=ICL_DEF);
01135 
01136 
01143 
01144   typedef SharedArray<int> IntSharedArray;
01150   GECODE_INT_EXPORT void
01151   element(Home home, IntSharedArray n, IntVar x0, IntVar x1,
01152           IntConLevel icl=ICL_DEF);
01158   GECODE_INT_EXPORT void
01159   element(Home home, IntSharedArray n, IntVar x0, BoolVar x1,
01160           IntConLevel icl=ICL_DEF);
01166   GECODE_INT_EXPORT void
01167   element(Home home, IntSharedArray n, IntVar x0, int x1,
01168           IntConLevel icl=ICL_DEF);
01174   GECODE_INT_EXPORT void
01175   element(Home home, const IntVarArgs& x, IntVar y0, IntVar y1,
01176           IntConLevel icl=ICL_DEF);
01182   GECODE_INT_EXPORT void
01183   element(Home home, const IntVarArgs& x, IntVar y0, int y1,
01184           IntConLevel icl=ICL_DEF);
01186   GECODE_INT_EXPORT void
01187   element(Home home, const BoolVarArgs& x, IntVar y0, BoolVar y1,
01188           IntConLevel icl=ICL_DEF);
01190   GECODE_INT_EXPORT void
01191   element(Home home, const BoolVarArgs& x, IntVar y0, int y1,
01192           IntConLevel icl=ICL_DEF);
01193 
01202   GECODE_INT_EXPORT void
01203   element(Home home, IntSharedArray a, 
01204           IntVar x, int w, IntVar y, int h, IntVar z,
01205           IntConLevel icl=ICL_DEF);
01214   GECODE_INT_EXPORT void
01215   element(Home home, IntSharedArray a, 
01216           IntVar x, int w, IntVar y, int h, BoolVar z,
01217           IntConLevel icl=ICL_DEF);
01229   GECODE_INT_EXPORT void
01230   element(Home home, const IntVarArgs& a, 
01231           IntVar x, int w, IntVar y, int h, IntVar z,
01232           IntConLevel icl=ICL_DEF);
01241   GECODE_INT_EXPORT void
01242   element(Home home, const BoolVarArgs& a, 
01243           IntVar x, int w, IntVar y, int h, BoolVar z,
01244           IntConLevel icl=ICL_DEF);
01246 
01247 
01262   GECODE_INT_EXPORT void
01263   distinct(Home home, const IntVarArgs& x,
01264            IntConLevel icl=ICL_DEF);
01277   GECODE_INT_EXPORT void
01278   distinct(Home home, const IntArgs& n, const IntVarArgs& x,
01279            IntConLevel icl=ICL_DEF);
01281 
01282 
01300   GECODE_INT_EXPORT void
01301   channel(Home home, const IntVarArgs& x, const IntVarArgs& y,
01302           IntConLevel icl=ICL_DEF);
01303 
01317   GECODE_INT_EXPORT void
01318   channel(Home home, const IntVarArgs& x, int xoff,
01319           const IntVarArgs& y, int yoff,
01320           IntConLevel icl=ICL_DEF);
01321 
01323   GECODE_INT_EXPORT void
01324   channel(Home home, BoolVar x0, IntVar x1,
01325           IntConLevel icl=ICL_DEF);
01327   forceinline void
01328   channel(Home home, IntVar x0, BoolVar x1,
01329           IntConLevel icl=ICL_DEF) {
01330     channel(home,x1,x0,icl);
01331   }
01337   GECODE_INT_EXPORT void
01338   channel(Home home, const BoolVarArgs& x, IntVar y, int o=0,
01339           IntConLevel icl=ICL_DEF);
01341 
01342 
01359   GECODE_INT_EXPORT void
01360   sorted(Home home, const IntVarArgs& x, const IntVarArgs& y,
01361          IntConLevel icl=ICL_DEF);
01362 
01374   GECODE_INT_EXPORT void
01375   sorted(Home home, const IntVarArgs& x, const IntVarArgs& y,
01376          const IntVarArgs& z,
01377          IntConLevel icl=ICL_DEF);
01379 
01380 
01399   GECODE_INT_EXPORT void
01400   count(Home home, const IntVarArgs& x, int n, IntRelType r, int m,
01401         IntConLevel icl=ICL_DEF);
01406   GECODE_INT_EXPORT void
01407   count(Home home, const IntVarArgs& x, IntVar y, IntRelType r, int m,
01408         IntConLevel icl=ICL_DEF);
01416   GECODE_INT_EXPORT void
01417   count(Home home, const IntVarArgs& x, const IntArgs& y, IntRelType r, int m,
01418         IntConLevel icl=ICL_DEF);
01423   GECODE_INT_EXPORT void
01424   count(Home home, const IntVarArgs& x, int n, IntRelType r, IntVar z,
01425         IntConLevel icl=ICL_DEF);
01430   GECODE_INT_EXPORT void
01431   count(Home home, const IntVarArgs& x, IntVar y, IntRelType r, IntVar z,
01432         IntConLevel icl=ICL_DEF);
01440   GECODE_INT_EXPORT void
01441   count(Home home, const IntVarArgs& x, const IntArgs& y, IntRelType r, IntVar z,
01442         IntConLevel icl=ICL_DEF);
01443 
01457   GECODE_INT_EXPORT void
01458   count(Home home, const IntVarArgs& x, const IntVarArgs& c,
01459         IntConLevel icl=ICL_DEF);
01460 
01474   GECODE_INT_EXPORT void
01475   count(Home home, const IntVarArgs& x, const IntSetArgs& c,
01476         IntConLevel icl=ICL_DEF);
01477 
01494   GECODE_INT_EXPORT void
01495   count(Home home, const IntVarArgs& x,
01496         const IntVarArgs& c, const IntArgs& v,
01497         IntConLevel icl=ICL_DEF);
01498 
01515   GECODE_INT_EXPORT void
01516   count(Home home, const IntVarArgs& x,
01517         const IntSetArgs& c, const IntArgs& v,
01518         IntConLevel icl=ICL_DEF);
01519 
01536   GECODE_INT_EXPORT void
01537   count(Home home, const IntVarArgs& x,
01538         const IntSet& c, const IntArgs& v,
01539         IntConLevel icl=ICL_DEF);
01540 
01542 
01563   GECODE_INT_EXPORT void
01564   sequence(Home home, const IntVarArgs& x, const IntSet& s, 
01565            int q, int l, int u, IntConLevel icl=ICL_DEF); 
01566   
01581   GECODE_INT_EXPORT void
01582   sequence(Home home, const BoolVarArgs& x, const IntSet& s, 
01583            int q, int l, int u, IntConLevel icl=ICL_DEF); 
01584 
01586 
01599 
01607   class DFA : public SharedHandle {
01608   private:
01610     class DFAI;
01611   public:
01613     class Transition {
01614     public:
01615       int i_state; 
01616       int symbol;  
01617       int o_state; 
01618     };
01620     class Transitions {
01621     private:
01623       const Transition* c_trans;
01625       const Transition* e_trans;
01626     public:
01628       Transitions(const DFA& d);
01630       Transitions(const DFA& d, int n);
01632       bool operator ()(void) const;
01634       void operator ++(void);
01636       int i_state(void) const;
01638       int symbol(void) const;
01640       int o_state(void) const;
01641     };
01643     class Symbols {
01644     private:
01646       const Transition* c_trans;
01648       const Transition* e_trans;
01649     public:
01651       Symbols(const DFA& d);
01653       bool operator ()(void) const;
01655       void operator ++(void);
01657       int val(void) const;
01658     };
01659   public:
01660     friend class Transitions;
01662     DFA(void);
01674     GECODE_INT_EXPORT
01675     DFA(int s, Transition t[], int f[], bool minimize=true);
01677     DFA(const DFA& d);
01679     int n_states(void) const;
01681     int n_transitions(void) const;
01683     unsigned int n_symbols(void) const;
01685     unsigned int max_degree(void) const;
01687     int final_fst(void) const;
01689     int final_lst(void) const;
01691     int symbol_min(void) const;
01693     int symbol_max(void) const;
01694   };
01695 
01696 
01704   enum ExtensionalPropKind {
01705     EPK_DEF,    
01706     EPK_SPEED,  
01707     EPK_MEMORY  
01708   };
01709 
01720   GECODE_INT_EXPORT void
01721   extensional(Home home, const IntVarArgs& x, DFA d,
01722               IntConLevel icl=ICL_DEF);
01723 
01734   GECODE_INT_EXPORT void
01735   extensional(Home home, const BoolVarArgs& x, DFA d,
01736               IntConLevel icl=ICL_DEF);
01737 
01744   class TupleSet : public SharedHandle {
01745   public:
01750     typedef int* Tuple;
01751 
01756     class GECODE_VTABLE_EXPORT TupleSetI
01757       : public SharedHandle::Object {
01758     public:
01760       int arity;
01762       int size;
01764       Tuple** tuples;
01766       Tuple* tuple_data;
01768       int* data;
01770       int excess;
01772       int min, max;
01774       unsigned int domsize;
01776       Tuple** last;
01778       Tuple* nullpointer;
01779 
01781       template<class T>
01782       void add(T t);
01784       GECODE_INT_EXPORT void finalize(void);
01786       GECODE_INT_EXPORT void resize(void);
01788       bool finalized(void) const;
01790       TupleSetI(void);
01792       GECODE_INT_EXPORT virtual ~TupleSetI(void);
01794       GECODE_INT_EXPORT virtual SharedHandle::Object* copy(void) const;
01795     };
01796     
01798     TupleSetI* implementation(void);
01799 
01801     TupleSet(void);
01803     TupleSet(const TupleSet& d);
01804 
01806     void add(const IntArgs& tuple);
01808     void finalize(void);
01810     bool finalized(void) const;
01812     int arity(void) const;
01814     int tuples(void) const;
01816     Tuple operator [](int i) const;
01818     int min(void) const;
01820     int max(void) const;
01821   };
01822 
01841   GECODE_INT_EXPORT void
01842   extensional(Home home, const IntVarArgs& x, const TupleSet& t,
01843               ExtensionalPropKind epk=EPK_DEF, IntConLevel icl=ICL_DEF);
01844 
01855   GECODE_INT_EXPORT void
01856   extensional(Home home, const BoolVarArgs& x, const TupleSet& t,
01857               ExtensionalPropKind epk=EPK_DEF, IntConLevel icl=ICL_DEF);
01859 
01860 }
01861 
01862 #include <gecode/int/extensional/dfa.hpp>
01863 #include <gecode/int/extensional/tuple-set.hpp>
01864 
01865 namespace Gecode {
01866 
01878   GECODE_INT_EXPORT void
01879   min(Home home, IntVar x0, IntVar x1, IntVar x2,
01880       IntConLevel icl=ICL_DEF);
01888   GECODE_INT_EXPORT void
01889   min(Home home, const IntVarArgs& x, IntVar y,
01890       IntConLevel icl=ICL_DEF);
01896   GECODE_INT_EXPORT void
01897   max(Home home, IntVar x0, IntVar x1, IntVar x2,
01898       IntConLevel icl=ICL_DEF);
01906   GECODE_INT_EXPORT void
01907   max(Home home, const IntVarArgs& x, IntVar y,
01908       IntConLevel icl=ICL_DEF);
01909 
01915   GECODE_INT_EXPORT void
01916   abs(Home home, IntVar x0, IntVar x1,
01917       IntConLevel icl=ICL_DEF);
01918 
01924   GECODE_INT_EXPORT void
01925   mult(Home home, IntVar x0, IntVar x1, IntVar x2,
01926        IntConLevel icl=ICL_DEF);
01927 
01933   GECODE_INT_EXPORT void
01934   sqr(Home home, IntVar x0, IntVar x1,
01935       IntConLevel icl=ICL_DEF);
01936 
01942   GECODE_INT_EXPORT void
01943   sqrt(Home home, IntVar x0, IntVar x1,
01944        IntConLevel icl=ICL_DEF);
01945 
01950   GECODE_INT_EXPORT void
01951   divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3,
01952          IntConLevel icl=ICL_DEF);
01953 
01958   GECODE_INT_EXPORT void
01959   div(Home home, IntVar x0, IntVar x1, IntVar x2,
01960       IntConLevel icl=ICL_DEF);
01961 
01966   GECODE_INT_EXPORT void
01967   mod(Home home, IntVar x0, IntVar x1, IntVar x2,
01968       IntConLevel icl=ICL_DEF);
01970 
02002   GECODE_INT_EXPORT void
02003   linear(Home home, const IntVarArgs& x,
02004          IntRelType r, int c,
02005          IntConLevel icl=ICL_DEF);
02009   GECODE_INT_EXPORT void
02010   linear(Home home, const IntVarArgs& x,
02011          IntRelType r, IntVar y,
02012          IntConLevel icl=ICL_DEF);
02016   GECODE_INT_EXPORT void
02017   linear(Home home, const IntVarArgs& x,
02018          IntRelType r, int c, BoolVar b,
02019          IntConLevel icl=ICL_DEF);
02023   GECODE_INT_EXPORT void
02024   linear(Home home, const IntVarArgs& x,
02025          IntRelType r, IntVar y, BoolVar b,
02026          IntConLevel icl=ICL_DEF);
02033   GECODE_INT_EXPORT void
02034   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02035          IntRelType r, int c,
02036          IntConLevel icl=ICL_DEF);
02043   GECODE_INT_EXPORT void
02044   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02045          IntRelType r, IntVar y,
02046          IntConLevel icl=ICL_DEF);
02053   GECODE_INT_EXPORT void
02054   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02055          IntRelType r, int c, BoolVar b,
02056          IntConLevel icl=ICL_DEF);
02063   GECODE_INT_EXPORT void
02064   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02065          IntRelType r, IntVar y, BoolVar b,
02066          IntConLevel icl=ICL_DEF);
02067 
02068 
02096   GECODE_INT_EXPORT void
02097   linear(Home home, const BoolVarArgs& x,
02098          IntRelType r, int c,
02099          IntConLevel icl=ICL_DEF);
02103   GECODE_INT_EXPORT void
02104   linear(Home home, const BoolVarArgs& x,
02105          IntRelType r, int c, BoolVar b,
02106          IntConLevel icl=ICL_DEF);
02110   GECODE_INT_EXPORT void
02111   linear(Home home, const BoolVarArgs& x,
02112          IntRelType r, IntVar y,
02113          IntConLevel icl=ICL_DEF);
02117   GECODE_INT_EXPORT void
02118   linear(Home home, const BoolVarArgs& x,
02119          IntRelType r, IntVar y, BoolVar b,
02120          IntConLevel icl=ICL_DEF);
02127   GECODE_INT_EXPORT void
02128   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02129          IntRelType r, int c,
02130          IntConLevel icl=ICL_DEF);
02137   GECODE_INT_EXPORT void
02138   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02139          IntRelType r, int c, BoolVar b,
02140          IntConLevel icl=ICL_DEF);
02147   GECODE_INT_EXPORT void
02148   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02149          IntRelType r, IntVar y,
02150          IntConLevel icl=ICL_DEF);
02157   GECODE_INT_EXPORT void
02158   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02159          IntRelType r, IntVar y, BoolVar b,
02160          IntConLevel icl=ICL_DEF);
02161 
02162 
02163 
02172 
02173   GECODE_INT_EXPORT void
02174   wait(Home home, IntVar x, void (*c)(Space& home),
02175        IntConLevel icl=ICL_DEF);
02177   GECODE_INT_EXPORT void
02178   wait(Home home, BoolVar x, void (*c)(Space& home),
02179        IntConLevel icl=ICL_DEF);
02181   GECODE_INT_EXPORT void
02182   wait(Home home, const IntVarArgs& x, void (*c)(Space& home),
02183        IntConLevel icl=ICL_DEF);
02185   GECODE_INT_EXPORT void
02186   wait(Home home, const BoolVarArgs& x, void (*c)(Space& home),
02187        IntConLevel icl=ICL_DEF);
02189   GECODE_INT_EXPORT void
02190   when(Home home, BoolVar x, 
02191        void (*t)(Space& home), void (*e)(Space& home)= NULL,
02192        IntConLevel icl=ICL_DEF);
02194 
02195 
02220   GECODE_INT_EXPORT void
02221   unshare(Home home, IntVarArgs& x,
02222           IntConLevel icl=ICL_DEF);
02224   GECODE_INT_EXPORT void
02225   unshare(Home home, BoolVarArgs& x,
02226           IntConLevel icl=ICL_DEF);
02228 
02229 
02235 
02236   enum IntVarBranch {
02237     INT_VAR_NONE = 0,        
02238     INT_VAR_RND,             
02239     INT_VAR_DEGREE_MIN,      
02240     INT_VAR_DEGREE_MAX,      
02241     INT_VAR_AFC_MIN,         
02242     INT_VAR_AFC_MAX,         
02243     INT_VAR_MIN_MIN,         
02244     INT_VAR_MIN_MAX,         
02245     INT_VAR_MAX_MIN,         
02246     INT_VAR_MAX_MAX,         
02247     INT_VAR_SIZE_MIN,        
02248     INT_VAR_SIZE_MAX,        
02249     INT_VAR_SIZE_DEGREE_MIN, 
02250     INT_VAR_SIZE_DEGREE_MAX, 
02251     INT_VAR_SIZE_AFC_MIN,    
02252     INT_VAR_SIZE_AFC_MAX,    
02253 
02258     INT_VAR_REGRET_MIN_MIN,
02264     INT_VAR_REGRET_MIN_MAX,
02270     INT_VAR_REGRET_MAX_MIN,
02276     INT_VAR_REGRET_MAX_MAX
02277   };
02278 
02280   enum IntValBranch {
02281     INT_VAL_MIN,       
02282     INT_VAL_MED,       
02283     INT_VAL_MAX,       
02284     INT_VAL_RND,       
02285     INT_VAL_SPLIT_MIN, 
02286     INT_VAL_SPLIT_MAX, 
02287     INT_VAL_RANGE_MIN, 
02288     INT_VAL_RANGE_MAX, 
02289     INT_VALUES_MIN,    
02290     INT_VALUES_MAX     
02291   };
02292 
02294   GECODE_INT_EXPORT void
02295   branch(Home home, const IntVarArgs& x,
02296          IntVarBranch vars, IntValBranch vals,
02297          const VarBranchOptions& o_vars = VarBranchOptions::def,
02298          const ValBranchOptions& o_vals = ValBranchOptions::def);
02300   GECODE_INT_EXPORT void
02301   branch(Home home, const IntVarArgs& x,
02302          const TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals,
02303          const TieBreakVarBranchOptions& o_vars = TieBreakVarBranchOptions::def,
02304          const ValBranchOptions& o_vals = ValBranchOptions::def);
02306   GECODE_INT_EXPORT void
02307   branch(Home home, IntVar x, IntValBranch vals,
02308          const ValBranchOptions& o_vals = ValBranchOptions::def);
02310   GECODE_INT_EXPORT void
02311   branch(Home home, const BoolVarArgs& x,
02312          IntVarBranch vars, IntValBranch vals,
02313          const VarBranchOptions& o_vars = VarBranchOptions::def,
02314          const ValBranchOptions& o_vals = ValBranchOptions::def);
02316   GECODE_INT_EXPORT void
02317   branch(Home home, const BoolVarArgs& x,
02318          const TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals,
02319          const TieBreakVarBranchOptions& o_vars = TieBreakVarBranchOptions::def,
02320          const ValBranchOptions& o_vals = ValBranchOptions::def);
02322   GECODE_INT_EXPORT void
02323   branch(Home home, BoolVar x, IntValBranch vals,
02324          const ValBranchOptions& o_vals = ValBranchOptions::def);
02325 
02327 
02333 
02334   enum IntAssign {
02335     INT_ASSIGN_MIN, 
02336     INT_ASSIGN_MED, 
02337     INT_ASSIGN_MAX, 
02338     INT_ASSIGN_RND  
02339   };
02340 
02342   GECODE_INT_EXPORT void
02343   assign(Home home, const IntVarArgs& x, IntAssign vals,
02344          const ValBranchOptions& o_vals = ValBranchOptions::def);
02346   GECODE_INT_EXPORT void
02347   assign(Home home, IntVar x, IntAssign vals,
02348          const ValBranchOptions& o_vals = ValBranchOptions::def);
02350   GECODE_INT_EXPORT void
02351   assign(Home home, const BoolVarArgs& x, IntAssign vals,
02352          const ValBranchOptions& o_vals = ValBranchOptions::def);
02354   GECODE_INT_EXPORT void
02355   assign(Home home, BoolVar x, IntAssign vals,
02356          const ValBranchOptions& o_vals = ValBranchOptions::def);
02357 
02359 
02363   template<class Char, class Traits>
02364   std::basic_ostream<Char,Traits>&
02365   operator <<(std::basic_ostream<Char,Traits>& os, const DFA& d);
02366 
02370   template<class Char, class Traits>
02371   std::basic_ostream<Char,Traits>&
02372   operator <<(std::basic_ostream<Char,Traits>& os, const TupleSet& ts);
02373 
02374 }
02375 
02376 #endif
02377 
02378 // IFDEF: GECODE_HAS_INT_VARS
02379 // STATISTICS: int-post
02380