Generated on Mon Aug 25 11:35:35 2008 for Gecode by doxygen 1.5.6

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  *     Guido Tack <tack@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Guido Tack, 2004
00009  *     Christian Schulte, 2004
00010  *
00011  *  Last modified:
00012  *     $Date: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $
00013  *     $Revision: 5993 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #ifndef __GECODE_SET_INT_HH__
00041 #define __GECODE_SET_INT_HH__
00042 
00043 #include "gecode/set.hh"
00044 
00045 namespace Gecode { namespace Set { namespace Int {
00046 
00058   template <class View>
00059   class MinElement :
00060     public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND> {
00061   protected:
00062     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x0;
00063     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x1;
00065     MinElement(Space* home, bool share,MinElement& p);
00067     MinElement(Space* home, View, Gecode::Int::IntView);
00068   public:
00070     GECODE_SET_EXPORT virtual Actor*      copy(Space* home,bool);
00072     GECODE_SET_EXPORT virtual ExecStatus propagate(Space* home, ModEventDelta med);
00074     static ExecStatus post(Space* home, View s, Gecode::Int::IntView x);
00076     GECODE_SET_EXPORT
00077     virtual Reflection::ActorSpec spec(const Space* home,
00078                                         Reflection::VarMap& m) const;
00080     static void post(Space* home, Reflection::VarMap& vars,
00081                      const Reflection::ActorSpec& spec);
00083     static Support::Symbol ati(void);
00084   };
00085 
00092   template <class View>
00093   class MaxElement :
00094     public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND> {
00095   protected:
00096     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x0;
00097     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x1;
00099     MaxElement(Space* home, bool share,MaxElement& p);
00101     MaxElement(Space* home, View, Gecode::Int::IntView);
00102   public:
00104     GECODE_SET_EXPORT virtual Actor*      copy(Space* home,bool);
00106     GECODE_SET_EXPORT virtual ExecStatus propagate(Space* home, ModEventDelta med);
00108     static ExecStatus post(Space* home, View s, Gecode::Int::IntView x);
00110     GECODE_SET_EXPORT
00111     virtual Reflection::ActorSpec spec(const Space* home,
00112                                         Reflection::VarMap& m) const;
00114     static void post(Space* home, Reflection::VarMap& vars,
00115                      const Reflection::ActorSpec& spec);
00117     static Support::Symbol ati(void);
00118   };
00119 
00126   template <class View>
00127   class Card :
00128     public IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND> {
00129   protected:
00130     using IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>::x0;
00131     using IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>::x1;
00133     Card(Space* home, bool share,Card& p);
00135     Card(Space* home, View, Gecode::Int::IntView);
00136   public:
00138     GECODE_SET_EXPORT virtual Actor*      copy(Space* home,bool);
00140     GECODE_SET_EXPORT virtual ExecStatus propagate(Space* home, ModEventDelta med);
00142     static ExecStatus post(Space* home, View s, Gecode::Int::IntView x);
00144     GECODE_SET_EXPORT
00145     virtual Reflection::ActorSpec spec(const Space* home,
00146                                         Reflection::VarMap& m) const;
00148     static void post(Space* home, Reflection::VarMap& vars,
00149                      const Reflection::ActorSpec& spec);
00151     static Support::Symbol ati(void);
00152   };
00153 
00154 
00161   template <class View>
00162   class Match : public Propagator {
00163   protected:
00165     View x0;
00167     ViewArray<Gecode::Int::IntView> xs;
00168 
00170     Match(Space* home, bool share,Match& p);
00172     Match(Space* home, View, ViewArray<Gecode::Int::IntView>&);
00173   public:
00175     GECODE_SET_EXPORT virtual Actor*   copy(Space* home,bool);
00177     GECODE_SET_EXPORT virtual PropCost cost(ModEventDelta med) const;
00179     GECODE_SET_EXPORT virtual size_t dispose(Space* home);
00181     GECODE_SET_EXPORT virtual ExecStatus propagate(Space* home, ModEventDelta med);
00183     static ExecStatus post(Space* home, View s,
00184                            ViewArray<Gecode::Int::IntView>& x);
00186     GECODE_SET_EXPORT
00187     virtual Reflection::ActorSpec spec(const Space* home,
00188                                         Reflection::VarMap& m) const;
00190     static void post(Space* home, Reflection::VarMap& vars,
00191                      const Reflection::ActorSpec& spec);
00193     static Support::Symbol ati(void);
00194   };
00195 
00213   template <class View>
00214   class ChannelInt : public Propagator {
00215   protected:
00217     ViewArray<Gecode::Int::IntView> xs;
00219     ViewArray<View> ys;
00220 
00222     ChannelInt(Space* home, bool share,ChannelInt& p);
00224     ChannelInt(Space* home,ViewArray<Gecode::Int::IntView>&, 
00225                ViewArray<View>&);
00226   public:
00228     virtual Actor*   copy(Space* home,bool);
00230     virtual PropCost cost(ModEventDelta med) const;
00232     virtual size_t dispose(Space* home);
00234     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00236     static ExecStatus post(Space* home,ViewArray<Gecode::Int::IntView>& x,
00237                            ViewArray<View>& y);
00239     GECODE_SET_EXPORT
00240     virtual Reflection::ActorSpec spec(const Space* home,
00241                                         Reflection::VarMap& m) const;
00243     static void post(Space* home, Reflection::VarMap& vars,
00244                      const Reflection::ActorSpec& spec);
00246     static Support::Symbol ati(void);
00247   };
00248 
00260   template <class View>
00261   class ChannelBool
00262   : public MixNaryOnePropagator<Gecode::Int::BoolView,
00263                                 Gecode::Int::PC_BOOL_VAL,
00264                                 View,PC_GEN_NONE> {
00265   protected:
00266     typedef MixNaryOnePropagator<Gecode::Int::BoolView,
00267                                   Gecode::Int::PC_BOOL_VAL,
00268                                   View,PC_GEN_NONE> Super;
00269     using Super::x;
00270     using Super::y;
00271 
00273     ChannelBool(Space* home, bool share,ChannelBool& p);
00275     ChannelBool(Space* home,ViewArray<Gecode::Int::BoolView>&, 
00276                 View);
00277 
00279     class IndexAdvisor : public Advisor {
00280     protected:
00282       int idx;
00283     public: 
00285       template <class A>
00286       IndexAdvisor(Space* home, ChannelBool<View>* p, Council<A>& c,
00287                    int index);
00289       IndexAdvisor(Space* home, bool share, IndexAdvisor& a);
00291       int index(void) const;
00293       template <class A>
00294       void dispose(Space* home, Council<A>& c);
00295     };
00296 
00298     Council<IndexAdvisor> co;
00300     SetDelta delta;
00302     GLBndSet zeros;
00304     GLBndSet ones;
00306     bool running;
00307   public:
00309     virtual Actor*   copy(Space* home,bool);
00311     virtual PropCost cost(ModEventDelta med) const;
00313     virtual size_t dispose(Space* home);
00315     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00317     virtual ExecStatus advise(Space* home, Advisor* a, const Delta* d);
00319     static ExecStatus post(Space* home,ViewArray<Gecode::Int::BoolView>& x,
00320                            View y);
00322     GECODE_SET_EXPORT
00323     virtual Reflection::ActorSpec spec(const Space* home,
00324                                         Reflection::VarMap& m) const;
00326     static void post(Space* home, Reflection::VarMap& vars,
00327                      const Reflection::ActorSpec& spec);
00329     static Support::Symbol ati(void);
00330   };
00331 
00338   template <class View>
00339   class Weights : public Propagator {
00340   protected:
00342     SharedArray<int> elements;
00344     SharedArray<int> weights;
00345 
00347     View x;
00349     Gecode::Int::IntView y;
00350 
00352     Weights(Space* home, bool share,Weights& p);
00354     Weights(Space* home, const IntArgs&, const IntArgs&,
00355             View, Gecode::Int::IntView);
00356   public:
00358     GECODE_SET_EXPORT virtual Actor*   copy(Space* home,bool);
00360     GECODE_SET_EXPORT virtual PropCost cost(ModEventDelta med) const;
00362     GECODE_SET_EXPORT virtual size_t dispose(Space* home);
00364     GECODE_SET_EXPORT virtual ExecStatus propagate(Space* home, ModEventDelta med);
00366     static ExecStatus post(Space* home,
00367                            const IntArgs& elements, const IntArgs& weights,
00368                            View x, Gecode::Int::IntView y);
00370     GECODE_SET_EXPORT
00371     virtual Reflection::ActorSpec spec(const Space* home,
00372                                         Reflection::VarMap& m) const;
00374     static void post(Space* home, Reflection::VarMap& vars,
00375                      const Reflection::ActorSpec& spec);
00377     static Support::Symbol ati(void);
00378   };
00379 
00380 }}}
00381 
00382 #include "gecode/set/int/minmax.icc"
00383 #include "gecode/set/int/card.icc"
00384 #include "gecode/set/int/match.icc"
00385 #include "gecode/set/int/channel-int.icc"
00386 #include "gecode/set/int/channel-bool.icc"
00387 #include "gecode/set/int/weights.icc"
00388 
00389 #endif
00390 
00391 // STATISTICS: set-prop