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
00041
00042
00043
00044 #ifndef __GECODE_INT_DISTINCT_HH__
00045 #define __GECODE_INT_DISTINCT_HH__
00046
00047 #include <gecode/int.hh>
00048
00049 #include <gecode/int/view-val-graph.hh>
00050 #include <gecode/int/rel.hh>
00051
00057 namespace Gecode { namespace Int { namespace Distinct {
00058
00067 template<class View>
00068 class Val : public NaryPropagator<View,PC_INT_VAL> {
00069 protected:
00070 using NaryPropagator<View,PC_INT_VAL>::x;
00071
00073 Val(Home home, ViewArray<View>& x);
00075 Val(Space& home, bool share, Val<View>& p);
00076 public:
00078 virtual Actor* copy(Space& home, bool share);
00080 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00082 static ExecStatus post(Home home, ViewArray<View>& x);
00083 };
00084
00098 template<class View, bool complete>
00099 ExecStatus prop_val(Space& home, ViewArray<View>&);
00100
00101
00102
00128 template<class View>
00129 class Bnd : public Propagator {
00130 protected:
00132 ViewArray<View> x;
00134 ViewArray<View> y;
00136 int min_x;
00138 int max_x;
00140 Bnd(Home home, ViewArray<View>& x);
00142 Bnd(Space& home, bool share, Bnd<View>& p);
00143 public:
00145 static ExecStatus post(Home home, ViewArray<View>& x);
00147 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00154 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00156 virtual Actor* copy(Space& home, bool share);
00158 virtual size_t dispose(Space& home);
00159 };
00160
00169 template<class View>
00170 ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
00171
00180 template<class View>
00181 ExecStatus prop_bnd(Space& home, ViewArray<View>& x);
00182
00183
00185 template<class View>
00186 class Graph : public ViewValGraph::Graph<View> {
00187 public:
00188 using ViewValGraph::Graph<View>::view;
00189 using ViewValGraph::Graph<View>::n_view;
00190 using ViewValGraph::Graph<View>::val;
00191 using ViewValGraph::Graph<View>::n_val;
00192 using ViewValGraph::Graph<View>::count;
00193 using ViewValGraph::Graph<View>::scc;
00194 using ViewValGraph::Graph<View>::match;
00196 Graph(void);
00198 ExecStatus init(Space& home, ViewArray<View>& x);
00200 bool mark(Space& home);
00202 ExecStatus prune(Space& home, bool& assigned);
00204 bool sync(Space& home);
00205 };
00206
00217 template<class View>
00218 class DomCtrl {
00219 protected:
00221 Graph<View> g;
00222 public:
00224 DomCtrl(void);
00226 bool available(void);
00228 ExecStatus init(Space& home, ViewArray<View>& x);
00230 ExecStatus sync(Space& home);
00232 ExecStatus propagate(Space& home, bool& assigned);
00233 };
00234
00250 template<class View>
00251 class Dom : public NaryPropagator<View,PC_INT_DOM> {
00252 protected:
00253 using NaryPropagator<View,PC_INT_DOM>::x;
00255 DomCtrl<View> dc;
00257 Dom(Space& home, bool share, Dom<View>& p);
00259 Dom(Home home, ViewArray<View>& x);
00260 public:
00262 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00269 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00271 virtual Actor* copy(Space& home, bool share);
00273 static ExecStatus post(Home home, ViewArray<View>& x);
00274 };
00275
00282 template<class View>
00283 class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
00284 protected:
00285 using TernaryPropagator<View,PC_INT_DOM>::x0;
00286 using TernaryPropagator<View,PC_INT_DOM>::x1;
00287 using TernaryPropagator<View,PC_INT_DOM>::x2;
00288
00290 TerDom(Space& home, bool share, TerDom<View>& p);
00292 TerDom(Home home, View x0, View x1, View x2);
00293 public:
00295 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00297 virtual Actor* copy(Space& home, bool share);
00299 static ExecStatus post(Home home, View x0, View x1, View x2);
00300 };
00301
00302 }}}
00303
00304 #include <gecode/int/distinct/val.hpp>
00305 #include <gecode/int/distinct/bnd.hpp>
00306 #include <gecode/int/distinct/ter-dom.hpp>
00307 #include <gecode/int/distinct/graph.hpp>
00308 #include <gecode/int/distinct/dom-ctrl.hpp>
00309 #include <gecode/int/distinct/dom.hpp>
00310
00311 #endif
00312
00313
00314