00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
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
00345