propagate.hpp
Go to the documentation of this file.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 #include <gecode/int/rel.hh>
00035
00036 namespace Gecode { namespace Int { namespace Order {
00037
00038 forceinline
00039 OrderProp::OrderProp(Home home, IntView _s0, int _p0, IntView _s1, int _p1,
00040 BoolView _b)
00041 : Propagator(home), s0(_s0), s1(_s1), b(_b), p0(_p0), p1(_p1) {
00042 s0.subscribe(home,*this,PC_INT_BND);
00043 s1.subscribe(home,*this,PC_INT_BND);
00044 b.subscribe(home,*this,PC_INT_VAL);
00045 }
00046
00047 forceinline ExecStatus
00048 OrderProp::post(Home home, IntView s0, int p0, IntView s1, int p1,
00049 BoolView b) {
00050 if (s0.max() + p0 <= s1.min()) {
00051 GECODE_ME_CHECK(b.zero(home));
00052 } else if (s1.max() + p1 <= s0.min()) {
00053 GECODE_ME_CHECK(b.one(home));
00054 } else if ((s1.min() + p1 > s0.max()) || b.zero()) {
00055 GECODE_ME_CHECK(b.zero(home));
00056 return Rel::Lq<OffsetView,IntView>::post(home,OffsetView(s0,p0),s1);
00057 } else if ((s0.min() + p0 > s1.max()) || b.one()) {
00058 GECODE_ME_CHECK(b.one(home));
00059 return Rel::Lq<OffsetView,IntView>::post(home,OffsetView(s1,p1),s0);
00060 } else {
00061 (void) new (home) OrderProp(home,s0,p0,s1,p1,b);
00062 }
00063 return ES_OK;
00064 }
00065
00066 forceinline
00067 OrderProp::OrderProp(Space& home, OrderProp& p)
00068 : Propagator(home,p), p0(p.p0), p1(p.p1) {
00069 s0.update(home,p.s0);
00070 s1.update(home,p.s1);
00071 b.update(home,p.b);
00072 }
00073
00074 }}}
00075
00076