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 #include "gecode/set/projectors/propagator.hh"
00039
00040 using namespace Gecode::Set;
00041
00042 namespace Gecode {
00043
00044 void projector(Space* home, const SetVar& xa, const SetVar& ya,
00045 ProjectorSet& ps, bool negated) {
00046 if (home->failed()) return;
00047 ViewArray<SetView> x(home, 2);
00048 x[0] = xa; x[1] = ya;
00049 if (negated) {
00050 GECODE_ES_FAIL(home,
00051 (Projection::NaryProjection<true>::post(home,
00052 x, ps)));
00053 } else {
00054 GECODE_ES_FAIL(home,
00055 (Projection::NaryProjection<false>::post(home,
00056 x, ps)));
00057 }
00058
00059 }
00060
00061 void projector(Space* home, const SetVarArgs& xa,
00062 ProjectorSet& ps, bool negated) {
00063 if (home->failed()) return;
00064 ViewArray<SetView> x(home, xa.size());
00065 for (int i=x.size(); i--;)
00066 x[i] = xa[i];
00067 if (negated) {
00068 GECODE_ES_FAIL(home,
00069 (Projection::NaryProjection<true>::post(home,
00070 x, ps)));
00071 } else {
00072 GECODE_ES_FAIL(home,
00073 (Projection::NaryProjection<false>::post(home,
00074 x, ps)));
00075 }
00076
00077 }
00078
00079 void projector(Space* home, const SetVar& xa, const SetVar& ya,
00080 const BoolVar& bv, ProjectorSet& ps) {
00081 if (home->failed()) return;
00082 ViewArray<SetView> x(home, 2);
00083 x[0] = xa; x[1] = ya;
00084 Gecode::Int::BoolView b(bv);
00085 GECODE_ES_FAIL(home,
00086 (Projection::ReNaryProjection::post(home,
00087 x, b, ps)));
00088 }
00089
00090 void projector(Space* home,
00091 const SetVar& xa, const SetVar& ya, const SetVar& za,
00092 ProjectorSet& ps, bool negated) {
00093 if (home->failed()) return;
00094 ViewArray<SetView> x(home, 3);
00095 x[0] = xa; x[1] = ya; x[2] = za;
00096 if (negated) {
00097 GECODE_ES_FAIL(home,
00098 (Projection::NaryProjection<true>::post(home,
00099 x, ps)));
00100 } else {
00101 GECODE_ES_FAIL(home,
00102 (Projection::NaryProjection<false>::post(home,
00103 x, ps)));
00104 }
00105
00106 }
00107
00108 void projector(Space* home,
00109 const SetVar& xa, const SetVar& ya, const SetVar& za,
00110 const BoolVar& bv, ProjectorSet& ps) {
00111 if (home->failed()) return;
00112 ViewArray<SetView> x(home, 3);
00113 x[0] = xa; x[1] = ya; x[2] = za;
00114 Gecode::Int::BoolView b(bv);
00115 GECODE_ES_FAIL(home,
00116 (Projection::ReNaryProjection::post(home,
00117 x, b, ps)));
00118 }
00119
00120 void projector(Space* home, const SetVar& xa, const SetVar& ya,
00121 const IntVar& i, Projector& p) {
00122 if (home->failed()) return;
00123 ViewArray<SetView> x(home, 2);
00124 x[0] = xa; x[1] = ya;
00125 Gecode::Int::IntView iv(i);
00126 GECODE_ES_FAIL(home,
00127 (Projection::CardProjection::post(home,x,i,p)));
00128 }
00129
00130 void projector(Space* home, const SetVar& xa, const SetVar& ya,
00131 const SetVar& za, const IntVar& i, Projector& p) {
00132 if (home->failed()) return;
00133 ViewArray<SetView> x(home, 3);
00134 x[0] = xa; x[1] = ya; x[2] = za;
00135 Gecode::Int::IntView iv(i);
00136 GECODE_ES_FAIL(home,
00137 (Projection::CardProjection::post(home,x,i,p)));
00138 }
00139
00140
00141 }
00142
00143