Generated on Wed Nov 1 15:04:39 2006 for Gecode by doxygen 1.4.5

var.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Contributing authors:
00006  *     Guido Tack <tack@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2002
00010  *     Guido Tack, 2004
00011  *
00012  *  Last modified:
00013  *     $Date: 2006-09-21 11:35:18 +0200 (Thu, 21 Sep 2006) $ by $Author: schulte $
00014  *     $Revision: 3686 $
00015  *
00016  *  This file is part of Gecode, the generic constraint
00017  *  development environment:
00018  *     http://www.gecode.org
00019  *
00020  *  See the file "LICENSE" for information on usage and
00021  *  redistribution of this file, and for a
00022  *     DISCLAIMER OF ALL WARRANTIES.
00023  *
00024  */
00025 
00026 #include <cmath>
00027 
00028 #include "gecode/int/var/imp-hdr.icc"
00029 
00030 namespace Gecode { namespace Int {
00031 
00032   class IntVarImpFwd;
00033   class IntVarImpBwd;
00034 
00040   class IntVarImp : public IntVarImpBase {
00041     friend class IntVarImpFwd;
00042     friend class IntVarImpBwd;
00043   protected:
00053     class RangeList : public FreeList {
00054     protected:
00056       int _min;
00058       int _max;
00059     public:
00061 
00062 
00063       RangeList(void);
00065       RangeList(int min, int max);
00067       RangeList(int min, int max, RangeList* p, RangeList* n);
00069 
00071 
00072 
00073       int min(void) const;
00075       int max(void) const;
00077       unsigned int width(void) const;
00078 
00080       RangeList* next(const RangeList* p) const;
00082       RangeList* prev(const RangeList* n) const;
00084 
00086 
00087 
00088       void min(int n);
00090       void max(int n);
00091 
00093       void prevnext(RangeList* p, RangeList* n);
00095       void next(RangeList* o, RangeList* n);
00097       void prev(RangeList* o, RangeList* n);
00099       void fix(RangeList* n);
00101 
00103 
00104 
00109       void dispose(Space* home, RangeList* p, RangeList* l);
00115       void dispose(Space* home, RangeList* l);
00117       void dispose(Space* home);
00118 
00120       static void* operator new(size_t s, Space* home);
00122       static void  operator delete(void*);
00124       static void  operator delete(void*, Space*);
00126     };
00127 
00135     RangeList dom;
00137     RangeList* _lst;
00139     RangeList* fst(void) const;
00141     void fst(RangeList* f);
00143     RangeList* lst(void) const;
00145     void lst(RangeList* l);
00147     unsigned int holes;
00148 
00149   protected:
00151     IntVarImp(Space* home, bool share, IntVarImp& x, bool is_bool);
00152   public:
00154     IntVarImp(Space* home, int min, int max);
00156     IntVarImp(Space* home, const IntSet& d);
00157 
00159 
00160 
00161     int min(void) const;
00163     int max(void) const;
00165     int val(void) const;
00167     GECODE_INT_EXPORT int med(void) const;
00168 
00170     unsigned int size(void) const;
00172     unsigned int width(void) const;
00174     unsigned int regret_min(void) const;
00176     unsigned int regret_max(void) const;
00178 
00179   private:
00181     GECODE_INT_EXPORT bool in_full(int n) const;
00182 
00183   public:
00185 
00186 
00187     bool range(void) const;
00189     bool assigned(void) const;
00190 
00192     bool in(int n) const;
00194     bool in(double n) const;
00196 
00197   protected:
00199 
00200 
00201     const RangeList* ranges_fwd(void) const;
00203     const RangeList* ranges_bwd(void) const;
00205 
00206   private:
00208     bool closer_min(int b) const;
00210 
00211 
00212     GECODE_INT_EXPORT void lq_full(Space* home, int n);
00214     GECODE_INT_EXPORT void gq_full(Space* home, int n);
00216     GECODE_INT_EXPORT void eq_full(Space* home, int n);
00218     GECODE_INT_EXPORT ModEvent nq_full(Space* home, int n);
00220   public:
00222 
00223 
00224     ModEvent lq(Space* home, int n);
00226     ModEvent lq(Space* home, double n);
00227 
00229     ModEvent gq(Space* home, int n);
00231     ModEvent gq(Space* home, double n);
00232 
00234     ModEvent nq(Space* home, int n);
00236     ModEvent nq(Space* home, double n);
00237 
00239     ModEvent eq(Space* home, int n);
00241     ModEvent eq(Space* home, double n);
00243 
00245 
00246 
00247     template <class I> ModEvent narrow(Space* home, I& i);
00249     template <class I> ModEvent inter(Space* home, I& i);
00251     template <class I> ModEvent minus(Space* home, I& i);
00253 
00255 
00256 
00257     void t_zero_none(Space* home);
00259     void t_one_none(Space* home);
00261 
00262   public:
00264 
00265 
00273     void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
00275 
00276   private:
00278     GECODE_INT_EXPORT IntVarImp* perform_copy(Space* home, bool share);
00280     GECODE_INT_EXPORT IntVarImp* perform_copy_bool(Space* home, bool share);
00281   public:
00283 
00284 
00285     IntVarImp* copy(Space* home, bool share);
00287     IntVarImp* copy_bool(Space* home, bool share);
00289   };
00290 
00291 
00296   class IntVarImpFwd {
00297   private:
00299     const IntVarImp::RangeList* p;
00301     const IntVarImp::RangeList* c;
00302   public:
00304 
00305 
00306     IntVarImpFwd(void);
00308     IntVarImpFwd(const IntVarImp* x);
00310     void init(const IntVarImp* x);
00312 
00314 
00315 
00316     bool operator()(void) const;
00318     void operator++(void);
00320 
00322 
00323 
00324     int min(void) const;
00326     int max(void) const;
00328     unsigned int width(void) const;
00330   };
00331 
00339   class IntVarImpBwd {
00340   private:
00342     const IntVarImp::RangeList* n;
00344     const IntVarImp::RangeList* c;
00345   public:
00347 
00348 
00349     IntVarImpBwd(void);
00351     IntVarImpBwd(const IntVarImp* x);
00353     void init(const IntVarImp* x);
00355 
00357 
00358 
00359     bool operator()(void) const;
00361     void operator++(void);
00363 
00365 
00366 
00367     int min(void) const;
00369     int max(void) const;
00371     unsigned int width(void) const;
00373   };
00374 
00375 
00376   class IntView;
00377   class BoolView;
00378 
00379 }}
00380 
00381 #include "gecode/int/var/imp.icc"
00382 
00383 
00384 namespace Gecode {
00385 
00391   class IntVar {
00392   protected:
00394     Int::IntVarImp* var;
00395   public:
00397 
00398 
00399     IntVar(void);
00401     IntVar(const IntVar& x);
00403     IntVar(const Int::IntView& x);
00415     GECODE_INT_EXPORT IntVar(Space* home, int min ,int max);
00427     GECODE_INT_EXPORT IntVar(Space* home, const IntSet& d);
00439     GECODE_INT_EXPORT void init(Space* home, int min, int max);
00451     GECODE_INT_EXPORT void init(Space* home, const IntSet& d);
00453 
00455 
00456 
00457     Int::IntVarImp* variable(void) const;
00459 
00461 
00462 
00463     int min(void) const;
00465     int max(void) const;
00467     int med(void) const;
00469     int val(void) const;
00470 
00472     unsigned int size(void) const;
00474     unsigned int width(void) const;
00476     unsigned int degree(void) const;
00478 
00480 
00481 
00482     bool range(void) const;
00484     bool assigned(void) const;
00485 
00487     bool in(int n) const;
00489 
00491 
00492 
00493     void update(Space* home, bool share, IntVar& x);
00495   };
00496 
00497 
00502   class IntVarRanges : public Int::IntVarImpFwd {
00503   public:
00505 
00506 
00507     IntVarRanges(void);
00509     IntVarRanges(const IntVar& x);
00511     void init(const IntVar& x);
00513   };
00514 
00519   class IntVarValues
00520     : public Iter::Ranges::ToValues<IntVarRanges> {
00521   public:
00523 
00524 
00525     IntVarValues(void);
00527     IntVarValues(const IntVar& x);
00529     void init(const IntVar& x);
00531   };
00532 
00538   class BoolVar : public IntVar {
00539   public:
00541 
00542 
00543     BoolVar(void);
00545     BoolVar(const Int::BoolView& x);
00557     BoolVar(Space* home, int min, int max);
00564     explicit BoolVar(const IntVar& x);
00566 
00568 
00569 
00570     void update(Space* home, bool share, BoolVar& x);
00572   };
00573 
00574 }
00575 
00580 std::ostream&
00581 operator<<(std::ostream&, const Gecode::IntVar& x);
00582 
00583 /*
00584  * For initialization, IntVar and IntView are mutually dependent.
00585  * Therefore, the inclusion of the variable definition is in view.hh
00586  *
00587  */
00588 
00589 // STATISTICS: int-var
00590