Generated on Mon Nov 30 23:53:20 2009 for Gecode by doxygen 1.6.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  *
00010  *  Copyright:
00011  *     Mikael Lagerkvist, 2006
00012  *     Christian Schulte, 2002
00013  *     Guido Tack, 2004
00014  *
00015  *  Last modified:
00016  *     $Date: 2009-11-03 11:29:41 +0100 (Tue, 03 Nov 2009) $ by $Author: schulte $
00017  *     $Revision: 10026 $
00018  *
00019  *  This file is part of Gecode, the generic constraint
00020  *  development environment:
00021  *     http://www.gecode.org
00022  *
00023  *  Permission is hereby granted, free of charge, to any person obtaining
00024  *  a copy of this software and associated documentation files (the
00025  *  "Software"), to deal in the Software without restriction, including
00026  *  without limitation the rights to use, copy, modify, merge, publish,
00027  *  distribute, sublicense, and/or sell copies of the Software, and to
00028  *  permit persons to whom the Software is furnished to do so, subject to
00029  *  the following conditions:
00030  *
00031  *  The above copyright notice and this permission notice shall be
00032  *  included in all copies or substantial portions of the Software.
00033  *
00034  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00035  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00036  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00037  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00038  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00039  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00040  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00041  *
00042  */
00043 
00044 #ifndef __GECODE_INT_HH__
00045 #define __GECODE_INT_HH__
00046 
00047 #include <climits>
00048 #include <iostream>
00049 
00050 #include <gecode/kernel.hh>
00051 #include <gecode/iter.hh>
00052 
00053 /*
00054  * Configure linking
00055  *
00056  */
00057 #if !defined(GECODE_STATIC_LIBS) && \
00058     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00059 
00060 #ifdef GECODE_BUILD_INT
00061 #define GECODE_INT_EXPORT __declspec( dllexport )
00062 #else
00063 #define GECODE_INT_EXPORT __declspec( dllimport )
00064 #endif
00065 
00066 #else
00067 
00068 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00069 #define GECODE_INT_EXPORT __attribute__ ((visibility("default")))
00070 #else
00071 #define GECODE_INT_EXPORT
00072 #endif
00073 
00074 #endif
00075 
00076 // Configure auto-linking
00077 #ifndef GECODE_BUILD_INT
00078 #define GECODE_LIBRARY_NAME "Int"
00079 #include <gecode/support/auto-link.hpp>
00080 #endif
00081 
00093 #include <gecode/int/exception.hpp>
00094 
00095 namespace Gecode { namespace Int {
00096 
00104   namespace Limits {
00106     const int max =  INT_MAX - 1;
00108     const int min = -max;
00110     const int infinity = max + 1;
00112     void check(int n, const char* l);
00114     void check(double n, const char* l);
00116     void positive(int n, const char* l);
00118     void positive(double n, const char* l);
00119   }
00120 
00121 }}
00122 
00123 #include <gecode/int/limits.hpp>
00124 
00125 namespace Gecode {
00126 
00127   class IntSetRanges;
00128 
00136   class IntSet : public SharedHandle {
00137     friend class IntSetRanges;
00138   private:
00140     class Range {
00141     public:
00142       int min, max;
00143     };
00144     class IntSetObject : public SharedHandle::Object {
00145     public:
00147       unsigned int size;
00149       int n;
00151       Range* r;
00153       GECODE_INT_EXPORT static IntSetObject* allocate(int m);
00155       GECODE_INT_EXPORT SharedHandle::Object* copy(void) const;
00157       GECODE_INT_EXPORT virtual ~IntSetObject(void);
00158     };
00160     class MinInc;
00162     GECODE_INT_EXPORT void normalize(Range* r, int n);
00164     GECODE_INT_EXPORT void init(int n, int m);
00166     GECODE_INT_EXPORT void init(const int r[], int n);
00168     GECODE_INT_EXPORT void init(const int r[][2], int n);
00169   public:
00171 
00172 
00173     IntSet(void);
00178     IntSet(int n, int m);
00180     IntSet(const int r[],   int n);
00186     IntSet(const int r[][2], int n);
00188     template<class I>
00189     explicit IntSet(I& i);
00190 #ifdef __INTEL_COMPILER
00192     IntSet(const IntSet& s);
00194     IntSet(IntSet& s);
00196     IntSet(const PrimArgArray<int>& i);
00198     IntSet(PrimArgArray<int>& i);
00199 #endif
00200 
00201 
00203 
00204 
00205     int ranges(void) const;
00207     int min(int i) const;
00209     int max(int i) const;
00211     unsigned int width(int i) const;
00213 
00215 
00216 
00217     unsigned int size(void) const;
00219     unsigned int width(void) const;
00221     int min(void) const;
00223     int max(void) const;
00225 
00227 
00228 
00229     GECODE_INT_EXPORT static const IntSet empty;
00231   };
00232 
00238   class IntSetRanges {
00239   private:
00241     const IntSet::Range* i;
00243     const IntSet::Range* e;
00244   public:
00246 
00247 
00248     IntSetRanges(void);
00250     IntSetRanges(const IntSet& s);
00252     void init(const IntSet& s);
00254 
00256 
00257 
00258     bool operator ()(void) const;
00260     void operator ++(void);
00262 
00264 
00265 
00266     int min(void) const;
00268     int max(void) const;
00270     unsigned int width(void) const;
00272   };
00273 
00279   class IntSetValues : public Iter::Ranges::ToValues<IntSetRanges> {
00280   public:
00282 
00283 
00284     IntSetValues(void);
00286     IntSetValues(const IntSet& s);
00288     void init(const IntSet& s);
00290   };
00291 
00296   template<class Char, class Traits>
00297   std::basic_ostream<Char,Traits>&
00298   operator <<(std::basic_ostream<Char,Traits>& os, const IntSet& s);
00299 
00300 }
00301 
00302 #include <gecode/int/int-set-1.hpp>
00303 
00304 #include <gecode/int/var-imp.hpp>
00305 
00306 namespace Gecode {
00307 
00308   namespace Int {
00309     class IntView;
00310   }
00311 
00317   class IntVar : public VarBase<Int::IntVarImp> {
00318     friend class IntVarArray;
00319   private:
00320     using VarBase<Int::IntVarImp>::varimp;
00327     void _init(Space& home, int min, int max);
00334     void _init(Space& home, const IntSet& d);
00335   public:
00337 
00338 
00339     IntVar(void);
00341     IntVar(const IntVar& x);
00343     IntVar(const Int::IntView& x);
00355     GECODE_INT_EXPORT IntVar(Space& home, int min ,int max);
00367     GECODE_INT_EXPORT IntVar(Space& home, const IntSet& d);
00379     GECODE_INT_EXPORT void init(Space& home, int min, int max);
00391     GECODE_INT_EXPORT void init(Space& home, const IntSet& d);
00393 
00395 
00396 
00397     int min(void) const;
00399     int max(void) const;
00401     int med(void) const;
00409     int val(void) const;
00410 
00412     unsigned int size(void) const;
00414     unsigned int width(void) const;
00416     unsigned int regret_min(void) const;
00418     unsigned int regret_max(void) const;
00420 
00422 
00423 
00424     bool range(void) const;
00426     bool assigned(void) const;
00427 
00429     bool in(int n) const;
00431 
00433 
00434 
00435     void update(Space& home, bool share, IntVar& x);
00437   };
00438 
00443   template<class Char, class Traits>
00444   std::basic_ostream<Char,Traits>&
00445   operator <<(std::basic_ostream<Char,Traits>& os, const IntVar& x);
00446 
00451   class IntVarRanges : public Int::IntVarImpFwd {
00452   public:
00454 
00455 
00456     IntVarRanges(void);
00458     IntVarRanges(const IntVar& x);
00460     void init(const IntVar& x);
00462   };
00463 
00468   class IntVarValues : public Iter::Ranges::ToValues<IntVarRanges> {
00469   public:
00471 
00472 
00473     IntVarValues(void);
00475     IntVarValues(const IntVar& x);
00477     void init(const IntVar& x);
00479   };
00480 
00481   namespace Int {
00482     class BoolView;
00483   }
00484 
00490   class BoolVar : public VarBase<Int::BoolVarImp> {
00491     friend class BoolVarArray;
00492   private:
00493     using VarBase<Int::BoolVarImp>::varimp;
00500     void _init(Space& home, int min, int max);
00501   public:
00503 
00504 
00505     BoolVar(void);
00507     BoolVar(const BoolVar& x);
00509     BoolVar(const Int::BoolView& x);
00521     GECODE_INT_EXPORT BoolVar(Space& home, int min, int max);
00533     GECODE_INT_EXPORT void init(Space& home, int min, int max);
00535 
00537 
00538 
00539     int min(void) const;
00541     int max(void) const;
00543     int med(void) const;
00551     int val(void) const;
00552 
00554     unsigned int size(void) const;
00556     unsigned int width(void) const;
00558     unsigned int regret_min(void) const;
00560     unsigned int regret_max(void) const;
00562 
00564 
00565 
00566     bool range(void) const;
00568     bool assigned(void) const;
00569 
00571     bool in(int n) const;
00573 
00575 
00576 
00577     bool zero(void) const;
00579     bool one(void) const;
00581     bool none(void) const;
00583 
00585 
00586 
00587     void update(Space& home, bool share, BoolVar& x);
00589 
00590   };
00591 
00596   template<class Char, class Traits>
00597   std::basic_ostream<Char,Traits>&
00598   operator <<(std::basic_ostream<Char,Traits>& os, const BoolVar& x);
00599 
00600 }
00601 
00602 
00603 #include <gecode/int/view.hpp>
00604 #include <gecode/int/propagator.hpp>
00605 
00606 namespace Gecode {
00607 
00617 
00618   typedef PrimArgArray<int>    IntArgs;
00627   class IntVarArgs : public VarArgArray<IntVar> {
00628   public:
00630 
00631 
00632     explicit IntVarArgs(int n) : VarArgArray<IntVar>(n) {}
00634     IntVarArgs(const IntVarArgs& a) : VarArgArray<IntVar>(a) {}
00636     IntVarArgs(const VarArray<IntVar>& a) : VarArgArray<IntVar>(a) {}
00638   };
00647   class BoolVarArgs : public VarArgArray<BoolVar> {
00648   public:
00650 
00651 
00652     explicit BoolVarArgs(int n) : VarArgArray<BoolVar>(n) {}
00654     BoolVarArgs(const BoolVarArgs& a) : VarArgArray<BoolVar>(a) {}
00656     BoolVarArgs(const VarArray<BoolVar>& a) : VarArgArray<BoolVar>(a) {}
00658   };
00660   typedef ArgArray<IntSet> IntSetArgs;
00662 
00678   class IntVarArray : public VarArray<IntVar> {
00679   public:
00681 
00682 
00683     IntVarArray(void);
00685     IntVarArray(Space& home, int n);
00687     IntVarArray(const IntVarArray& a);
00699     GECODE_INT_EXPORT
00700     IntVarArray(Space& home, int n, int min, int max);
00712     GECODE_INT_EXPORT
00713     IntVarArray(Space& home, int n, const IntSet& s);
00715   };
00716 
00721   class BoolVarArray : public VarArray<BoolVar> {
00722   public:
00724 
00725 
00726     BoolVarArray(void);
00728     BoolVarArray(Space& home, int n);
00730     BoolVarArray(const BoolVarArray& a);
00742     GECODE_INT_EXPORT
00743     BoolVarArray(Space& home, int n, int min, int max);
00745   };
00746 
00747 }
00748 
00749 #include <gecode/int/int-set-2.hpp>
00750 
00751 #include <gecode/int/array.hpp>
00752 
00753 namespace Gecode {
00754 
00759   enum IntRelType {
00760     IRT_EQ, 
00761     IRT_NQ, 
00762     IRT_LQ, 
00763     IRT_LE, 
00764     IRT_GQ, 
00765     IRT_GR  
00766   };
00767 
00772   enum BoolOpType {
00773     BOT_AND, 
00774     BOT_OR,  
00775     BOT_IMP, 
00776     BOT_EQV, 
00777     BOT_XOR  
00778   };
00779 
00793   enum IntConLevel {
00794     ICL_VAL, 
00795     ICL_BND, 
00796     ICL_DOM, 
00797     ICL_DEF  
00798   };
00799 
00800 
00808 
00809   GECODE_INT_EXPORT void
00810   dom(Home home, IntVar x, int n,
00811       IntConLevel icl=ICL_DEF);
00813   GECODE_INT_EXPORT void
00814   dom(Home home, const IntVarArgs& x, int n,
00815       IntConLevel icl=ICL_DEF);
00816 
00818   GECODE_INT_EXPORT void
00819   dom(Home home, IntVar x, int l, int m,
00820       IntConLevel icl=ICL_DEF);
00822   GECODE_INT_EXPORT void
00823   dom(Home home, const IntVarArgs& x, int l, int m,
00824       IntConLevel icl=ICL_DEF);
00825 
00827   GECODE_INT_EXPORT void
00828   dom(Home home, IntVar x, const IntSet& s,
00829       IntConLevel icl=ICL_DEF);
00831   GECODE_INT_EXPORT void
00832   dom(Home home, const IntVarArgs& x, const IntSet& s,
00833       IntConLevel icl=ICL_DEF);
00834 
00836   GECODE_INT_EXPORT void
00837   dom(Home home, IntVar x, int n, BoolVar b,
00838       IntConLevel icl=ICL_DEF);
00840   GECODE_INT_EXPORT void
00841   dom(Home home, IntVar x, int l, int m, BoolVar b,
00842       IntConLevel icl=ICL_DEF);
00844   GECODE_INT_EXPORT void
00845   dom(Home home, IntVar x, const IntSet& s, BoolVar b,
00846       IntConLevel icl=ICL_DEF);
00848 
00849 
00860   GECODE_INT_EXPORT void
00861   rel(Home home, IntVar x0, IntRelType r, IntVar x1,
00862       IntConLevel icl=ICL_DEF);
00869   GECODE_INT_EXPORT void
00870   rel(Home home, const IntVarArgs& x, IntRelType r, IntVar y,
00871       IntConLevel icl=ICL_DEF);
00875   GECODE_INT_EXPORT void
00876   rel(Home home, IntVar x, IntRelType r, int c,
00877       IntConLevel icl=ICL_DEF);
00881   GECODE_INT_EXPORT void
00882   rel(Home home, const IntVarArgs& x, IntRelType r, int c,
00883       IntConLevel icl=ICL_DEF);
00890   GECODE_INT_EXPORT void
00891   rel(Home home, IntVar x0, IntRelType r, IntVar x1, BoolVar b,
00892       IntConLevel icl=ICL_DEF);
00899   GECODE_INT_EXPORT void
00900   rel(Home home, IntVar x, IntRelType r, int c, BoolVar b,
00901       IntConLevel icl=ICL_DEF);
00920   GECODE_INT_EXPORT void
00921   rel(Home home, const IntVarArgs& x, IntRelType r,
00922       IntConLevel icl=ICL_DEF);
00935   GECODE_INT_EXPORT void
00936   rel(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
00937       IntConLevel icl=ICL_DEF);
00938 
00946   GECODE_INT_EXPORT void
00947   rel(Home home, BoolVar x0, IntRelType r, BoolVar x1,
00948       IntConLevel icl=ICL_DEF);
00952   GECODE_INT_EXPORT void
00953   rel(Home home, BoolVar x0, IntRelType r, BoolVar x1, BoolVar b,
00954       IntConLevel icl=ICL_DEF);
00958   GECODE_INT_EXPORT void
00959   rel(Home home, const BoolVarArgs& x, IntRelType r, BoolVar y,
00960       IntConLevel icl=ICL_DEF);
00968   GECODE_INT_EXPORT void
00969   rel(Home home, BoolVar x, IntRelType r, int n,
00970       IntConLevel icl=ICL_DEF);
00978   GECODE_INT_EXPORT void
00979   rel(Home home, BoolVar x, IntRelType r, int n, BoolVar b,
00980       IntConLevel icl=ICL_DEF);
00988   GECODE_INT_EXPORT void
00989   rel(Home home, const BoolVarArgs& x, IntRelType r, int n,
00990       IntConLevel icl=ICL_DEF);
01000   GECODE_INT_EXPORT void
01001   rel(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01002       IntConLevel icl=ICL_DEF);
01014   GECODE_INT_EXPORT void
01015   rel(Home home, const BoolVarArgs& x, IntRelType r,
01016       IntConLevel icl=ICL_DEF);
01022   GECODE_INT_EXPORT void
01023   rel(Home home, BoolVar x0, BoolOpType o, BoolVar x1, BoolVar x2,
01024       IntConLevel icl=ICL_DEF);
01033   GECODE_INT_EXPORT void
01034   rel(Home home, BoolVar x0, BoolOpType o, BoolVar x1, int n,
01035       IntConLevel icl=ICL_DEF);
01045   GECODE_INT_EXPORT void
01046   rel(Home home, BoolOpType o, const BoolVarArgs& x, BoolVar y,
01047       IntConLevel icl=ICL_DEF);
01060   GECODE_INT_EXPORT void
01061   rel(Home home, BoolOpType o, const BoolVarArgs& x, int n,
01062       IntConLevel icl=ICL_DEF);
01073   GECODE_INT_EXPORT void
01074   clause(Home home, BoolOpType o, const BoolVarArgs& x, const BoolVarArgs& y,
01075          BoolVar z, IntConLevel icl=ICL_DEF);
01089   GECODE_INT_EXPORT void
01090   clause(Home home, BoolOpType o, const BoolVarArgs& x, const BoolVarArgs& y,
01091          int n, IntConLevel icl=ICL_DEF);
01092 
01093 
01100 
01101   typedef SharedArray<int> IntSharedArray;
01107   GECODE_INT_EXPORT void
01108   element(Home home, IntSharedArray n, IntVar x0, IntVar x1,
01109           IntConLevel icl=ICL_DEF);
01115   GECODE_INT_EXPORT void
01116   element(Home home, IntSharedArray n, IntVar x0, BoolVar x1,
01117           IntConLevel icl=ICL_DEF);
01123   GECODE_INT_EXPORT void
01124   element(Home home, IntSharedArray n, IntVar x0, int x1,
01125           IntConLevel icl=ICL_DEF);
01131   GECODE_INT_EXPORT void
01132   element(Home home, const IntVarArgs& x, IntVar y0, IntVar y1,
01133           IntConLevel icl=ICL_DEF);
01139   GECODE_INT_EXPORT void
01140   element(Home home, const IntVarArgs& x, IntVar y0, int y1,
01141           IntConLevel icl=ICL_DEF);
01143   GECODE_INT_EXPORT void
01144   element(Home home, const BoolVarArgs& x, IntVar y0, BoolVar y1,
01145           IntConLevel icl=ICL_DEF);
01147   GECODE_INT_EXPORT void
01148   element(Home home, const BoolVarArgs& x, IntVar y0, int y1,
01149           IntConLevel icl=ICL_DEF);
01150 
01159   GECODE_INT_EXPORT void
01160   element(Home home, IntSharedArray a, 
01161           IntVar x, int w, IntVar y, int h, IntVar z,
01162           IntConLevel icl=ICL_DEF);
01171   GECODE_INT_EXPORT void
01172   element(Home home, IntSharedArray a, 
01173           IntVar x, int w, IntVar y, int h, BoolVar z,
01174           IntConLevel icl=ICL_DEF);
01186   GECODE_INT_EXPORT void
01187   element(Home home, const IntVarArgs& a, 
01188           IntVar x, int w, IntVar y, int h, IntVar z,
01189           IntConLevel icl=ICL_DEF);
01198   GECODE_INT_EXPORT void
01199   element(Home home, const BoolVarArgs& a, 
01200           IntVar x, int w, IntVar y, int h, BoolVar z,
01201           IntConLevel icl=ICL_DEF);
01203 
01204 
01219   GECODE_INT_EXPORT void
01220   distinct(Home home, const IntVarArgs& x,
01221            IntConLevel icl=ICL_DEF);
01234   GECODE_INT_EXPORT void
01235   distinct(Home home, const IntArgs& n, const IntVarArgs& x,
01236            IntConLevel icl=ICL_DEF);
01238 
01239 
01257   GECODE_INT_EXPORT void
01258   channel(Home home, const IntVarArgs& x, const IntVarArgs& y,
01259           IntConLevel icl=ICL_DEF);
01260 
01274   GECODE_INT_EXPORT void
01275   channel(Home home, const IntVarArgs& x, int xoff,
01276           const IntVarArgs& y, int yoff,
01277           IntConLevel icl=ICL_DEF);
01278 
01280   GECODE_INT_EXPORT void
01281   channel(Home home, BoolVar x0, IntVar x1,
01282           IntConLevel icl=ICL_DEF);
01284   forceinline void
01285   channel(Home home, IntVar x0, BoolVar x1,
01286           IntConLevel icl=ICL_DEF) {
01287     channel(home,x1,x0,icl);
01288   }
01294   GECODE_INT_EXPORT void
01295   channel(Home home, const BoolVarArgs& x, IntVar y, int o=0,
01296           IntConLevel icl=ICL_DEF);
01298 
01299 
01316   GECODE_INT_EXPORT void
01317   sorted(Home home, const IntVarArgs& x, const IntVarArgs& y,
01318          IntConLevel icl=ICL_DEF);
01319 
01331   GECODE_INT_EXPORT void
01332   sorted(Home home, const IntVarArgs& x, const IntVarArgs& y,
01333          const IntVarArgs& z,
01334          IntConLevel icl=ICL_DEF);
01336 
01337 
01356   GECODE_INT_EXPORT void
01357   count(Home home, const IntVarArgs& x, int n, IntRelType r, int m,
01358         IntConLevel icl=ICL_DEF);
01363   GECODE_INT_EXPORT void
01364   count(Home home, const IntVarArgs& x, IntVar y, IntRelType r, int m,
01365         IntConLevel icl=ICL_DEF);
01373   GECODE_INT_EXPORT void
01374   count(Home home, const IntVarArgs& x, const IntArgs& y, IntRelType r, int m,
01375         IntConLevel icl=ICL_DEF);
01380   GECODE_INT_EXPORT void
01381   count(Home home, const IntVarArgs& x, int n, IntRelType r, IntVar z,
01382         IntConLevel icl=ICL_DEF);
01387   GECODE_INT_EXPORT void
01388   count(Home home, const IntVarArgs& x, IntVar y, IntRelType r, IntVar z,
01389         IntConLevel icl=ICL_DEF);
01397   GECODE_INT_EXPORT void
01398   count(Home home, const IntVarArgs& x, const IntArgs& y, IntRelType r, IntVar z,
01399         IntConLevel icl=ICL_DEF);
01400 
01414   GECODE_INT_EXPORT void
01415   count(Home home, const IntVarArgs& x, const IntVarArgs& c,
01416         IntConLevel icl=ICL_DEF);
01417 
01431   GECODE_INT_EXPORT void
01432   count(Home home, const IntVarArgs& x, const IntSetArgs& c,
01433         IntConLevel icl=ICL_DEF);
01434 
01451   GECODE_INT_EXPORT void
01452   count(Home home, const IntVarArgs& x,
01453         const IntVarArgs& c, const IntArgs& v,
01454         IntConLevel icl=ICL_DEF);
01455 
01472   GECODE_INT_EXPORT void
01473   count(Home home, const IntVarArgs& x,
01474         const IntSetArgs& c, const IntArgs& v,
01475         IntConLevel icl=ICL_DEF);
01476 
01493   GECODE_INT_EXPORT void
01494   count(Home home, const IntVarArgs& x,
01495         const IntSet& c, const IntArgs& v,
01496         IntConLevel icl=ICL_DEF);
01497 
01499 
01512 
01520   class DFA : public SharedHandle {
01521   private:
01523     class DFAI;
01524   public:
01526     class Transition {
01527     public:
01528       int i_state; 
01529       int symbol;  
01530       int o_state; 
01531     };
01533     class Transitions {
01534     private:
01536       const Transition* c_trans;
01538       const Transition* e_trans;
01539     public:
01541       Transitions(const DFA& d);
01543       Transitions(const DFA& d, int n);
01545       bool operator ()(void) const;
01547       void operator ++(void);
01549       int i_state(void) const;
01551       int symbol(void) const;
01553       int o_state(void) const;
01554     };
01556     class Symbols {
01557     private:
01559       const Transition* c_trans;
01561       const Transition* e_trans;
01562     public:
01564       Symbols(const DFA& d);
01566       bool operator ()(void) const;
01568       void operator ++(void);
01570       int val(void) const;
01571     };
01572   public:
01573     friend class Transitions;
01575     DFA(void);
01587     GECODE_INT_EXPORT
01588     DFA(int s, Transition t[], int f[], bool minimize=true);
01590     DFA(const DFA& d);
01592     int n_states(void) const;
01594     int n_transitions(void) const;
01596     unsigned int n_symbols(void) const;
01598     unsigned int max_degree(void) const;
01600     int final_fst(void) const;
01602     int final_lst(void) const;
01604     int symbol_min(void) const;
01606     int symbol_max(void) const;
01607   };
01608 
01609 
01617   enum ExtensionalPropKind {
01618     EPK_DEF,    
01619     EPK_SPEED,  
01620     EPK_MEMORY  
01621   };
01622 
01633   GECODE_INT_EXPORT void
01634   extensional(Home home, const IntVarArgs& x, DFA d,
01635               IntConLevel icl=ICL_DEF);
01636 
01647   GECODE_INT_EXPORT void
01648   extensional(Home home, const BoolVarArgs& x, DFA d,
01649               IntConLevel icl=ICL_DEF);
01650 
01657   class TupleSet : public SharedHandle {
01658   public:
01663     typedef int* Tuple;
01664 
01669     class GECODE_VTABLE_EXPORT TupleSetI
01670       : public SharedHandle::Object {
01671     public:
01673       int arity;
01675       int size;
01677       Tuple** tuples;
01679       Tuple* tuple_data;
01681       int* data;
01683       int excess;
01685       int min, max;
01687       unsigned int domsize;
01689       Tuple** last;
01691       Tuple* nullpointer;
01692 
01694       template<class T>
01695       void add(T t);
01697       GECODE_INT_EXPORT void finalize(void);
01699       GECODE_INT_EXPORT void resize(void);
01701       bool finalized(void) const;
01703       TupleSetI(void);
01705       GECODE_INT_EXPORT virtual ~TupleSetI(void);
01707       GECODE_INT_EXPORT virtual SharedHandle::Object* copy(void) const;
01708     };
01709     
01711     TupleSetI* implementation(void);
01712 
01714     TupleSet(void);
01716     TupleSet(const TupleSet& d);
01717 
01719     void add(const IntArgs& tuple);
01721     void finalize(void);
01723     bool finalized(void) const;
01725     int arity(void) const;
01727     int tuples(void) const;
01729     Tuple operator [](int i) const;
01731     int min(void) const;
01733     int max(void) const;
01734   };
01735 
01754   GECODE_INT_EXPORT void
01755   extensional(Home home, const IntVarArgs& x, const TupleSet& t,
01756               ExtensionalPropKind epk=EPK_DEF, IntConLevel icl=ICL_DEF);
01757 
01768   GECODE_INT_EXPORT void
01769   extensional(Home home, const BoolVarArgs& x, const TupleSet& t,
01770               ExtensionalPropKind epk=EPK_DEF, IntConLevel icl=ICL_DEF);
01772 
01773 }
01774 
01775 #include <gecode/int/extensional/dfa.hpp>
01776 #include <gecode/int/extensional/tuple-set.hpp>
01777 
01778 namespace Gecode {
01779 
01791   GECODE_INT_EXPORT void
01792   min(Home home, IntVar x0, IntVar x1, IntVar x2,
01793       IntConLevel icl=ICL_DEF);
01801   GECODE_INT_EXPORT void
01802   min(Home home, const IntVarArgs& x, IntVar y,
01803       IntConLevel icl=ICL_DEF);
01809   GECODE_INT_EXPORT void
01810   max(Home home, IntVar x0, IntVar x1, IntVar x2,
01811       IntConLevel icl=ICL_DEF);
01819   GECODE_INT_EXPORT void
01820   max(Home home, const IntVarArgs& x, IntVar y,
01821       IntConLevel icl=ICL_DEF);
01822 
01828   GECODE_INT_EXPORT void
01829   abs(Home home, IntVar x0, IntVar x1,
01830       IntConLevel icl=ICL_DEF);
01831 
01837   GECODE_INT_EXPORT void
01838   mult(Home home, IntVar x0, IntVar x1, IntVar x2,
01839        IntConLevel icl=ICL_DEF);
01840 
01846   GECODE_INT_EXPORT void
01847   sqr(Home home, IntVar x0, IntVar x1,
01848       IntConLevel icl=ICL_DEF);
01849 
01855   GECODE_INT_EXPORT void
01856   sqrt(Home home, IntVar x0, IntVar x1,
01857        IntConLevel icl=ICL_DEF);
01858 
01863   GECODE_INT_EXPORT void
01864   divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3,
01865          IntConLevel icl=ICL_DEF);
01866 
01871   GECODE_INT_EXPORT void
01872   div(Home home, IntVar x0, IntVar x1, IntVar x2,
01873       IntConLevel icl=ICL_DEF);
01874 
01879   GECODE_INT_EXPORT void
01880   mod(Home home, IntVar x0, IntVar x1, IntVar x2,
01881       IntConLevel icl=ICL_DEF);
01883 
01915   GECODE_INT_EXPORT void
01916   linear(Home home, const IntVarArgs& x,
01917          IntRelType r, int c,
01918          IntConLevel icl=ICL_DEF);
01922   GECODE_INT_EXPORT void
01923   linear(Home home, const IntVarArgs& x,
01924          IntRelType r, IntVar y,
01925          IntConLevel icl=ICL_DEF);
01929   GECODE_INT_EXPORT void
01930   linear(Home home, const IntVarArgs& x,
01931          IntRelType r, int c, BoolVar b,
01932          IntConLevel icl=ICL_DEF);
01936   GECODE_INT_EXPORT void
01937   linear(Home home, const IntVarArgs& x,
01938          IntRelType r, IntVar y, BoolVar b,
01939          IntConLevel icl=ICL_DEF);
01946   GECODE_INT_EXPORT void
01947   linear(Home home, const IntArgs& a, const IntVarArgs& x,
01948          IntRelType r, int c,
01949          IntConLevel icl=ICL_DEF);
01956   GECODE_INT_EXPORT void
01957   linear(Home home, const IntArgs& a, const IntVarArgs& x,
01958          IntRelType r, IntVar y,
01959          IntConLevel icl=ICL_DEF);
01966   GECODE_INT_EXPORT void
01967   linear(Home home, const IntArgs& a, const IntVarArgs& x,
01968          IntRelType r, int c, BoolVar b,
01969          IntConLevel icl=ICL_DEF);
01976   GECODE_INT_EXPORT void
01977   linear(Home home, const IntArgs& a, const IntVarArgs& x,
01978          IntRelType r, IntVar y, BoolVar b,
01979          IntConLevel icl=ICL_DEF);
01980 
01981 
02009   GECODE_INT_EXPORT void
02010   linear(Home home, const BoolVarArgs& x,
02011          IntRelType r, int c,
02012          IntConLevel icl=ICL_DEF);
02016   GECODE_INT_EXPORT void
02017   linear(Home home, const BoolVarArgs& x,
02018          IntRelType r, int c, BoolVar b,
02019          IntConLevel icl=ICL_DEF);
02023   GECODE_INT_EXPORT void
02024   linear(Home home, const BoolVarArgs& x,
02025          IntRelType r, IntVar y,
02026          IntConLevel icl=ICL_DEF);
02030   GECODE_INT_EXPORT void
02031   linear(Home home, const BoolVarArgs& x,
02032          IntRelType r, IntVar y, BoolVar b,
02033          IntConLevel icl=ICL_DEF);
02040   GECODE_INT_EXPORT void
02041   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02042          IntRelType r, int c,
02043          IntConLevel icl=ICL_DEF);
02050   GECODE_INT_EXPORT void
02051   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02052          IntRelType r, int c, BoolVar b,
02053          IntConLevel icl=ICL_DEF);
02060   GECODE_INT_EXPORT void
02061   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02062          IntRelType r, IntVar y,
02063          IntConLevel icl=ICL_DEF);
02070   GECODE_INT_EXPORT void
02071   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02072          IntRelType r, IntVar y, BoolVar b,
02073          IntConLevel icl=ICL_DEF);
02074 
02075 
02076 
02085 
02086   GECODE_INT_EXPORT void
02087   wait(Home home, IntVar x, void (*c)(Space& home),
02088        IntConLevel icl=ICL_DEF);
02090   GECODE_INT_EXPORT void
02091   wait(Home home, BoolVar x, void (*c)(Space& home),
02092        IntConLevel icl=ICL_DEF);
02094   GECODE_INT_EXPORT void
02095   wait(Home home, const IntVarArgs& x, void (*c)(Space& home),
02096        IntConLevel icl=ICL_DEF);
02098   GECODE_INT_EXPORT void
02099   wait(Home home, const BoolVarArgs& x, void (*c)(Space& home),
02100        IntConLevel icl=ICL_DEF);
02102   GECODE_INT_EXPORT void
02103   when(Home home, BoolVar x, 
02104        void (*t)(Space& home), void (*e)(Space& home)= NULL,
02105        IntConLevel icl=ICL_DEF);
02107 
02108 
02133   GECODE_INT_EXPORT void
02134   unshare(Home home, IntVarArgs& x,
02135           IntConLevel icl=ICL_DEF);
02137   GECODE_INT_EXPORT void
02138   unshare(Home home, BoolVarArgs& x,
02139           IntConLevel icl=ICL_DEF);
02141 
02142 
02148 
02149   enum IntVarBranch {
02150     INT_VAR_NONE = 0,        
02151     INT_VAR_RND,             
02152     INT_VAR_DEGREE_MIN,      
02153     INT_VAR_DEGREE_MAX,      
02154     INT_VAR_AFC_MIN,         
02155     INT_VAR_AFC_MAX,         
02156     INT_VAR_MIN_MIN,         
02157     INT_VAR_MIN_MAX,         
02158     INT_VAR_MAX_MIN,         
02159     INT_VAR_MAX_MAX,         
02160     INT_VAR_SIZE_MIN,        
02161     INT_VAR_SIZE_MAX,        
02162     INT_VAR_SIZE_DEGREE_MIN, 
02163     INT_VAR_SIZE_DEGREE_MAX, 
02164     INT_VAR_SIZE_AFC_MIN,    
02165     INT_VAR_SIZE_AFC_MAX,    
02166 
02171     INT_VAR_REGRET_MIN_MIN,
02177     INT_VAR_REGRET_MIN_MAX,
02183     INT_VAR_REGRET_MAX_MIN,
02189     INT_VAR_REGRET_MAX_MAX
02190   };
02191 
02193   enum IntValBranch {
02194     INT_VAL_MIN,       
02195     INT_VAL_MED,       
02196     INT_VAL_MAX,       
02197     INT_VAL_RND,       
02198     INT_VAL_SPLIT_MIN, 
02199     INT_VAL_SPLIT_MAX, 
02200     INT_VAL_RANGE_MIN, 
02201     INT_VAL_RANGE_MAX, 
02202     INT_VALUES_MIN,    
02203     INT_VALUES_MAX     
02204   };
02205 
02207   GECODE_INT_EXPORT void
02208   branch(Home home, const IntVarArgs& x,
02209          IntVarBranch vars, IntValBranch vals,
02210          const VarBranchOptions& o_vars = VarBranchOptions::def,
02211          const ValBranchOptions& o_vals = ValBranchOptions::def);
02213   GECODE_INT_EXPORT void
02214   branch(Home home, const IntVarArgs& x,
02215          const TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals,
02216          const TieBreakVarBranchOptions& o_vars = TieBreakVarBranchOptions::def,
02217          const ValBranchOptions& o_vals = ValBranchOptions::def);
02219   GECODE_INT_EXPORT void
02220   branch(Home home, IntVar x, IntValBranch vals,
02221          const ValBranchOptions& o_vals = ValBranchOptions::def);
02223   GECODE_INT_EXPORT void
02224   branch(Home home, const BoolVarArgs& x,
02225          IntVarBranch vars, IntValBranch vals,
02226          const VarBranchOptions& o_vars = VarBranchOptions::def,
02227          const ValBranchOptions& o_vals = ValBranchOptions::def);
02229   GECODE_INT_EXPORT void
02230   branch(Home home, const BoolVarArgs& x,
02231          const TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals,
02232          const TieBreakVarBranchOptions& o_vars = TieBreakVarBranchOptions::def,
02233          const ValBranchOptions& o_vals = ValBranchOptions::def);
02235   GECODE_INT_EXPORT void
02236   branch(Home home, BoolVar x, IntValBranch vals,
02237          const ValBranchOptions& o_vals = ValBranchOptions::def);
02239 
02245 
02246   enum IntAssign {
02247     INT_ASSIGN_MIN, 
02248     INT_ASSIGN_MED, 
02249     INT_ASSIGN_MAX, 
02250     INT_ASSIGN_RND  
02251   };
02252 
02254   GECODE_INT_EXPORT void
02255   assign(Home home, const IntVarArgs& x, IntAssign vals,
02256          const ValBranchOptions& o_vals = ValBranchOptions::def);
02258   GECODE_INT_EXPORT void
02259   assign(Home home, IntVar x, IntAssign vals,
02260          const ValBranchOptions& o_vals = ValBranchOptions::def);
02262   GECODE_INT_EXPORT void
02263   assign(Home home, const BoolVarArgs& x, IntAssign vals,
02264          const ValBranchOptions& o_vals = ValBranchOptions::def);
02266   GECODE_INT_EXPORT void
02267   assign(Home home, BoolVar x, IntAssign vals,
02268          const ValBranchOptions& o_vals = ValBranchOptions::def);
02269 
02271 
02275   template<class Char, class Traits>
02276   std::basic_ostream<Char,Traits>&
02277   operator <<(std::basic_ostream<Char,Traits>& os, const DFA& d);
02278 
02282   template<class Char, class Traits>
02283   std::basic_ostream<Char,Traits>&
02284   operator <<(std::basic_ostream<Char,Traits>& os, const TupleSet& ts);
02285 
02286 }
02287 
02288 #endif
02289 
02290 // IFDEF: GECODE_HAS_INT_VARS
02291 // STATISTICS: int-post
02292