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