Generated on Mon May 5 05:53:57 2008 for Gecode by doxygen 1.5.5

rel.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  *     Gabor Szokoli <szokoli@gecode.org>
00009  *
00010  *  Copyright:
00011  *     Christian Schulte, 2002
00012  *     Guido Tack, 2004
00013  *     Gabor Szokoli, 2003
00014  *
00015  *  Last modified:
00016  *     $Date: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $
00017  *     $Revision: 5993 $
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_REL_HH__
00045 #define __GECODE_INT_REL_HH__
00046 
00047 #include "gecode/int.hh"
00048 
00054 namespace Gecode { namespace Int { namespace Rel {
00055 
00056   /*
00057    * Equality propagators
00058    *
00059    */
00060 
00070   template <class View0,class View1>
00071   class EqDom :
00072     public MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM> {
00073   protected:
00074     using MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>::x0;
00075     using MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>::x1;
00076 
00078     EqDom(Space* home, bool share, EqDom<View0,View1>& p);
00079   public:
00081     EqDom(Space* home, View0 x0, View1 x1);
00083     virtual Actor* copy(Space* home, bool share);
00091     virtual PropCost cost(ModEventDelta med) const;
00093     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00095     virtual Reflection::ActorSpec spec(const Space* home,
00096                                         Reflection::VarMap& m) const;
00098     static void post(Space* home, Reflection::VarMap& vars,
00099                      const Reflection::ActorSpec& spec);
00101     static Support::Symbol ati(void);
00103     static  ExecStatus post(Space* home, View0 x0, View1 x1);
00104   };
00105 
00112   template <class View0, class View1>
00113   class EqBnd :
00114     public MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND> {
00115   protected:
00116     using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x0;
00117     using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x1;
00118 
00120     EqBnd(Space* home, bool share, EqBnd<View0,View1>& p);
00121   public:
00123     EqBnd(Space* home, View0 x0, View1 x1);
00125     EqBnd(Space* home, bool share, Propagator& p, View0 x0, View1 x1);
00127     virtual Actor* copy(Space* home, bool share);
00129     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00131     virtual Reflection::ActorSpec spec(const Space* home,
00132                                         Reflection::VarMap& m) const;
00134     static void post(Space* home, Reflection::VarMap& vars,
00135                      const Reflection::ActorSpec& spec);
00137     static Support::Symbol ati(void);
00139     static  ExecStatus post(Space* home, View0 x0, View1 x1);
00140   };
00141 
00151   template <class View>
00152   class NaryEqDom : public NaryPropagator<View,PC_INT_DOM> {
00153   protected:
00154     using NaryPropagator<View,PC_INT_DOM>::x;
00155 
00157     NaryEqDom(Space* home, bool share, NaryEqDom<View>& p);
00159     NaryEqDom(Space* home, ViewArray<View>&);
00160   public:
00162     virtual Actor* copy(Space* home, bool share);
00170     virtual PropCost cost(ModEventDelta med) const;
00172     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00174     virtual Reflection::ActorSpec spec(const Space* home,
00175                                         Reflection::VarMap& m) const;
00177     static void post(Space* home, Reflection::VarMap& vars,
00178                      const Reflection::ActorSpec& spec);
00180     static Support::Symbol ati(void);
00182     static  ExecStatus post(Space* home, ViewArray<View>& x);
00183   };
00184 
00191   template <class View>
00192   class NaryEqBnd : public NaryPropagator<View,PC_INT_BND> {
00193   protected:
00194     using NaryPropagator<View,PC_INT_BND>::x;
00195 
00197     NaryEqBnd(Space* home, bool share, NaryEqBnd<View>& p);
00199     NaryEqBnd(Space* home, ViewArray<View>&);
00200   public:
00202     virtual Actor* copy(Space* home, bool share);
00209     virtual PropCost cost(ModEventDelta med) const;
00211     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00213     virtual Reflection::ActorSpec spec(const Space* home,
00214                                         Reflection::VarMap& m) const;
00216     static void post(Space* home, Reflection::VarMap& vars,
00217                      const Reflection::ActorSpec& spec);
00219     static Support::Symbol ati(void);
00221     static  ExecStatus post(Space* home, ViewArray<View>& x);
00222   };
00223 
00230   template <class View, class CtrlView>
00231   class ReEqDom : public ReBinaryPropagator<View,PC_INT_DOM,CtrlView> {
00232   protected:
00233     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00234     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x1;
00235     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00236 
00238     ReEqDom(Space* home, bool share, ReEqDom& p);
00240     ReEqDom(Space* home, View x0, View x1, CtrlView b);
00241   public:
00243     virtual Actor* copy(Space* home, bool share);
00245     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00247     virtual Reflection::ActorSpec spec(const Space* home,
00248                                         Reflection::VarMap& m) const;
00250     static void post(Space* home, Reflection::VarMap& vars,
00251                      const Reflection::ActorSpec& spec);
00253     static Support::Symbol ati(void);
00255     static  ExecStatus post(Space* home, View x0, View x1, CtrlView b);
00256   };
00257 
00264   template <class View, class CtrlView>
00265   class ReEqBnd : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00266   protected:
00267     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00268     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00269     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00270 
00272     ReEqBnd(Space* home, bool share, ReEqBnd& p);
00274     ReEqBnd(Space* home, View x0, View x1, CtrlView b);
00275   public:
00277     virtual Actor*     copy(Space* home, bool share);
00279     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00281     virtual Reflection::ActorSpec spec(const Space* home,
00282                                         Reflection::VarMap& m) const;
00284     static void post(Space* home, Reflection::VarMap& vars,
00285                      const Reflection::ActorSpec& spec);
00287     static Support::Symbol ati(void);
00289     static  ExecStatus post(Space* home, View x0, View x1, CtrlView b);
00290   };
00291 
00298   template <class View, class CtrlView>
00299   class ReEqDomInt : public ReUnaryPropagator<View,PC_INT_DOM,CtrlView> {
00300   protected:
00301     using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00302     using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00303 
00305     int c;
00307     ReEqDomInt(Space* home, bool share, ReEqDomInt& p);
00309     ReEqDomInt(Space* home, View x, int c, CtrlView b);
00310   public:
00312     virtual Actor* copy(Space* home, bool share);
00314     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00316     virtual Reflection::ActorSpec spec(const Space* home,
00317                                         Reflection::VarMap& m) const;
00319     static void post(Space* home, Reflection::VarMap& vars,
00320                      const Reflection::ActorSpec& spec);
00322     static Support::Symbol ati(void);
00324     static  ExecStatus post(Space* home, View x, int c, CtrlView b);
00325   };
00326 
00333   template <class View, class CtrlView>
00334   class ReEqBndInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00335   protected:
00336     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00337     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00338 
00340     int c;
00342     ReEqBndInt(Space* home, bool share, ReEqBndInt& p);
00344     ReEqBndInt(Space* home, View x, int c, CtrlView b);
00345   public:
00347     virtual Actor* copy(Space* home, bool share);
00349     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00351     virtual Reflection::ActorSpec spec(const Space* home,
00352                                         Reflection::VarMap& m) const;
00354     static void post(Space* home, Reflection::VarMap& vars,
00355                      const Reflection::ActorSpec& spec);
00357     static Support::Symbol ati(void);
00359     static  ExecStatus post(Space* home, View x, int c, CtrlView b);
00360   };
00361 
00362 
00363 
00364 
00365   /*
00366    * Disequality propagators
00367    *
00368    */
00369 
00376   template <class View>
00377   class Nq : public BinaryPropagator<View,PC_INT_VAL> {
00378   protected:
00379     using BinaryPropagator<View,PC_INT_VAL>::x0;
00380     using BinaryPropagator<View,PC_INT_VAL>::x1;
00381 
00383     Nq(Space* home, bool share, Nq<View>& p);
00385     Nq(Space* home, View x0, View x1);
00386   public:
00388     virtual Actor* copy(Space* home, bool share);
00390     virtual PropCost cost(ModEventDelta med) const;
00392     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00394     virtual Reflection::ActorSpec spec(const Space* home,
00395                                         Reflection::VarMap& m) const;
00397     static void post(Space* home, Reflection::VarMap& vars,
00398                      const Reflection::ActorSpec& spec);
00400     static Support::Symbol ati(void);
00402     static  ExecStatus post(Space* home, View x0, View x1);
00403   };
00404 
00405   /*
00406    * Order propagators
00407    *
00408    */
00409 
00417   template <class View>
00418   class Lq : public BinaryPropagator<View,PC_INT_BND> {
00419   protected:
00420     using BinaryPropagator<View,PC_INT_BND>::x0;
00421     using BinaryPropagator<View,PC_INT_BND>::x1;
00422 
00424     Lq(Space* home, bool share, Lq& p);
00426     Lq(Space* home, View x0, View x1);
00427   public:
00429     virtual Actor*     copy(Space* home, bool share);
00431     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00433     virtual Reflection::ActorSpec spec(const Space* home,
00434                                         Reflection::VarMap& m) const;
00436     static void post(Space* home, Reflection::VarMap& vars,
00437                      const Reflection::ActorSpec& spec);
00439     static Support::Symbol ati(void);
00441     static  ExecStatus post(Space* home, View x0, View x1);
00442   };
00443 
00450   template <class View>
00451   class Le : public BinaryPropagator<View,PC_INT_BND> {
00452   protected:
00453     using BinaryPropagator<View,PC_INT_BND>::x0;
00454     using BinaryPropagator<View,PC_INT_BND>::x1;
00455 
00457     Le(Space* home, bool share, Le& p);
00459     Le(Space* home, View x0, View x1);
00460   public:
00462     virtual Actor* copy(Space* home, bool share);
00464     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00466     virtual Reflection::ActorSpec spec(const Space* home,
00467                                         Reflection::VarMap& m) const ;
00469     static void post(Space* home, Reflection::VarMap& vars,
00470                      const Reflection::ActorSpec& spec);
00472     static Support::Symbol ati(void);
00474     static  ExecStatus post(Space* home, View x0, View x1);
00475   };
00476 
00477 
00478   /*
00479    * Reified order propagators
00480    *
00481    */
00482 
00490   template <class View, class CtrlView>
00491   class ReLq : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00492   protected:
00493     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00494     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00495     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00496 
00498     ReLq(Space* home, bool share, ReLq& p);
00500     ReLq(Space* home, View x0, View x1, CtrlView b);
00501   public:
00503     virtual Actor* copy(Space* home, bool share);
00505     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00507     virtual Reflection::ActorSpec spec(const Space* home,
00508                                         Reflection::VarMap& m) const;
00510     static void post(Space* home, Reflection::VarMap& vars,
00511                      const Reflection::ActorSpec& spec);
00513     static Support::Symbol ati(void);
00515     static  ExecStatus post(Space* home, View x0, View x1, CtrlView b);
00516   };
00517 
00525   template <class View, class CtrlView>
00526   class ReLqInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00527   protected:
00528     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00529     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00530 
00532     int c;
00534     ReLqInt(Space* home, bool share, ReLqInt& p);
00536     ReLqInt(Space* home, View x, int c, CtrlView b);
00537   public:
00539     virtual Actor* copy(Space* home, bool share);
00541     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00543     virtual Reflection::ActorSpec spec(const Space* home,
00544                                         Reflection::VarMap& m) const;
00546     static void post(Space* home, Reflection::VarMap& vars,
00547                      const Reflection::ActorSpec& spec);
00549     static Support::Symbol ati(void);
00551     static  ExecStatus post(Space* home, View x, int c, CtrlView b);
00552    };
00553 
00554 
00555 
00556 
00557 
00581   template <class View>
00582   class Lex : public NaryPropagator<ViewTuple<View,2>,PC_INT_BND> {
00583   protected:
00584     using NaryPropagator<ViewTuple<View,2>,PC_INT_BND>::x;
00585 
00587     bool strict;
00589     Lex(Space* home, bool share, Lex& p);
00591     Lex(Space* home, ViewArray<ViewTuple<View,2> >& xy, bool strict);
00592   public:
00594     virtual Actor* copy(Space* home, bool share);
00596     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00598     virtual Reflection::ActorSpec spec(const Space* home,
00599                                         Reflection::VarMap& m) const;
00601     static void post(Space* home, Reflection::VarMap& vars,
00602                      const Reflection::ActorSpec& spec);
00604     static Support::Symbol ati(void);
00606     static  ExecStatus post(Space* home,
00607                             ViewArray<ViewTuple<View,2> >& xy, bool strict);
00608   };
00609 
00610 
00617   template<class View>
00618   class NaryNq : public BinaryPropagator<ViewTuple<View,2>,PC_INT_DOM> {
00619   protected:
00620     using BinaryPropagator<ViewTuple<View,2>,PC_INT_DOM>::x0;
00621     using BinaryPropagator<ViewTuple<View,2>,PC_INT_DOM>::x1;
00623     ViewArray<ViewTuple<View,2> > x;
00625     NaryNq(Space* home,  ViewArray<ViewTuple<View,2> >& x);
00627     NaryNq(Space* home, bool share, NaryNq& p);
00628   public:
00630     virtual Actor* copy(Space* home, bool share);
00632     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00634     virtual Reflection::ActorSpec spec(const Space* home,
00635                                         Reflection::VarMap& m) const;
00637     static void post(Space* home, Reflection::VarMap& vars,
00638                      const Reflection::ActorSpec& spec);
00640     static Support::Symbol ati(void);
00642     static  ExecStatus post(Space* home, ViewArray<ViewTuple<View,2> >& x);
00643   };
00644 
00645 
00646 }}}
00647 
00648 #include "gecode/int/rel/eq.icc"
00649 #include "gecode/int/rel/nq.icc"
00650 #include "gecode/int/rel/lq-le.icc"
00651 #include "gecode/int/rel/lex.icc"
00652 
00653 #endif
00654 
00655 
00656 // STATISTICS: int-prop
00657