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/rel.hh"
00050
00056 namespace Gecode { namespace Int { namespace Distinct {
00057
00066 template <class View>
00067 class Val : public NaryPropagator<View,PC_INT_VAL> {
00068 protected:
00069 using NaryPropagator<View,PC_INT_VAL>::x;
00070
00072 Val(Space* home, ViewArray<View>& x);
00074 Val(Space* home, bool share, Val<View>& p);
00075 public:
00077 virtual Actor* copy(Space* home, bool share);
00079 virtual ExecStatus propagate(Space* home, ModEventDelta med);
00081 virtual Reflection::ActorSpec spec(const Space* home,
00082 Reflection::VarMap& m) const;
00084 static Support::Symbol ati(void);
00086 static void post(Space* home, Reflection::VarMap& vars,
00087 const Reflection::ActorSpec& spec);
00089 static ExecStatus post(Space* home, ViewArray<View>& x);
00090 };
00091
00105 template <class View, bool complete>
00106 ExecStatus prop_val(Space* home, ViewArray<View>&);
00107
00108
00109
00135 template <class View>
00136 class Bnd : public Propagator {
00137 protected:
00139 ViewArray<View> x;
00141 ViewArray<View> y;
00143 Bnd(Space* home, ViewArray<View>& x);
00145 Bnd(Space* home, bool share, Bnd<View>& p);
00146 public:
00148 static ExecStatus post(Space* home, ViewArray<View>& x);
00150 static void post(Space* home, Reflection::VarMap& vars,
00151 const Reflection::ActorSpec& spec);
00153 virtual ExecStatus propagate(Space* home, ModEventDelta med);
00160 virtual PropCost cost(ModEventDelta med) const;
00162 virtual Actor* copy(Space* home, bool share);
00164 virtual size_t dispose(Space* home);
00166 virtual Reflection::ActorSpec spec(const Space* home,
00167 Reflection::VarMap& m) const;
00169 static Support::Symbol ati(void);
00170 };
00171
00180 template <class View>
00181 ExecStatus prop_bnd(Space* home, ViewArray<View>& x, int m);
00182
00183 template <class View> class ViewNode;
00184 template <class View> class ValNode;
00185
00196 template <class View>
00197 class DomCtrl {
00198 protected:
00200 class ViewValGraph {
00201 public:
00203 ViewNode<View>** view;
00205 int n_view;
00207 ValNode<View>* val;
00209 int n_val;
00211 unsigned int count;
00212 public:
00214 ViewValGraph(void);
00216 bool initialized(void) const;
00218 ExecStatus init(Space* home, int n, View* x);
00220 void mark(void);
00222 ExecStatus tell(Space* home, bool& assigned);
00224 void purge(void);
00226 bool sync(void);
00227 public:
00229 typedef Support::SentinelStack<ViewNode<View>*> MatchStack;
00231 bool match(MatchStack& m, ViewNode<View>* x);
00232 };
00234 ViewValGraph vvg;
00235 public:
00237 DomCtrl(void);
00239 bool available(void);
00241 ExecStatus init(Space* home, int n, View* x);
00243 ExecStatus sync(void);
00245 ExecStatus propagate(Space* home, bool& assigned);
00246 };
00247
00263 template <class View>
00264 class Dom : public NaryPropagator<View,PC_INT_DOM> {
00265 protected:
00266 using NaryPropagator<View,PC_INT_DOM>::x;
00268 DomCtrl<View> dc;
00270 Dom(Space* home, bool share, Dom<View>& p);
00272 Dom(Space* home, ViewArray<View>& x);
00273 public:
00275 virtual ExecStatus propagate(Space* home, ModEventDelta med);
00282 virtual PropCost cost(ModEventDelta med) const;
00284 virtual Actor* copy(Space* home, bool share);
00286 virtual Reflection::ActorSpec spec(const Space* home,
00287 Reflection::VarMap& m) const;
00289 static Support::Symbol ati(void);
00291 static ExecStatus post(Space* home, ViewArray<View>& x);
00293 static void post(Space* home, Reflection::VarMap& vars,
00294 const Reflection::ActorSpec& spec);
00295 };
00296
00303 template <class View>
00304 class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
00305 protected:
00306 using TernaryPropagator<View,PC_INT_DOM>::x0;
00307 using TernaryPropagator<View,PC_INT_DOM>::x1;
00308 using TernaryPropagator<View,PC_INT_DOM>::x2;
00309
00311 TerDom(Space* home, bool share, TerDom<View>& p);
00313 TerDom(Space* home, View x0, View x1, View x2);
00314 public:
00316 virtual ExecStatus propagate(Space* home, ModEventDelta med);
00318 virtual Actor* copy(Space* home, bool share);
00320 virtual Reflection::ActorSpec spec(const Space* home,
00321 Reflection::VarMap& m) const;
00323 static Support::Symbol ati(void);
00325 static ExecStatus post(Space* home, View x0, View x1, View x2);
00327 static void post(Space* home, Reflection::VarMap& vars,
00328 const Reflection::ActorSpec& spec);
00329 };
00330
00331 }}}
00332
00333 #include "gecode/int/distinct/val.icc"
00334 #include "gecode/int/distinct/bnd.icc"
00335 #include "gecode/int/distinct/ter-dom.icc"
00336 #include "gecode/int/distinct/dom.icc"
00337
00338 #endif
00339
00340
00341