set.cpp
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
00035
00036
00037
00038
00039
00040 #include <gecode/set.hh>
00041
00042
00043 namespace Gecode { namespace Set {
00044
00045
00046
00047
00048
00049 ModEvent
00050 SetVarImp::cardMin_full(Space& home) {
00051 ModEvent me = ME_SET_CARD;
00052 if (cardMin() == lub.size()) {
00053 glb.become(home, lub);
00054 me = ME_SET_VAL;
00055 }
00056 SetDelta d;
00057 return notify(home, me, d);
00058 }
00059
00060 ModEvent
00061 SetVarImp::cardMax_full(Space& home) {
00062 ModEvent me = ME_SET_CARD;
00063 if (cardMax() == glb.size()) {
00064 lub.become(home, glb);
00065 me = ME_SET_VAL;
00066 }
00067 SetDelta d;
00068 return notify(home, me, d);
00069 }
00070
00071 ModEvent
00072 SetVarImp::processLubChange(Space& home, SetDelta& d) {
00073 ModEvent me = ME_SET_LUB;
00074 if (cardMax() > lub.size()) {
00075 lub.card(lub.size());
00076 if (cardMin() > cardMax()) {
00077 glb.become(home, lub);
00078 glb.card(glb.size());
00079 lub.card(glb.size());
00080 return fail(home);
00081 }
00082 me = ME_SET_CLUB;
00083 }
00084 if (cardMax() == lub.size() && cardMin() == cardMax()) {
00085 glb.become(home, lub);
00086 me = ME_SET_VAL;
00087 assert(d.glbMin() == 1);
00088 assert(d.glbMax() == 0);
00089 }
00090 return notify(home, me, d);
00091 }
00092
00093 ModEvent
00094 SetVarImp::processGlbChange(Space& home, SetDelta& d) {
00095 ModEvent me = ME_SET_GLB;
00096 if (cardMin() < glb.size()) {
00097 glb.card(glb.size());
00098 if (cardMin() > cardMax()) {
00099 glb.become(home, lub);
00100 glb.card(glb.size());
00101 lub.card(glb.size());
00102 return fail(home);
00103 }
00104 me = ME_SET_CGLB;
00105 }
00106 if (cardMin() == glb.size() && cardMin() == cardMax()) {
00107 lub.become(home, glb);
00108 me = ME_SET_VAL;
00109 assert(d.lubMin() == 1);
00110 assert(d.lubMax() == 0);
00111 }
00112 return notify(home, me, d);
00113 }
00114
00115
00116
00117
00118
00119
00120 forceinline
00121 SetVarImp::SetVarImp(Space& home, bool share, SetVarImp& x)
00122 : SetVarImpBase(home,share,x) {
00123 lub.update(home, x.lub);
00124 glb.card(x.cardMin());
00125 lub.card(x.cardMax());
00126 if (x.assigned()) {
00127 glb.become(home,lub);
00128 } else {
00129 glb.update(home,x.glb);
00130 }
00131 }
00132
00133
00134 SetVarImp*
00135 SetVarImp::perform_copy(Space& home, bool share) {
00136 return new (home) SetVarImp(home,share,*this);
00137 }
00138
00139
00140
00141
00142
00143 void
00144 SetVarImp::subscribe(Space& home, Propagator& p, PropCond pc,
00145 bool schedule) {
00146 SetVarImpBase::subscribe(home,p,pc,assigned(),schedule);
00147 }
00148 void
00149 SetVarImp::subscribe(Space& home, Advisor& a, bool fail) {
00150 SetVarImpBase::subscribe(home,a,assigned(),fail);
00151 }
00152 void
00153 SetVarImp::reschedule(Space& home, Propagator& p, PropCond pc) {
00154 SetVarImpBase::reschedule(home,p,pc,assigned());
00155 }
00156
00157
00158 }}
00159
00160
00161