Generated on Tue May 22 09:39:57 2018 for Gecode by doxygen 1.6.3

distinct.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  *  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_INT_DISTINCT_HH__
00041 #define __GECODE_INT_DISTINCT_HH__
00042 
00043 #include <gecode/int.hh>
00044 
00045 #include <gecode/int/view-val-graph.hh>
00046 #include <gecode/int/rel.hh>
00047 
00053 namespace Gecode { namespace Int { namespace Distinct {
00054 
00063   template<class View>
00064   class Val : public NaryPropagator<View,PC_INT_VAL> {
00065   protected:
00066     using NaryPropagator<View,PC_INT_VAL>::x;
00067 
00069     Val(Home home, ViewArray<View>& x);
00071     Val(Space& home, Val<View>& p);
00072   public:
00074     virtual Actor*     copy(Space& home);
00076     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00078     static ExecStatus post(Home home, ViewArray<View>& x);
00079   };
00080 
00094   template<class View, bool complete>
00095   ExecStatus prop_val(Space& home, ViewArray<View>&);
00096 
00097 
00098 
00124   template<class View>
00125   class Bnd : public Propagator {
00126   protected:
00128     ViewArray<View> x;
00130     ViewArray<View> y;
00132     int min_x;
00134     int max_x;
00136     Bnd(Home home, ViewArray<View>& x);
00138     Bnd(Space& home, Bnd<View>& p);
00139   public:
00141     static ExecStatus post(Home home, ViewArray<View>& x);
00143     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00150     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00152     virtual void reschedule(Space& home);
00154     virtual Actor* copy(Space& home);
00156     virtual size_t dispose(Space& home);
00157   };
00158 
00167   template<class View>
00168   ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
00169 
00178   template<class View>
00179   ExecStatus prop_bnd(Space& home, ViewArray<View>& x);
00180 
00181 
00183   template<class View>
00184   class Graph : public ViewValGraph::Graph<View> {
00185   public:
00186     using ViewValGraph::Graph<View>::view;
00187     using ViewValGraph::Graph<View>::n_view;
00188     using ViewValGraph::Graph<View>::val;
00189     using ViewValGraph::Graph<View>::n_val;
00190     using ViewValGraph::Graph<View>::count;
00191     using ViewValGraph::Graph<View>::scc;
00192     using ViewValGraph::Graph<View>::match;
00194     Graph(void);
00196     ExecStatus init(Space& home, ViewArray<View>& x);
00198     bool mark(void);
00200     ExecStatus prune(Space& home, bool& assigned);
00202     bool sync(void);
00203   };
00204 
00215   template<class View>
00216   class DomCtrl {
00217   protected:
00219     Graph<View> g;
00220   public:
00222     DomCtrl(void);
00224     bool available(void);
00226     ExecStatus init(Space& home, ViewArray<View>& x);
00228     ExecStatus sync(void);
00230     ExecStatus propagate(Space& home, bool& assigned);
00231   };
00232 
00248   template<class View>
00249   class Dom : public NaryPropagator<View,PC_INT_DOM> {
00250   protected:
00251     using NaryPropagator<View,PC_INT_DOM>::x;
00253     DomCtrl<View> dc;
00255     Dom(Space& home, Dom<View>& p);
00257     Dom(Home home, ViewArray<View>& x);
00258   public:
00260     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00267     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00269     virtual Actor* copy(Space& home);
00271     static ExecStatus post(Home home, ViewArray<View>& x);
00272   };
00273 
00280   template<class View>
00281   class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
00282   protected:
00283     using TernaryPropagator<View,PC_INT_DOM>::x0;
00284     using TernaryPropagator<View,PC_INT_DOM>::x1;
00285     using TernaryPropagator<View,PC_INT_DOM>::x2;
00286 
00288     TerDom(Space& home, TerDom<View>& p);
00290     TerDom(Home home, View x0, View x1, View x2);
00291   public:
00293     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00295     virtual Actor* copy(Space& home);
00297     static  ExecStatus post(Home home, View x0, View x1, View x2);
00298   };
00299 
00308   class EqIte : public BinaryPropagator<IntView,PC_INT_DOM> {
00309   protected:
00310     using BinaryPropagator<IntView,PC_INT_DOM>::x0;
00311     using BinaryPropagator<IntView,PC_INT_DOM>::x1;
00313     int c0, c1;
00315     EqIte(Space& home, EqIte& p);
00317     EqIte(Home home, IntView x0, IntView x1, int c0, int c1);
00318   public:
00320     GECODE_INT_EXPORT
00321     virtual Actor* copy(Space& home);
00323     GECODE_INT_EXPORT
00324     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00326     GECODE_INT_EXPORT
00327     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00329     static ExecStatus post(Home home, IntView x0, IntView x1, int c0, int c1);
00330   };
00331 
00332 }}}
00333 
00334 #include <gecode/int/distinct/val.hpp>
00335 #include <gecode/int/distinct/bnd.hpp>
00336 #include <gecode/int/distinct/ter-dom.hpp>
00337 #include <gecode/int/distinct/graph.hpp>
00338 #include <gecode/int/distinct/dom-ctrl.hpp>
00339 #include <gecode/int/distinct/dom.hpp>
00340 #include <gecode/int/distinct/eqite.hpp>
00341 
00342 #endif
00343 
00344 // STATISTICS: int-prop
00345