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 "test/set.hh"
00035
00036 using namespace Gecode;
00037
00038 namespace Test { namespace Set {
00039
00041 namespace Var {
00042
00044 class Construct : public SetTest {
00045 public:
00047 Construct(void)
00048 : SetTest("Var::Construct",1,IntSet(0,0),false,0) {}
00050 virtual bool solution(const SetAssignment&) const {
00051 return true;
00052 }
00053 void con(Space& home, int glbMin, int glbMax,
00054 int lubMin, int lubMax,
00055 unsigned int minCard = 0,
00056 unsigned int maxCard = Gecode::Set::Limits::card,
00057 bool fail=true) {
00058 bool ok = false;
00059 try {
00060 SetVar x(home, glbMin, glbMax, lubMin, lubMax, minCard, maxCard);
00061 ok = true;
00062 } catch (Gecode::Set::VariableEmptyDomain&) {
00063 if (!fail) {
00064 home.fail();
00065 return;
00066 }
00067 ok = true;
00068 }
00069
00070 if (ok) {
00071 try {
00072 SetVarArray xs(home, 1,
00073 glbMin, glbMax, lubMin, lubMax, minCard, maxCard);
00074 } catch (Gecode::Set::VariableEmptyDomain&) {
00075 if (!fail) {
00076 home.fail();
00077 return;
00078 } else {
00079 return;
00080 }
00081 }
00082 if (fail) {
00083 home.fail();
00084 }
00085 }
00086 }
00087 void con(Space& home, const IntSet& glb, int lubMin, int lubMax,
00088 unsigned int minCard = 0,
00089 unsigned int maxCard = Gecode::Set::Limits::card,
00090 bool fail=true) {
00091 bool ok = false;
00092 try {
00093 SetVar x(home, glb, lubMin, lubMax, minCard, maxCard);
00094 ok = true;
00095 } catch (Gecode::Set::VariableEmptyDomain&) {
00096 if (!fail) {
00097 home.fail();
00098 return;
00099 }
00100 ok = true;
00101 }
00102 if (ok) {
00103 try {
00104 SetVarArray xs(home, 1,
00105 glb, lubMin, lubMax, minCard, maxCard);
00106 } catch (Gecode::Set::VariableEmptyDomain&) {
00107 if (!fail) {
00108 home.fail();
00109 return;
00110 } else {
00111 return;
00112 }
00113 }
00114 if (fail) {
00115 home.fail();
00116 }
00117 }
00118 }
00119 void con(Space& home, int glbMin, int glbMax, const IntSet& lub,
00120 unsigned int minCard = 0,
00121 unsigned int maxCard = Gecode::Set::Limits::card,
00122 bool fail=true) {
00123 bool ok = false;
00124 try {
00125 SetVar x(home, glbMin, glbMax, lub, minCard, maxCard);
00126 ok = true;
00127 } catch (Gecode::Set::VariableEmptyDomain&) {
00128 if (!fail) {
00129 home.fail();
00130 return;
00131 }
00132 ok = true;
00133 }
00134 if (ok) {
00135 try {
00136 SetVarArray xs(home, 1,
00137 glbMin, glbMax, lub, minCard, maxCard);
00138 } catch (Gecode::Set::VariableEmptyDomain&) {
00139 if (!fail) {
00140 home.fail();
00141 return;
00142 } else {
00143 return;
00144 }
00145 }
00146 if (fail) {
00147 home.fail();
00148 }
00149 }
00150 }
00151 void con(Space& home, const IntSet& glb, const IntSet& lub,
00152 unsigned int minCard = 0,
00153 unsigned int maxCard = Gecode::Set::Limits::card,
00154 bool fail=true) {
00155 bool ok = false;
00156 try {
00157 SetVar x(home, glb, lub, minCard, maxCard);
00158 ok = true;
00159 } catch (Gecode::Set::VariableEmptyDomain&) {
00160 if (!fail) {
00161 home.fail();
00162 return;
00163 }
00164 ok = true;
00165 }
00166 if (ok) {
00167 try {
00168 SetVarArray xs(home, 1,
00169 glb, lub, minCard, maxCard);
00170 } catch (Gecode::Set::VariableEmptyDomain&) {
00171 if (!fail) {
00172 home.fail();
00173 return;
00174 } else {
00175 return;
00176 }
00177 }
00178 if (fail) {
00179 home.fail();
00180 }
00181 }
00182 }
00184 virtual void post(Space& home, SetVarArray&, IntVarArray&) {
00185
00186 con(home, 1,1, 1,0);
00187 con(home, IntSet(1,1), 1,0);
00188 con(home, 1,1, IntSet(1,0));
00189 con(home, IntSet(1,1), IntSet(1,0));
00190
00191
00192 con(home, 1,0, 1,1, 2,3);
00193 con(home, IntSet(1,0), 1,1, 2U,3U);
00194 con(home, 1,0, IntSet(1,1), 2U,3U);
00195 con(home, IntSet(1,0), IntSet(1,1), 2U,3U);
00196
00197
00198 con(home, 1,3, 1,4, 0,2);
00199 con(home, IntSet(1,3), 1,4, 0U,2U);
00200 con(home, 1,3, IntSet(1,4), 0U,2U);
00201 con(home, IntSet(1,3), IntSet(1,4), 0U,2U);
00202
00203
00204 con(home, 1,3, 2,4);
00205 con(home, IntSet(1,3), 2,4);
00206 con(home, 1,3, IntSet(2,4));
00207 con(home, IntSet(1,3), IntSet(2,4));
00208 con(home, 1,4, 1,3);
00209 con(home, IntSet(1,4), 1,3);
00210 con(home, 1,4, IntSet(1,3));
00211 con(home, IntSet(1,4), IntSet(1,3));
00212
00213 con(home, IntSet::empty, 2, 4, 0U, 10U, false);
00214 }
00215 };
00216 Construct _con;
00217
00218
00219 }}}
00220
00221