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:
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
00387