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

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-07-11 09:33:32 +0200 (Fri, 11 Jul 2008) $ by $Author: tack $
00017  *     $Revision: 7290 $
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     EqDom(Space* home, bool share, Propagator& p, View0 x0, View1 x1);
00085     virtual Actor* copy(Space* home, bool share);
00093     virtual PropCost cost(ModEventDelta med) const;
00095     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00097     virtual Reflection::ActorSpec spec(const Space* home,
00098                                        Reflection::VarMap& m) const;
00100     static void post(Space* home, Reflection::VarMap& vars,
00101                      const Reflection::ActorSpec& spec);
00103     static Support::Symbol ati(void);
00105     static  ExecStatus post(Space* home, View0 x0, View1 x1);
00106   };
00107 
00114   template <class View0, class View1>
00115   class EqBnd :
00116     public MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND> {
00117   protected:
00118     using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x0;
00119     using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x1;
00120 
00122     EqBnd(Space* home, bool share, EqBnd<View0,View1>& p);
00123   public:
00125     EqBnd(Space* home, View0 x0, View1 x1);
00127     EqBnd(Space* home, bool share, Propagator& p, View0 x0, View1 x1);
00129     virtual Actor* copy(Space* home, bool share);
00131     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00133     virtual Reflection::ActorSpec spec(const Space* home,
00134                                         Reflection::VarMap& m) const;
00136     static void post(Space* home, Reflection::VarMap& vars,
00137                      const Reflection::ActorSpec& spec);
00139     static Support::Symbol ati(void);
00141     static  ExecStatus post(Space* home, View0 x0, View1 x1);
00142   };
00143 
00153   template <class View>
00154   class NaryEqDom : public NaryPropagator<View,PC_INT_DOM> {
00155   protected:
00156     using NaryPropagator<View,PC_INT_DOM>::x;
00157 
00159     NaryEqDom(Space* home, bool share, NaryEqDom<View>& p);
00161     NaryEqDom(Space* home, ViewArray<View>&);
00162   public:
00164     virtual Actor* copy(Space* home, bool share);
00172     virtual PropCost cost(ModEventDelta med) const;
00174     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00176     virtual Reflection::ActorSpec spec(const Space* home,
00177                                         Reflection::VarMap& m) const;
00179     static void post(Space* home, Reflection::VarMap& vars,
00180                      const Reflection::ActorSpec& spec);
00182     static Support::Symbol ati(void);
00184     static  ExecStatus post(Space* home, ViewArray<View>& x);
00185   };
00186 
00193   template <class View>
00194   class NaryEqBnd : public NaryPropagator<View,PC_INT_BND> {
00195   protected:
00196     using NaryPropagator<View,PC_INT_BND>::x;
00197 
00199     NaryEqBnd(Space* home, bool share, NaryEqBnd<View>& p);
00201     NaryEqBnd(Space* home, ViewArray<View>&);
00202   public:
00204     virtual Actor* copy(Space* home, bool share);
00211     virtual PropCost cost(ModEventDelta med) const;
00213     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00215     virtual Reflection::ActorSpec spec(const Space* home,
00216                                         Reflection::VarMap& m) const;
00218     static void post(Space* home, Reflection::VarMap& vars,
00219                      const Reflection::ActorSpec& spec);
00221     static Support::Symbol ati(void);
00223     static  ExecStatus post(Space* home, ViewArray<View>& x);
00224   };
00225 
00232   template <class View, class CtrlView>
00233   class ReEqDom : public ReBinaryPropagator<View,PC_INT_DOM,CtrlView> {
00234   protected:
00235     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00236     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x1;
00237     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00238 
00240     ReEqDom(Space* home, bool share, ReEqDom& p);
00242     ReEqDom(Space* home, View x0, View x1, CtrlView b);
00243   public:
00245     virtual Actor* copy(Space* home, bool share);
00247     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00249     virtual Reflection::ActorSpec spec(const Space* home,
00250                                         Reflection::VarMap& m) const;
00252     static void post(Space* home, Reflection::VarMap& vars,
00253                      const Reflection::ActorSpec& spec);
00255     static Support::Symbol ati(void);
00257     static  ExecStatus post(Space* home, View x0, View x1, CtrlView b);
00258   };
00259 
00266   template <class View, class CtrlView>
00267   class ReEqBnd : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00268   protected:
00269     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00270     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00271     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00272 
00274     ReEqBnd(Space* home, bool share, ReEqBnd& p);
00276     ReEqBnd(Space* home, View x0, View x1, CtrlView b);
00277   public:
00279     virtual Actor*     copy(Space* home, bool share);
00281     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00283     virtual Reflection::ActorSpec spec(const Space* home,
00284                                         Reflection::VarMap& m) const;
00286     static void post(Space* home, Reflection::VarMap& vars,
00287                      const Reflection::ActorSpec& spec);
00289     static Support::Symbol ati(void);
00291     static  ExecStatus post(Space* home, View x0, View x1, CtrlView b);
00292   };
00293 
00300   template <class View, class CtrlView>
00301   class ReEqDomInt : public ReUnaryPropagator<View,PC_INT_DOM,CtrlView> {
00302   protected:
00303     using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00304     using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00305 
00307     int c;
00309     ReEqDomInt(Space* home, bool share, ReEqDomInt& p);
00311     ReEqDomInt(Space* home, View x, int c, CtrlView b);
00312   public:
00314     virtual Actor* copy(Space* home, bool share);
00316     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00318     virtual Reflection::ActorSpec spec(const Space* home,
00319                                         Reflection::VarMap& m) const;
00321     static void post(Space* home, Reflection::VarMap& vars,
00322                      const Reflection::ActorSpec& spec);
00324     static Support::Symbol ati(void);
00326     static  ExecStatus post(Space* home, View x, int c, CtrlView b);
00327   };
00328 
00335   template <class View, class CtrlView>
00336   class ReEqBndInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00337   protected:
00338     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00339     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00340 
00342     int c;
00344     ReEqBndInt(Space* home, bool share, ReEqBndInt& p);
00346     ReEqBndInt(Space* home, View x, int c, CtrlView b);
00347   public:
00349     virtual Actor* copy(Space* home, bool share);
00351     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00353     virtual Reflection::ActorSpec spec(const Space* home,
00354                                         Reflection::VarMap& m) const;
00356     static void post(Space* home, Reflection::VarMap& vars,
00357                      const Reflection::ActorSpec& spec);
00359     static Support::Symbol ati(void);
00361     static  ExecStatus post(Space* home, View x, int c, CtrlView b);
00362   };
00363 
00364 
00365 
00366 
00367   /*
00368    * Disequality propagators
00369    *
00370    */
00371 
00378   template <class View>
00379   class Nq : public BinaryPropagator<View,PC_INT_VAL> {
00380   protected:
00381     using BinaryPropagator<View,PC_INT_VAL>::x0;
00382     using BinaryPropagator<View,PC_INT_VAL>::x1;
00383 
00385     Nq(Space* home, bool share, Nq<View>& p);
00387     Nq(Space* home, View x0, View x1);
00388   public:
00390     virtual Actor* copy(Space* home, bool share);
00392     virtual PropCost cost(ModEventDelta med) const;
00394     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00396     virtual Reflection::ActorSpec spec(const Space* home,
00397                                         Reflection::VarMap& m) const;
00399     static void post(Space* home, Reflection::VarMap& vars,
00400                      const Reflection::ActorSpec& spec);
00402     static Support::Symbol ati(void);
00404     static  ExecStatus post(Space* home, View x0, View x1);
00405   };
00406 
00407   /*
00408    * Order propagators
00409    *
00410    */
00411 
00419   template <class View>
00420   class Lq : public BinaryPropagator<View,PC_INT_BND> {
00421   protected:
00422     using BinaryPropagator<View,PC_INT_BND>::x0;
00423     using BinaryPropagator<View,PC_INT_BND>::x1;
00424 
00426     Lq(Space* home, bool share, Lq& p);
00428     Lq(Space* home, View x0, View x1);
00429   public:
00431     virtual Actor*     copy(Space* home, bool share);
00433     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00435     virtual Reflection::ActorSpec spec(const Space* home,
00436                                         Reflection::VarMap& m) const;
00438     static void post(Space* home, Reflection::VarMap& vars,
00439                      const Reflection::ActorSpec& spec);
00441     static Support::Symbol ati(void);
00443     static  ExecStatus post(Space* home, View x0, View x1);
00444   };
00445 
00452   template <class View>
00453   class Le : public BinaryPropagator<View,PC_INT_BND> {
00454   protected:
00455     using BinaryPropagator<View,PC_INT_BND>::x0;
00456     using BinaryPropagator<View,PC_INT_BND>::x1;
00457 
00459     Le(Space* home, bool share, Le& p);
00461     Le(Space* home, View x0, View x1);
00462   public:
00464     virtual Actor* copy(Space* home, bool share);
00466     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00468     virtual Reflection::ActorSpec spec(const Space* home,
00469                                         Reflection::VarMap& m) const ;
00471     static void post(Space* home, Reflection::VarMap& vars,
00472                      const Reflection::ActorSpec& spec);
00474     static Support::Symbol ati(void);
00476     static  ExecStatus post(Space* home, View x0, View x1);
00477   };
00478 
00479 
00480   /*
00481    * Reified order propagators
00482    *
00483    */
00484 
00492   template <class View, class CtrlView>
00493   class ReLq : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00494   protected:
00495     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00496     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00497     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00498 
00500     ReLq(Space* home, bool share, ReLq& p);
00502     ReLq(Space* home, View x0, View x1, CtrlView b);
00503   public:
00505     virtual Actor* copy(Space* home, bool share);
00507     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00509     virtual Reflection::ActorSpec spec(const Space* home,
00510                                         Reflection::VarMap& m) const;
00512     static void post(Space* home, Reflection::VarMap& vars,
00513                      const Reflection::ActorSpec& spec);
00515     static Support::Symbol ati(void);
00517     static  ExecStatus post(Space* home, View x0, View x1, CtrlView b);
00518   };
00519 
00527   template <class View, class CtrlView>
00528   class ReLqInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00529   protected:
00530     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00531     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00532 
00534     int c;
00536     ReLqInt(Space* home, bool share, ReLqInt& p);
00538     ReLqInt(Space* home, View x, int c, CtrlView b);
00539   public:
00541     virtual Actor* copy(Space* home, bool share);
00543     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00545     virtual Reflection::ActorSpec spec(const Space* home,
00546                                         Reflection::VarMap& m) const;
00548     static void post(Space* home, Reflection::VarMap& vars,
00549                      const Reflection::ActorSpec& spec);
00551     static Support::Symbol ati(void);
00553     static  ExecStatus post(Space* home, View x, int c, CtrlView b);
00554    };
00555 
00556 
00557 
00558 
00559 
00583   template <class View>
00584   class Lex : public Propagator {
00585   protected:
00587     ViewArray<View> x, y;
00589     bool strict;
00591     Lex(Space* home, bool share, Lex& p);
00593     Lex(Space* home, ViewArray<View>& x, ViewArray<View>& y, bool strict);
00594   public:
00596     virtual Actor* copy(Space* home, bool share);
00598     virtual PropCost cost(ModEventDelta med) const;
00600     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00602     virtual Reflection::ActorSpec spec(const Space* home,
00603                                        Reflection::VarMap& m) const;
00605     static void post(Space* home, Reflection::VarMap& vars,
00606                      const Reflection::ActorSpec& spec);
00608     static Support::Symbol ati(void);
00610     static ExecStatus post(Space* home, ViewArray<View>& x, ViewArray<View>& y,
00611                            bool strict);
00613     virtual size_t dispose(Space* home);
00614   };
00615 
00616 }}}
00617 
00618 #include "gecode/int/rel/eq.icc"
00619 #include "gecode/int/rel/nq.icc"
00620 #include "gecode/int/rel/lq-le.icc"
00621 #include "gecode/int/rel/lex.icc"
00622 
00623 #endif
00624 
00625 
00626 // STATISTICS: int-prop
00627