Generated on Thu Apr 11 13:59:07 2019 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:
00073 #ifdef GECODE_HAS_CBS
00074 
00075     virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
00077     virtual void domainsizesum(Propagator::InDecision in,
00078                                unsigned int& size, unsigned int& size_b) const;
00079 #endif
00080 
00081     virtual Actor*     copy(Space& home);
00083     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00085     static ExecStatus post(Home home, ViewArray<View>& x);
00086   };
00087 
00088 #ifdef GECODE_HAS_CBS
00089 
00099   template<class View>
00100   void cbsdistinct(Space& home, unsigned int prop_id, const ViewArray<View>& x,
00101                    Propagator::SendMarginal send);
00102 
00103   template<class View>
00104   void cbssize(const ViewArray<View>& x, Propagator::InDecision in,
00105                unsigned int& size, unsigned int& size_b);
00106 #endif
00107 
00121   template<class View, bool complete>
00122   ExecStatus prop_val(Space& home, ViewArray<View>&);
00123 
00124 
00125 
00151   template<class View>
00152   class Bnd : public Propagator {
00153   protected:
00155     ViewArray<View> x;
00157     ViewArray<View> y;
00159     int min_x;
00161     int max_x;
00163     Bnd(Home home, ViewArray<View>& x);
00165     Bnd(Space& home, Bnd<View>& p);
00166   public:
00167 #ifdef GECODE_HAS_CBS
00168 
00169     virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
00171     virtual void domainsizesum(Propagator::InDecision in,
00172                                unsigned int& size, unsigned int& size_b) const;
00173 #endif
00174 
00175     static ExecStatus post(Home home, ViewArray<View>& x);
00177     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00184     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00186     virtual void reschedule(Space& home);
00188     virtual Actor* copy(Space& home);
00190     virtual size_t dispose(Space& home);
00191   };
00192 
00201   template<class View>
00202   ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
00203 
00212   template<class View>
00213   ExecStatus prop_bnd(Space& home, ViewArray<View>& x);
00214 
00215 
00217   template<class View>
00218   class Graph : public ViewValGraph::Graph<View> {
00219   public:
00220     using ViewValGraph::Graph<View>::view;
00221     using ViewValGraph::Graph<View>::n_view;
00222     using ViewValGraph::Graph<View>::val;
00223     using ViewValGraph::Graph<View>::n_val;
00224     using ViewValGraph::Graph<View>::count;
00225     using ViewValGraph::Graph<View>::scc;
00226     using ViewValGraph::Graph<View>::match;
00228     Graph(void);
00230     ExecStatus init(Space& home, ViewArray<View>& x);
00232     bool mark(void);
00234     ExecStatus prune(Space& home, bool& assigned);
00236     bool sync(void);
00237   };
00238 
00249   template<class View>
00250   class DomCtrl {
00251   protected:
00253     Graph<View> g;
00254   public:
00256     DomCtrl(void);
00258     bool available(void);
00260     ExecStatus init(Space& home, ViewArray<View>& x);
00262     ExecStatus sync(void);
00264     ExecStatus propagate(Space& home, bool& assigned);
00265   };
00266 
00282   template<class View>
00283   class Dom : public NaryPropagator<View,PC_INT_DOM> {
00284   protected:
00285     using NaryPropagator<View,PC_INT_DOM>::x;
00287     DomCtrl<View> dc;
00289     Dom(Space& home, Dom<View>& p);
00291     Dom(Home home, ViewArray<View>& x);
00292   public:
00293 #ifdef GECODE_HAS_CBS
00294 
00295     virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
00297     virtual void domainsizesum(Propagator::InDecision in,
00298                                unsigned int& size, unsigned int& size_b) const;
00299 #endif
00300 
00301     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00308     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00310     virtual Actor* copy(Space& home);
00312     static ExecStatus post(Home home, ViewArray<View>& x);
00313   };
00314 
00321   template<class View>
00322   class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
00323   protected:
00324     using TernaryPropagator<View,PC_INT_DOM>::x0;
00325     using TernaryPropagator<View,PC_INT_DOM>::x1;
00326     using TernaryPropagator<View,PC_INT_DOM>::x2;
00327 
00329     TerDom(Space& home, TerDom<View>& p);
00331     TerDom(Home home, View x0, View x1, View x2);
00332   public:
00334     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00336     virtual Actor* copy(Space& home);
00338     static  ExecStatus post(Home home, View x0, View x1, View x2);
00339   };
00340 
00349   class EqIte : public BinaryPropagator<IntView,PC_INT_DOM> {
00350   protected:
00351     using BinaryPropagator<IntView,PC_INT_DOM>::x0;
00352     using BinaryPropagator<IntView,PC_INT_DOM>::x1;
00354     int c0, c1;
00356     EqIte(Space& home, EqIte& p);
00358     EqIte(Home home, IntView x0, IntView x1, int c0, int c1);
00359   public:
00361     GECODE_INT_EXPORT
00362     virtual Actor* copy(Space& home);
00364     GECODE_INT_EXPORT
00365     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00367     GECODE_INT_EXPORT
00368     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00370     static ExecStatus post(Home home, IntView x0, IntView x1, int c0, int c1);
00371   };
00372 
00373 }}}
00374 
00375 #include <gecode/int/distinct/cbs.hpp>
00376 #include <gecode/int/distinct/val.hpp>
00377 #include <gecode/int/distinct/bnd.hpp>
00378 #include <gecode/int/distinct/ter-dom.hpp>
00379 #include <gecode/int/distinct/graph.hpp>
00380 #include <gecode/int/distinct/dom-ctrl.hpp>
00381 #include <gecode/int/distinct/dom.hpp>
00382 #include <gecode/int/distinct/eqite.hpp>
00383 
00384 #endif
00385 
00386 // STATISTICS: int-prop
00387