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/int/extensional.hh>
00039
00040 namespace Gecode {
00041
00042 void
00043 extensional(Home home, const IntVarArgs& x, const TupleSet& t, bool pos,
00044 IntPropLevel) {
00045 using namespace Int;
00046 if (!t.finalized())
00047 throw NotYetFinalized("Int::extensional");
00048 if (t.arity() != x.size())
00049 throw ArgumentSizeMismatch("Int::extensional");
00050 GECODE_POST;
00051
00052 ViewArray<IntView> xv(home,x);
00053 if (pos)
00054 GECODE_ES_FAIL((Extensional::postposcompact<IntView>(home,xv,t)));
00055 else
00056 GECODE_ES_FAIL((Extensional::postnegcompact<IntView>(home,xv,t)));
00057 }
00058
00059 void
00060 extensional(Home home, const IntVarArgs& x, const TupleSet& t, bool pos,
00061 Reify r,
00062 IntPropLevel) {
00063 using namespace Int;
00064 if (!t.finalized())
00065 throw NotYetFinalized("Int::extensional");
00066 if (t.arity() != x.size())
00067 throw ArgumentSizeMismatch("Int::extensional");
00068 GECODE_POST;
00069
00070 ViewArray<IntView> xv(home,x);
00071 if (pos) {
00072 switch (r.mode()) {
00073 case RM_EQV:
00074 GECODE_ES_FAIL((Extensional::postrecompact<IntView,BoolView,RM_EQV>
00075 (home,xv,t,r.var())));
00076 break;
00077 case RM_IMP:
00078 GECODE_ES_FAIL((Extensional::postrecompact<IntView,BoolView,RM_IMP>
00079 (home,xv,t,r.var())));
00080 break;
00081 case RM_PMI:
00082 GECODE_ES_FAIL((Extensional::postrecompact<IntView,BoolView,RM_PMI>
00083 (home,xv,t,r.var())));
00084 break;
00085 default: throw UnknownReifyMode("Int::extensional");
00086 }
00087 } else {
00088 NegBoolView n(r.var());
00089 switch (r.mode()) {
00090 case RM_EQV:
00091 GECODE_ES_FAIL((Extensional::postrecompact<IntView,NegBoolView,RM_EQV>
00092 (home,xv,t,n)));
00093 break;
00094 case RM_IMP:
00095 GECODE_ES_FAIL((Extensional::postrecompact<IntView,NegBoolView,RM_PMI>
00096 (home,xv,t,n)));
00097 break;
00098 case RM_PMI:
00099 GECODE_ES_FAIL((Extensional::postrecompact<IntView,NegBoolView,RM_IMP>
00100 (home,xv,t,n)));
00101 break;
00102 default: throw UnknownReifyMode("Int::extensional");
00103 }
00104 }
00105 }
00106
00107 void
00108 extensional(Home home, const BoolVarArgs& x, const TupleSet& t, bool pos,
00109 IntPropLevel) {
00110 using namespace Int;
00111 if (!t.finalized())
00112 throw NotYetFinalized("Int::extensional");
00113 if (t.arity() != x.size())
00114 throw ArgumentSizeMismatch("Int::extensional");
00115 if ((t.min() < 0) || (t.max() > 1))
00116 throw NotZeroOne("Int::extensional");
00117 GECODE_POST;
00118
00119 ViewArray<BoolView> xv(home,x);
00120 if (pos)
00121 GECODE_ES_FAIL((Extensional::postposcompact<BoolView>(home,xv,t)));
00122 else
00123 GECODE_ES_FAIL((Extensional::postnegcompact<BoolView>(home,xv,t)));
00124 }
00125
00126 void
00127 extensional(Home home, const BoolVarArgs& x, const TupleSet& t, bool pos,
00128 Reify r,
00129 IntPropLevel) {
00130 using namespace Int;
00131 if (!t.finalized())
00132 throw NotYetFinalized("Int::extensional");
00133 if (t.arity() != x.size())
00134 throw ArgumentSizeMismatch("Int::extensional");
00135 if ((t.min() < 0) || (t.max() > 1))
00136 throw NotZeroOne("Int::extensional");
00137 GECODE_POST;
00138
00139 ViewArray<BoolView> xv(home,x);
00140 if (pos) {
00141 switch (r.mode()) {
00142 case RM_EQV:
00143 GECODE_ES_FAIL((Extensional::postrecompact<BoolView,BoolView,RM_EQV>
00144 (home,xv,t,r.var())));
00145 break;
00146 case RM_IMP:
00147 GECODE_ES_FAIL((Extensional::postrecompact<BoolView,BoolView,RM_IMP>
00148 (home,xv,t,r.var())));
00149 break;
00150 case RM_PMI:
00151 GECODE_ES_FAIL((Extensional::postrecompact<BoolView,BoolView,RM_PMI>
00152 (home,xv,t,r.var())));
00153 break;
00154 default: throw UnknownReifyMode("Int::extensional");
00155 }
00156 } else {
00157 NegBoolView n(r.var());
00158 switch (r.mode()) {
00159 case RM_EQV:
00160 GECODE_ES_FAIL((Extensional::postrecompact<BoolView,NegBoolView,RM_EQV>
00161 (home,xv,t,n)));
00162 break;
00163 case RM_IMP:
00164 GECODE_ES_FAIL((Extensional::postrecompact<BoolView,NegBoolView,RM_PMI>
00165 (home,xv,t,n)));
00166 break;
00167 case RM_PMI:
00168 GECODE_ES_FAIL((Extensional::postrecompact<BoolView,NegBoolView,RM_IMP>
00169 (home,xv,t,n)));
00170 break;
00171 default: throw UnknownReifyMode("Int::extensional");
00172 }
00173 }
00174 }
00175
00176 }
00177
00178