Generated on Tue Jul 27 2010 21:59:15 for Gecode by doxygen 1.7.1

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: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00017  *     $Revision: 9878 $
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(Home 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(const Space& home, const ModEventDelta& med) const;
00095     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00097     static  ExecStatus post(Home home, View0 x0, View1 x1);
00098   };
00099 
00106   template<class View0, class View1>
00107   class EqBnd :
00108     public MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND> {
00109   protected:
00110     using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x0;
00111     using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x1;
00112 
00114     EqBnd(Space& home, bool share, EqBnd<View0,View1>& p);
00115   public:
00117     EqBnd(Home home, View0 x0, View1 x1);
00119     EqBnd(Space& home, bool share, Propagator& p, View0 x0, View1 x1);
00121     virtual Actor* copy(Space& home, bool share);
00123     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00125     static  ExecStatus post(Home home, View0 x0, View1 x1);
00126   };
00127 
00137   template<class View>
00138   class NaryEqDom : public NaryPropagator<View,PC_INT_DOM> {
00139   protected:
00140     using NaryPropagator<View,PC_INT_DOM>::x;
00141 
00143     NaryEqDom(Space& home, bool share, NaryEqDom<View>& p);
00145     NaryEqDom(Home home, ViewArray<View>&);
00146   public:
00148     virtual Actor* copy(Space& home, bool share);
00156     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00158     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00160     static  ExecStatus post(Home home, ViewArray<View>& x);
00161   };
00162 
00169   template<class View>
00170   class NaryEqBnd : public NaryPropagator<View,PC_INT_BND> {
00171   protected:
00172     using NaryPropagator<View,PC_INT_BND>::x;
00173 
00175     NaryEqBnd(Space& home, bool share, NaryEqBnd<View>& p);
00177     NaryEqBnd(Home home, ViewArray<View>&);
00178   public:
00180     virtual Actor* copy(Space& home, bool share);
00187     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00189     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00191     static  ExecStatus post(Home home, ViewArray<View>& x);
00192   };
00193 
00200   template<class View, class CtrlView>
00201   class ReEqDom : public ReBinaryPropagator<View,PC_INT_DOM,CtrlView> {
00202   protected:
00203     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00204     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x1;
00205     using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00206 
00208     ReEqDom(Space& home, bool share, ReEqDom& p);
00210     ReEqDom(Home home, View x0, View x1, CtrlView b);
00211   public:
00213     virtual Actor* copy(Space& home, bool share);
00215     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00217     static  ExecStatus post(Home home, View x0, View x1, CtrlView b);
00218   };
00219 
00226   template<class View, class CtrlView>
00227   class ReEqBnd : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00228   protected:
00229     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00230     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00231     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00232 
00234     ReEqBnd(Space& home, bool share, ReEqBnd& p);
00236     ReEqBnd(Home home, View x0, View x1, CtrlView b);
00237   public:
00239     virtual Actor*     copy(Space& home, bool share);
00241     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00243     static  ExecStatus post(Home home, View x0, View x1, CtrlView b);
00244   };
00245 
00252   template<class View, class CtrlView>
00253   class ReEqDomInt : public ReUnaryPropagator<View,PC_INT_DOM,CtrlView> {
00254   protected:
00255     using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00256     using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00257 
00259     int c;
00261     ReEqDomInt(Space& home, bool share, ReEqDomInt& p);
00263     ReEqDomInt(Home home, View x, int c, CtrlView b);
00264   public:
00266     virtual Actor* copy(Space& home, bool share);
00268     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00270     static  ExecStatus post(Home home, View x, int c, CtrlView b);
00271   };
00272 
00279   template<class View, class CtrlView>
00280   class ReEqBndInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00281   protected:
00282     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00283     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00284 
00286     int c;
00288     ReEqBndInt(Space& home, bool share, ReEqBndInt& p);
00290     ReEqBndInt(Home home, View x, int c, CtrlView b);
00291   public:
00293     virtual Actor* copy(Space& home, bool share);
00295     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00297     static  ExecStatus post(Home home, View x, int c, CtrlView b);
00298   };
00299 
00300 
00301 
00302 
00303   /*
00304    * Disequality propagators
00305    *
00306    */
00307 
00314   template<class View>
00315   class Nq : public BinaryPropagator<View,PC_INT_VAL> {
00316   protected:
00317     using BinaryPropagator<View,PC_INT_VAL>::x0;
00318     using BinaryPropagator<View,PC_INT_VAL>::x1;
00319 
00321     Nq(Space& home, bool share, Nq<View>& p);
00323     Nq(Home home, View x0, View x1);
00324   public:
00326     virtual Actor* copy(Space& home, bool share);
00328     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00330     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00332     static  ExecStatus post(Home home, View x0, View x1);
00333   };
00334 
00335   /*
00336    * Order propagators
00337    *
00338    */
00339 
00347   template<class View>
00348   class Lq : public BinaryPropagator<View,PC_INT_BND> {
00349   protected:
00350     using BinaryPropagator<View,PC_INT_BND>::x0;
00351     using BinaryPropagator<View,PC_INT_BND>::x1;
00352 
00354     Lq(Space& home, bool share, Lq& p);
00356     Lq(Home home, View x0, View x1);
00357   public:
00359     virtual Actor*     copy(Space& home, bool share);
00361     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00363     static  ExecStatus post(Home home, View x0, View x1);
00364   };
00365 
00372   template<class View>
00373   class Le : public BinaryPropagator<View,PC_INT_BND> {
00374   protected:
00375     using BinaryPropagator<View,PC_INT_BND>::x0;
00376     using BinaryPropagator<View,PC_INT_BND>::x1;
00377 
00379     Le(Space& home, bool share, Le& p);
00381     Le(Home home, View x0, View x1);
00382   public:
00384     virtual Actor* copy(Space& home, bool share);
00386     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00388     static  ExecStatus post(Home home, View x0, View x1);
00389   };
00390 
00391 
00392   /*
00393    * Reified order propagators
00394    *
00395    */
00396 
00404   template<class View, class CtrlView>
00405   class ReLq : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00406   protected:
00407     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00408     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00409     using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00410 
00412     ReLq(Space& home, bool share, ReLq& p);
00414     ReLq(Home home, View x0, View x1, CtrlView b);
00415   public:
00417     virtual Actor* copy(Space& home, bool share);
00419     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00421     static  ExecStatus post(Home home, View x0, View x1, CtrlView b);
00422   };
00423 
00431   template<class View, class CtrlView>
00432   class ReLqInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00433   protected:
00434     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00435     using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00436 
00438     int c;
00440     ReLqInt(Space& home, bool share, ReLqInt& p);
00442     ReLqInt(Home home, View x, int c, CtrlView b);
00443   public:
00445     virtual Actor* copy(Space& home, bool share);
00447     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00449     static  ExecStatus post(Home home, View x, int c, CtrlView b);
00450    };
00451 
00452 
00453 
00454 
00455 
00479   template<class View>
00480   class Lex : public Propagator {
00481   protected:
00483     ViewArray<View> x, y;
00485     bool strict;
00487     Lex(Space& home, bool share, Lex& p);
00489     Lex(Home home, ViewArray<View>& x, ViewArray<View>& y, bool strict);
00490   public:
00492     virtual Actor* copy(Space& home, bool share);
00494     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00496     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00498     static ExecStatus post(Home home, ViewArray<View>& x, ViewArray<View>& y,
00499                            bool strict);
00501     virtual size_t dispose(Space& home);
00502   };
00503 
00504 }}}
00505 
00506 #include <gecode/int/rel/eq.hpp>
00507 #include <gecode/int/rel/nq.hpp>
00508 #include <gecode/int/rel/lq-le.hpp>
00509 #include <gecode/int/rel/lex.hpp>
00510 
00511 #endif
00512 
00513 
00514 // STATISTICS: int-prop
00515