Generated on Mon Nov 30 11:16:10 2009 for Gecode by doxygen 1.5.5

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: 2009-11-24 22:19:04 +0100 (Tue, 24 Nov 2009) $ by $Author: schulte $
00019  *     $Revision: 10116 $
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 <iostream>
00051 
00052 #include <gecode/kernel.hh>
00053 #include <gecode/iter.hh>
00054 
00055 /*
00056  * Configure linking
00057  *
00058  */
00059 #if !defined(GECODE_STATIC_LIBS) && \
00060     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00061 
00062 #ifdef GECODE_BUILD_INT
00063 #define GECODE_INT_EXPORT __declspec( dllexport )
00064 #else
00065 #define GECODE_INT_EXPORT __declspec( dllimport )
00066 #endif
00067 
00068 #else
00069 
00070 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00071 #define GECODE_INT_EXPORT __attribute__ ((visibility("default")))
00072 #else
00073 #define GECODE_INT_EXPORT
00074 #endif
00075 
00076 #endif
00077 
00078 // Configure auto-linking
00079 #ifndef GECODE_BUILD_INT
00080 #define GECODE_LIBRARY_NAME "Int"
00081 #include <gecode/support/auto-link.hpp>
00082 #endif
00083 
00095 #include <gecode/int/exception.hpp>
00096 
00097 namespace Gecode { namespace Int {
00098 
00106   namespace Limits {
00108     const int max =  INT_MAX - 1;
00110     const int min = -max;
00112     const int infinity = max + 1;
00114     void check(int n, const char* l);
00116     void check(double n, const char* l);
00118     void positive(int n, const char* l);
00120     void positive(double n, const char* l);
00121   }
00122 
00123 }}
00124 
00125 #include <gecode/int/limits.hpp>
00126 
00127 namespace Gecode {
00128 
00129   class IntSetRanges;
00130 
00138   class IntSet : public SharedHandle {
00139     friend class IntSetRanges;
00140   private:
00142     class Range {
00143     public:
00144       int min, max;
00145     };
00146     class IntSetObject : public SharedHandle::Object {
00147     public:
00149       unsigned int size;
00151       int n;
00153       Range* r;
00155       GECODE_INT_EXPORT static IntSetObject* allocate(int m);
00157       GECODE_INT_EXPORT SharedHandle::Object* copy(void) const;
00159       GECODE_INT_EXPORT virtual ~IntSetObject(void);
00160     };
00162     class MinInc;
00164     GECODE_INT_EXPORT void normalize(Range* r, int n);
00166     GECODE_INT_EXPORT void init(int n, int m);
00168     GECODE_INT_EXPORT void init(const int r[], int n);
00170     GECODE_INT_EXPORT void init(const int r[][2], int n);
00171   public:
00173 
00174 
00175     IntSet(void);
00180     IntSet(int n, int m);
00182     IntSet(const int r[],   int n);
00188     IntSet(const int r[][2], int n);
00190     template<class I>
00191     explicit IntSet(I& i);
00192 #ifdef __INTEL_COMPILER
00194     IntSet(const IntSet& s);
00196     IntSet(IntSet& s);
00198     IntSet(const PrimArgArray<int>& i);
00200     IntSet(PrimArgArray<int>& i);
00201 #endif
00202 
00203 
00205 
00206 
00207     int ranges(void) const;
00209     int min(int i) const;
00211     int max(int i) const;
00213     unsigned int width(int i) const;
00215 
00217 
00218 
00219     unsigned int size(void) const;
00221     unsigned int width(void) const;
00223     int min(void) const;
00225     int max(void) const;
00227 
00229 
00230 
00231     GECODE_INT_EXPORT static const IntSet empty;
00233   };
00234 
00240   class IntSetRanges {
00241   private:
00243     const IntSet::Range* i;
00245     const IntSet::Range* e;
00246   public:
00248 
00249 
00250     IntSetRanges(void);
00252     IntSetRanges(const IntSet& s);
00254     void init(const IntSet& s);
00256 
00258 
00259 
00260     bool operator ()(void) const;
00262     void operator ++(void);
00264 
00266 
00267 
00268     int min(void) const;
00270     int max(void) const;
00272     unsigned int width(void) const;
00274   };
00275 
00281   class IntSetValues : public Iter::Ranges::ToValues<IntSetRanges> {
00282   public:
00284 
00285 
00286     IntSetValues(void);
00288     IntSetValues(const IntSet& s);
00290     void init(const IntSet& s);
00292   };
00293 
00298   template<class Char, class Traits>
00299   std::basic_ostream<Char,Traits>&
00300   operator <<(std::basic_ostream<Char,Traits>& os, const IntSet& s);
00301 
00302 }
00303 
00304 #include <gecode/int/int-set-1.hpp>
00305 
00306 #include <gecode/int/var-imp.hpp>
00307 
00308 namespace Gecode {
00309 
00310   namespace Int {
00311     class IntView;
00312   }
00313 
00319   class IntVar : public VarBase<Int::IntVarImp> {
00320     friend class IntVarArray;
00321   private:
00322     using VarBase<Int::IntVarImp>::varimp;
00329     void _init(Space& home, int min, int max);
00336     void _init(Space& home, const IntSet& d);
00337   public:
00339 
00340 
00341     IntVar(void);
00343     IntVar(const IntVar& x);
00345     IntVar(const Int::IntView& x);
00357     GECODE_INT_EXPORT IntVar(Space& home, int min ,int max);
00369     GECODE_INT_EXPORT IntVar(Space& home, const IntSet& d);
00381     GECODE_INT_EXPORT void init(Space& home, int min, int max);
00393     GECODE_INT_EXPORT void init(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 assigned(void) const;
00429 
00431     bool in(int n) const;
00433 
00435 
00436 
00437     void update(Space& home, bool share, IntVar& x);
00439   };
00440 
00445   template<class Char, class Traits>
00446   std::basic_ostream<Char,Traits>&
00447   operator <<(std::basic_ostream<Char,Traits>& os, const IntVar& x);
00448 
00453   class IntVarRanges : public Int::IntVarImpFwd {
00454   public:
00456 
00457 
00458     IntVarRanges(void);
00460     IntVarRanges(const IntVar& x);
00462     void init(const IntVar& x);
00464   };
00465 
00470   class IntVarValues : public Iter::Ranges::ToValues<IntVarRanges> {
00471   public:
00473 
00474 
00475     IntVarValues(void);
00477     IntVarValues(const IntVar& x);
00479     void init(const IntVar& x);
00481   };
00482 
00483   namespace Int {
00484     class BoolView;
00485   }
00486 
00492   class BoolVar : public VarBase<Int::BoolVarImp> {
00493     friend class BoolVarArray;
00494   private:
00495     using VarBase<Int::BoolVarImp>::varimp;
00502     void _init(Space& home, int min, int max);
00503   public:
00505 
00506 
00507     BoolVar(void);
00509     BoolVar(const BoolVar& x);
00511     BoolVar(const Int::BoolView& x);
00523     GECODE_INT_EXPORT BoolVar(Space& home, int min, int max);
00535     GECODE_INT_EXPORT void init(Space& home, int min, int max);
00537 
00539 
00540 
00541     int min(void) const;
00543     int max(void) const;
00545     int med(void) const;
00553     int val(void) const;
00554 
00556     unsigned int size(void) const;
00558     unsigned int width(void) const;
00560     unsigned int regret_min(void) const;
00562     unsigned int regret_max(void) const;
00564 
00566 
00567 
00568     bool range(void) const;
00570     bool assigned(void) const;
00571 
00573     bool in(int n) const;
00575 
00577 
00578 
00579     bool zero(void) const;
00581     bool one(void) const;
00583     bool none(void) const;
00585 
00587 
00588 
00589     void update(Space& home, bool share, BoolVar& x);
00591 
00592   };
00593 
00598   template<class Char, class Traits>
00599   std::basic_ostream<Char,Traits>&
00600   operator <<(std::basic_ostream<Char,Traits>& os, const BoolVar& x);
00601 
00602 }
00603 
00604 
00605 #include <gecode/int/view.hpp>
00606 #include <gecode/int/propagator.hpp>
00607 
00608 namespace Gecode {
00609 
00619 
00620   typedef PrimArgArray<int>    IntArgs;
00629   class IntVarArgs : public VarArgArray<IntVar> {
00630   public:
00632 
00633 
00634     explicit IntVarArgs(int n) : VarArgArray<IntVar>(n) {}
00636     IntVarArgs(const IntVarArgs& a) : VarArgArray<IntVar>(a) {}
00638     IntVarArgs(const VarArray<IntVar>& a) : VarArgArray<IntVar>(a) {}
00640   };
00649   class BoolVarArgs : public VarArgArray<BoolVar> {
00650   public:
00652 
00653 
00654     explicit BoolVarArgs(int n) : VarArgArray<BoolVar>(n) {}
00656     BoolVarArgs(const BoolVarArgs& a) : VarArgArray<BoolVar>(a) {}
00658     BoolVarArgs(const VarArray<BoolVar>& a) : VarArgArray<BoolVar>(a) {}
00660   };
00662   typedef ArgArray<IntSet> IntSetArgs;
00664 
00680   class IntVarArray : public VarArray<IntVar> {
00681   public:
00683 
00684 
00685     IntVarArray(void);
00687     IntVarArray(Space& home, int n);
00689     IntVarArray(const IntVarArray& a);
00701     GECODE_INT_EXPORT
00702     IntVarArray(Space& home, int n, int min, int max);
00714     GECODE_INT_EXPORT
00715     IntVarArray(Space& home, int n, const IntSet& s);
00717   };
00718 
00723   class BoolVarArray : public VarArray<BoolVar> {
00724   public:
00726 
00727 
00728     BoolVarArray(void);
00730     BoolVarArray(Space& home, int n);
00732     BoolVarArray(const BoolVarArray& a);
00744     GECODE_INT_EXPORT
00745     BoolVarArray(Space& home, int n, int min, int max);
00747   };
00748 
00749 }
00750 
00751 #include <gecode/int/int-set-2.hpp>
00752 
00753 #include <gecode/int/array.hpp>
00754 
00755 namespace Gecode {
00756 
00761   enum IntRelType {
00762     IRT_EQ, 
00763     IRT_NQ, 
00764     IRT_LQ, 
00765     IRT_LE, 
00766     IRT_GQ, 
00767     IRT_GR  
00768   };
00769 
00774   enum BoolOpType {
00775     BOT_AND, 
00776     BOT_OR,  
00777     BOT_IMP, 
00778     BOT_EQV, 
00779     BOT_XOR  
00780   };
00781 
00795   enum IntConLevel {
00796     ICL_VAL, 
00797     ICL_BND, 
00798     ICL_DOM, 
00799     ICL_DEF  
00800   };
00801 
00802 
00810 
00811   GECODE_INT_EXPORT void
00812   dom(Home home, IntVar x, int n,
00813       IntConLevel icl=ICL_DEF);
00815   GECODE_INT_EXPORT void
00816   dom(Home home, const IntVarArgs& x, int n,
00817       IntConLevel icl=ICL_DEF);
00818 
00820   GECODE_INT_EXPORT void
00821   dom(Home home, IntVar x, int l, int m,
00822       IntConLevel icl=ICL_DEF);
00824   GECODE_INT_EXPORT void
00825   dom(Home home, const IntVarArgs& x, int l, int m,
00826       IntConLevel icl=ICL_DEF);
00827 
00829   GECODE_INT_EXPORT void
00830   dom(Home home, IntVar x, const IntSet& s,
00831       IntConLevel icl=ICL_DEF);
00833   GECODE_INT_EXPORT void
00834   dom(Home home, const IntVarArgs& x, const IntSet& s,
00835       IntConLevel icl=ICL_DEF);
00836 
00838   GECODE_INT_EXPORT void
00839   dom(Home home, IntVar x, int n, BoolVar b,
00840       IntConLevel icl=ICL_DEF);
00842   GECODE_INT_EXPORT void
00843   dom(Home home, IntVar x, int l, int m, BoolVar b,
00844       IntConLevel icl=ICL_DEF);
00846   GECODE_INT_EXPORT void
00847   dom(Home home, IntVar x, const IntSet& s, BoolVar b,
00848       IntConLevel icl=ICL_DEF);
00850 
00851 
00862   GECODE_INT_EXPORT void
00863   rel(Home home, IntVar x0, IntRelType r, IntVar x1,
00864       IntConLevel icl=ICL_DEF);
00871   GECODE_INT_EXPORT void
00872   rel(Home home, const IntVarArgs& x, IntRelType r, IntVar y,
00873       IntConLevel icl=ICL_DEF);
00877   GECODE_INT_EXPORT void
00878   rel(Home home, IntVar x, IntRelType r, int c,
00879       IntConLevel icl=ICL_DEF);
00883   GECODE_INT_EXPORT void
00884   rel(Home home, const IntVarArgs& x, IntRelType r, int c,
00885       IntConLevel icl=ICL_DEF);
00892   GECODE_INT_EXPORT void
00893   rel(Home home, IntVar x0, IntRelType r, IntVar x1, BoolVar b,
00894       IntConLevel icl=ICL_DEF);
00901   GECODE_INT_EXPORT void
00902   rel(Home home, IntVar x, IntRelType r, int c, BoolVar b,
00903       IntConLevel icl=ICL_DEF);
00922   GECODE_INT_EXPORT void
00923   rel(Home home, const IntVarArgs& x, IntRelType r,
00924       IntConLevel icl=ICL_DEF);
00937   GECODE_INT_EXPORT void
00938   rel(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
00939       IntConLevel icl=ICL_DEF);
00940 
00948   GECODE_INT_EXPORT void
00949   rel(Home home, BoolVar x0, IntRelType r, BoolVar x1,
00950       IntConLevel icl=ICL_DEF);
00954   GECODE_INT_EXPORT void
00955   rel(Home home, BoolVar x0, IntRelType r, BoolVar x1, BoolVar b,
00956       IntConLevel icl=ICL_DEF);
00960   GECODE_INT_EXPORT void
00961   rel(Home home, const BoolVarArgs& x, IntRelType r, BoolVar y,
00962       IntConLevel icl=ICL_DEF);
00970   GECODE_INT_EXPORT void
00971   rel(Home home, BoolVar x, IntRelType r, int n,
00972       IntConLevel icl=ICL_DEF);
00980   GECODE_INT_EXPORT void
00981   rel(Home home, BoolVar x, IntRelType r, int n, BoolVar b,
00982       IntConLevel icl=ICL_DEF);
00990   GECODE_INT_EXPORT void
00991   rel(Home home, const BoolVarArgs& x, IntRelType r, int n,
00992       IntConLevel icl=ICL_DEF);
01002   GECODE_INT_EXPORT void
01003   rel(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01004       IntConLevel icl=ICL_DEF);
01016   GECODE_INT_EXPORT void
01017   rel(Home home, const BoolVarArgs& x, IntRelType r,
01018       IntConLevel icl=ICL_DEF);
01024   GECODE_INT_EXPORT void
01025   rel(Home home, BoolVar x0, BoolOpType o, BoolVar x1, BoolVar x2,
01026       IntConLevel icl=ICL_DEF);
01035   GECODE_INT_EXPORT void
01036   rel(Home home, BoolVar x0, BoolOpType o, BoolVar x1, int n,
01037       IntConLevel icl=ICL_DEF);
01047   GECODE_INT_EXPORT void
01048   rel(Home home, BoolOpType o, const BoolVarArgs& x, BoolVar y,
01049       IntConLevel icl=ICL_DEF);
01062   GECODE_INT_EXPORT void
01063   rel(Home home, BoolOpType o, const BoolVarArgs& x, int n,
01064       IntConLevel icl=ICL_DEF);
01075   GECODE_INT_EXPORT void
01076   clause(Home home, BoolOpType o, const BoolVarArgs& x, const BoolVarArgs& y,
01077          BoolVar z, IntConLevel icl=ICL_DEF);
01091   GECODE_INT_EXPORT void
01092   clause(Home home, BoolOpType o, const BoolVarArgs& x, const BoolVarArgs& y,
01093          int n, IntConLevel icl=ICL_DEF);
01094 
01095 
01102 
01103   typedef SharedArray<int> IntSharedArray;
01109   GECODE_INT_EXPORT void
01110   element(Home home, IntSharedArray n, IntVar x0, IntVar x1,
01111           IntConLevel icl=ICL_DEF);
01117   GECODE_INT_EXPORT void
01118   element(Home home, IntSharedArray n, IntVar x0, BoolVar x1,
01119           IntConLevel icl=ICL_DEF);
01125   GECODE_INT_EXPORT void
01126   element(Home home, IntSharedArray n, IntVar x0, int x1,
01127           IntConLevel icl=ICL_DEF);
01133   GECODE_INT_EXPORT void
01134   element(Home home, const IntVarArgs& x, IntVar y0, IntVar y1,
01135           IntConLevel icl=ICL_DEF);
01141   GECODE_INT_EXPORT void
01142   element(Home home, const IntVarArgs& x, IntVar y0, int y1,
01143           IntConLevel icl=ICL_DEF);
01145   GECODE_INT_EXPORT void
01146   element(Home home, const BoolVarArgs& x, IntVar y0, BoolVar y1,
01147           IntConLevel icl=ICL_DEF);
01149   GECODE_INT_EXPORT void
01150   element(Home home, const BoolVarArgs& x, IntVar y0, int y1,
01151           IntConLevel icl=ICL_DEF);
01152 
01161   GECODE_INT_EXPORT void
01162   element(Home home, IntSharedArray a, 
01163           IntVar x, int w, IntVar y, int h, IntVar z,
01164           IntConLevel icl=ICL_DEF);
01173   GECODE_INT_EXPORT void
01174   element(Home home, IntSharedArray a, 
01175           IntVar x, int w, IntVar y, int h, BoolVar z,
01176           IntConLevel icl=ICL_DEF);
01188   GECODE_INT_EXPORT void
01189   element(Home home, const IntVarArgs& a, 
01190           IntVar x, int w, IntVar y, int h, IntVar z,
01191           IntConLevel icl=ICL_DEF);
01200   GECODE_INT_EXPORT void
01201   element(Home home, const BoolVarArgs& a, 
01202           IntVar x, int w, IntVar y, int h, BoolVar z,
01203           IntConLevel icl=ICL_DEF);
01205 
01206 
01221   GECODE_INT_EXPORT void
01222   distinct(Home home, const IntVarArgs& x,
01223            IntConLevel icl=ICL_DEF);
01236   GECODE_INT_EXPORT void
01237   distinct(Home home, const IntArgs& n, const IntVarArgs& x,
01238            IntConLevel icl=ICL_DEF);
01240 
01241 
01259   GECODE_INT_EXPORT void
01260   channel(Home home, const IntVarArgs& x, const IntVarArgs& y,
01261           IntConLevel icl=ICL_DEF);
01262 
01276   GECODE_INT_EXPORT void
01277   channel(Home home, const IntVarArgs& x, int xoff,
01278           const IntVarArgs& y, int yoff,
01279           IntConLevel icl=ICL_DEF);
01280 
01282   GECODE_INT_EXPORT void
01283   channel(Home home, BoolVar x0, IntVar x1,
01284           IntConLevel icl=ICL_DEF);
01286   forceinline void
01287   channel(Home home, IntVar x0, BoolVar x1,
01288           IntConLevel icl=ICL_DEF) {
01289     channel(home,x1,x0,icl);
01290   }
01296   GECODE_INT_EXPORT void
01297   channel(Home home, const BoolVarArgs& x, IntVar y, int o=0,
01298           IntConLevel icl=ICL_DEF);
01300 
01301 
01318   GECODE_INT_EXPORT void
01319   sorted(Home home, const IntVarArgs& x, const IntVarArgs& y,
01320          IntConLevel icl=ICL_DEF);
01321 
01333   GECODE_INT_EXPORT void
01334   sorted(Home home, const IntVarArgs& x, const IntVarArgs& y,
01335          const IntVarArgs& z,
01336          IntConLevel icl=ICL_DEF);
01338 
01339 
01358   GECODE_INT_EXPORT void
01359   count(Home home, const IntVarArgs& x, int n, IntRelType r, int m,
01360         IntConLevel icl=ICL_DEF);
01365   GECODE_INT_EXPORT void
01366   count(Home home, const IntVarArgs& x, IntVar y, IntRelType r, int m,
01367         IntConLevel icl=ICL_DEF);
01375   GECODE_INT_EXPORT void
01376   count(Home home, const IntVarArgs& x, const IntArgs& y, IntRelType r, int m,
01377         IntConLevel icl=ICL_DEF);
01382   GECODE_INT_EXPORT void
01383   count(Home home, const IntVarArgs& x, int n, IntRelType r, IntVar z,
01384         IntConLevel icl=ICL_DEF);
01389   GECODE_INT_EXPORT void
01390   count(Home home, const IntVarArgs& x, IntVar y, IntRelType r, IntVar z,
01391         IntConLevel icl=ICL_DEF);
01399   GECODE_INT_EXPORT void
01400   count(Home home, const IntVarArgs& x, const IntArgs& y, IntRelType r, IntVar z,
01401         IntConLevel icl=ICL_DEF);
01402 
01416   GECODE_INT_EXPORT void
01417   count(Home home, const IntVarArgs& x, const IntVarArgs& c,
01418         IntConLevel icl=ICL_DEF);
01419 
01433   GECODE_INT_EXPORT void
01434   count(Home home, const IntVarArgs& x, const IntSetArgs& c,
01435         IntConLevel icl=ICL_DEF);
01436 
01453   GECODE_INT_EXPORT void
01454   count(Home home, const IntVarArgs& x,
01455         const IntVarArgs& c, const IntArgs& v,
01456         IntConLevel icl=ICL_DEF);
01457 
01474   GECODE_INT_EXPORT void
01475   count(Home home, const IntVarArgs& x,
01476         const IntSetArgs& c, const IntArgs& v,
01477         IntConLevel icl=ICL_DEF);
01478 
01495   GECODE_INT_EXPORT void
01496   count(Home home, const IntVarArgs& x,
01497         const IntSet& c, const IntArgs& v,
01498         IntConLevel icl=ICL_DEF);
01499 
01501 
01522   GECODE_INT_EXPORT void
01523   sequence(Home home, const IntVarArgs& x, const IntSet& s, 
01524            int q, int l, int u, IntConLevel icl=ICL_DEF); 
01525   
01540   GECODE_INT_EXPORT void
01541   sequence(Home home, const BoolVarArgs& x, const IntSet& s, 
01542            int q, int l, int u, IntConLevel icl=ICL_DEF); 
01543 
01545 
01558 
01566   class DFA : public SharedHandle {
01567   private:
01569     class DFAI;
01570   public:
01572     class Transition {
01573     public:
01574       int i_state; 
01575       int symbol;  
01576       int o_state; 
01577     };
01579     class Transitions {
01580     private:
01582       const Transition* c_trans;
01584       const Transition* e_trans;
01585     public:
01587       Transitions(const DFA& d);
01589       Transitions(const DFA& d, int n);
01591       bool operator ()(void) const;
01593       void operator ++(void);
01595       int i_state(void) const;
01597       int symbol(void) const;
01599       int o_state(void) const;
01600     };
01602     class Symbols {
01603     private:
01605       const Transition* c_trans;
01607       const Transition* e_trans;
01608     public:
01610       Symbols(const DFA& d);
01612       bool operator ()(void) const;
01614       void operator ++(void);
01616       int val(void) const;
01617     };
01618   public:
01619     friend class Transitions;
01621     DFA(void);
01633     GECODE_INT_EXPORT
01634     DFA(int s, Transition t[], int f[], bool minimize=true);
01636     DFA(const DFA& d);
01638     int n_states(void) const;
01640     int n_transitions(void) const;
01642     unsigned int n_symbols(void) const;
01644     unsigned int max_degree(void) const;
01646     int final_fst(void) const;
01648     int final_lst(void) const;
01650     int symbol_min(void) const;
01652     int symbol_max(void) const;
01653   };
01654 
01655 
01663   enum ExtensionalPropKind {
01664     EPK_DEF,    
01665     EPK_SPEED,  
01666     EPK_MEMORY  
01667   };
01668 
01679   GECODE_INT_EXPORT void
01680   extensional(Home home, const IntVarArgs& x, DFA d,
01681               IntConLevel icl=ICL_DEF);
01682 
01693   GECODE_INT_EXPORT void
01694   extensional(Home home, const BoolVarArgs& x, DFA d,
01695               IntConLevel icl=ICL_DEF);
01696 
01703   class TupleSet : public SharedHandle {
01704   public:
01709     typedef int* Tuple;
01710 
01715     class GECODE_VTABLE_EXPORT TupleSetI
01716       : public SharedHandle::Object {
01717     public:
01719       int arity;
01721       int size;
01723       Tuple** tuples;
01725       Tuple* tuple_data;
01727       int* data;
01729       int excess;
01731       int min, max;
01733       unsigned int domsize;
01735       Tuple** last;
01737       Tuple* nullpointer;
01738 
01740       template<class T>
01741       void add(T t);
01743       GECODE_INT_EXPORT void finalize(void);
01745       GECODE_INT_EXPORT void resize(void);
01747       bool finalized(void) const;
01749       TupleSetI(void);
01751       GECODE_INT_EXPORT virtual ~TupleSetI(void);
01753       GECODE_INT_EXPORT virtual SharedHandle::Object* copy(void) const;
01754     };
01755     
01757     TupleSetI* implementation(void);
01758 
01760     TupleSet(void);
01762     TupleSet(const TupleSet& d);
01763 
01765     void add(const IntArgs& tuple);
01767     void finalize(void);
01769     bool finalized(void) const;
01771     int arity(void) const;
01773     int tuples(void) const;
01775     Tuple operator [](int i) const;
01777     int min(void) const;
01779     int max(void) const;
01780   };
01781 
01800   GECODE_INT_EXPORT void
01801   extensional(Home home, const IntVarArgs& x, const TupleSet& t,
01802               ExtensionalPropKind epk=EPK_DEF, IntConLevel icl=ICL_DEF);
01803 
01814   GECODE_INT_EXPORT void
01815   extensional(Home home, const BoolVarArgs& x, const TupleSet& t,
01816               ExtensionalPropKind epk=EPK_DEF, IntConLevel icl=ICL_DEF);
01818 
01819 }
01820 
01821 #include <gecode/int/extensional/dfa.hpp>
01822 #include <gecode/int/extensional/tuple-set.hpp>
01823 
01824 namespace Gecode {
01825 
01837   GECODE_INT_EXPORT void
01838   min(Home home, IntVar x0, IntVar x1, IntVar x2,
01839       IntConLevel icl=ICL_DEF);
01847   GECODE_INT_EXPORT void
01848   min(Home home, const IntVarArgs& x, IntVar y,
01849       IntConLevel icl=ICL_DEF);
01855   GECODE_INT_EXPORT void
01856   max(Home home, IntVar x0, IntVar x1, IntVar x2,
01857       IntConLevel icl=ICL_DEF);
01865   GECODE_INT_EXPORT void
01866   max(Home home, const IntVarArgs& x, IntVar y,
01867       IntConLevel icl=ICL_DEF);
01868 
01874   GECODE_INT_EXPORT void
01875   abs(Home home, IntVar x0, IntVar x1,
01876       IntConLevel icl=ICL_DEF);
01877 
01883   GECODE_INT_EXPORT void
01884   mult(Home home, IntVar x0, IntVar x1, IntVar x2,
01885        IntConLevel icl=ICL_DEF);
01886 
01892   GECODE_INT_EXPORT void
01893   sqr(Home home, IntVar x0, IntVar x1,
01894       IntConLevel icl=ICL_DEF);
01895 
01901   GECODE_INT_EXPORT void
01902   sqrt(Home home, IntVar x0, IntVar x1,
01903        IntConLevel icl=ICL_DEF);
01904 
01909   GECODE_INT_EXPORT void
01910   divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3,
01911          IntConLevel icl=ICL_DEF);
01912 
01917   GECODE_INT_EXPORT void
01918   div(Home home, IntVar x0, IntVar x1, IntVar x2,
01919       IntConLevel icl=ICL_DEF);
01920 
01925   GECODE_INT_EXPORT void
01926   mod(Home home, IntVar x0, IntVar x1, IntVar x2,
01927       IntConLevel icl=ICL_DEF);
01929 
01961   GECODE_INT_EXPORT void
01962   linear(Home home, const IntVarArgs& x,
01963          IntRelType r, int c,
01964          IntConLevel icl=ICL_DEF);
01968   GECODE_INT_EXPORT void
01969   linear(Home home, const IntVarArgs& x,
01970          IntRelType r, IntVar y,
01971          IntConLevel icl=ICL_DEF);
01975   GECODE_INT_EXPORT void
01976   linear(Home home, const IntVarArgs& x,
01977          IntRelType r, int c, BoolVar b,
01978          IntConLevel icl=ICL_DEF);
01982   GECODE_INT_EXPORT void
01983   linear(Home home, const IntVarArgs& x,
01984          IntRelType r, IntVar y, BoolVar b,
01985          IntConLevel icl=ICL_DEF);
01992   GECODE_INT_EXPORT void
01993   linear(Home home, const IntArgs& a, const IntVarArgs& x,
01994          IntRelType r, int c,
01995          IntConLevel icl=ICL_DEF);
02002   GECODE_INT_EXPORT void
02003   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02004          IntRelType r, IntVar y,
02005          IntConLevel icl=ICL_DEF);
02012   GECODE_INT_EXPORT void
02013   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02014          IntRelType r, int c, BoolVar b,
02015          IntConLevel icl=ICL_DEF);
02022   GECODE_INT_EXPORT void
02023   linear(Home home, const IntArgs& a, const IntVarArgs& x,
02024          IntRelType r, IntVar y, BoolVar b,
02025          IntConLevel icl=ICL_DEF);
02026 
02027 
02055   GECODE_INT_EXPORT void
02056   linear(Home home, const BoolVarArgs& x,
02057          IntRelType r, int c,
02058          IntConLevel icl=ICL_DEF);
02062   GECODE_INT_EXPORT void
02063   linear(Home home, const BoolVarArgs& x,
02064          IntRelType r, int c, BoolVar b,
02065          IntConLevel icl=ICL_DEF);
02069   GECODE_INT_EXPORT void
02070   linear(Home home, const BoolVarArgs& x,
02071          IntRelType r, IntVar y,
02072          IntConLevel icl=ICL_DEF);
02076   GECODE_INT_EXPORT void
02077   linear(Home home, const BoolVarArgs& x,
02078          IntRelType r, IntVar y, BoolVar b,
02079          IntConLevel icl=ICL_DEF);
02086   GECODE_INT_EXPORT void
02087   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02088          IntRelType r, int c,
02089          IntConLevel icl=ICL_DEF);
02096   GECODE_INT_EXPORT void
02097   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02098          IntRelType r, int c, BoolVar b,
02099          IntConLevel icl=ICL_DEF);
02106   GECODE_INT_EXPORT void
02107   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02108          IntRelType r, IntVar y,
02109          IntConLevel icl=ICL_DEF);
02116   GECODE_INT_EXPORT void
02117   linear(Home home, const IntArgs& a, const BoolVarArgs& x,
02118          IntRelType r, IntVar y, BoolVar b,
02119          IntConLevel icl=ICL_DEF);
02120 
02121 
02122 
02131 
02132   GECODE_INT_EXPORT void
02133   wait(Home home, IntVar x, void (*c)(Space& home),
02134        IntConLevel icl=ICL_DEF);
02136   GECODE_INT_EXPORT void
02137   wait(Home home, BoolVar x, void (*c)(Space& home),
02138        IntConLevel icl=ICL_DEF);
02140   GECODE_INT_EXPORT void
02141   wait(Home home, const IntVarArgs& x, void (*c)(Space& home),
02142        IntConLevel icl=ICL_DEF);
02144   GECODE_INT_EXPORT void
02145   wait(Home home, const BoolVarArgs& x, void (*c)(Space& home),
02146        IntConLevel icl=ICL_DEF);
02148   GECODE_INT_EXPORT void
02149   when(Home home, BoolVar x, 
02150        void (*t)(Space& home), void (*e)(Space& home)= NULL,
02151        IntConLevel icl=ICL_DEF);
02153 
02154 
02179   GECODE_INT_EXPORT void
02180   unshare(Home home, IntVarArgs& x,
02181           IntConLevel icl=ICL_DEF);
02183   GECODE_INT_EXPORT void
02184   unshare(Home home, BoolVarArgs& x,
02185           IntConLevel icl=ICL_DEF);
02187 
02188 
02194 
02195   enum IntVarBranch {
02196     INT_VAR_NONE = 0,        
02197     INT_VAR_RND,             
02198     INT_VAR_DEGREE_MIN,      
02199     INT_VAR_DEGREE_MAX,      
02200     INT_VAR_AFC_MIN,         
02201     INT_VAR_AFC_MAX,         
02202     INT_VAR_MIN_MIN,         
02203     INT_VAR_MIN_MAX,         
02204     INT_VAR_MAX_MIN,         
02205     INT_VAR_MAX_MAX,         
02206     INT_VAR_SIZE_MIN,        
02207     INT_VAR_SIZE_MAX,        
02208     INT_VAR_SIZE_DEGREE_MIN, 
02209     INT_VAR_SIZE_DEGREE_MAX, 
02210     INT_VAR_SIZE_AFC_MIN,    
02211     INT_VAR_SIZE_AFC_MAX,    
02212 
02217     INT_VAR_REGRET_MIN_MIN,
02223     INT_VAR_REGRET_MIN_MAX,
02229     INT_VAR_REGRET_MAX_MIN,
02235     INT_VAR_REGRET_MAX_MAX
02236   };
02237 
02239   enum IntValBranch {
02240     INT_VAL_MIN,       
02241     INT_VAL_MED,       
02242     INT_VAL_MAX,       
02243     INT_VAL_RND,       
02244     INT_VAL_SPLIT_MIN, 
02245     INT_VAL_SPLIT_MAX, 
02246     INT_VAL_RANGE_MIN, 
02247     INT_VAL_RANGE_MAX, 
02248     INT_VALUES_MIN,    
02249     INT_VALUES_MAX     
02250   };
02251 
02253   GECODE_INT_EXPORT void
02254   branch(Home home, const IntVarArgs& x,
02255          IntVarBranch vars, IntValBranch vals,
02256          const VarBranchOptions& o_vars = VarBranchOptions::def,
02257          const ValBranchOptions& o_vals = ValBranchOptions::def);
02259   GECODE_INT_EXPORT void
02260   branch(Home home, const IntVarArgs& x,
02261          const TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals,
02262          const TieBreakVarBranchOptions& o_vars = TieBreakVarBranchOptions::def,
02263          const ValBranchOptions& o_vals = ValBranchOptions::def);
02265   GECODE_INT_EXPORT void
02266   branch(Home home, IntVar x, IntValBranch vals,
02267          const ValBranchOptions& o_vals = ValBranchOptions::def);
02269   GECODE_INT_EXPORT void
02270   branch(Home home, const BoolVarArgs& x,
02271          IntVarBranch vars, IntValBranch vals,
02272          const VarBranchOptions& o_vars = VarBranchOptions::def,
02273          const ValBranchOptions& o_vals = ValBranchOptions::def);
02275   GECODE_INT_EXPORT void
02276   branch(Home home, const BoolVarArgs& x,
02277          const TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals,
02278          const TieBreakVarBranchOptions& o_vars = TieBreakVarBranchOptions::def,
02279          const ValBranchOptions& o_vals = ValBranchOptions::def);
02281   GECODE_INT_EXPORT void
02282   branch(Home home, BoolVar x, IntValBranch vals,
02283          const ValBranchOptions& o_vals = ValBranchOptions::def);
02285 
02291 
02292   enum IntAssign {
02293     INT_ASSIGN_MIN, 
02294     INT_ASSIGN_MED, 
02295     INT_ASSIGN_MAX, 
02296     INT_ASSIGN_RND  
02297   };
02298 
02300   GECODE_INT_EXPORT void
02301   assign(Home home, const IntVarArgs& x, IntAssign vals,
02302          const ValBranchOptions& o_vals = ValBranchOptions::def);
02304   GECODE_INT_EXPORT void
02305   assign(Home home, IntVar x, IntAssign vals,
02306          const ValBranchOptions& o_vals = ValBranchOptions::def);
02308   GECODE_INT_EXPORT void
02309   assign(Home home, const BoolVarArgs& x, IntAssign vals,
02310          const ValBranchOptions& o_vals = ValBranchOptions::def);
02312   GECODE_INT_EXPORT void
02313   assign(Home home, BoolVar x, IntAssign vals,
02314          const ValBranchOptions& o_vals = ValBranchOptions::def);
02315 
02317 
02321   template<class Char, class Traits>
02322   std::basic_ostream<Char,Traits>&
02323   operator <<(std::basic_ostream<Char,Traits>& os, const DFA& d);
02324 
02328   template<class Char, class Traits>
02329   std::basic_ostream<Char,Traits>&
02330   operator <<(std::basic_ostream<Char,Traits>& os, const TupleSet& ts);
02331 
02332 }
02333 
02334 #endif
02335 
02336 // IFDEF: GECODE_HAS_INT_VARS
02337 // STATISTICS: int-post
02338