00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "qsolver.hh"
00024 #include "implicative.hh"
00025 #include "SDFVariableHeuristic.hh"
00026 #include "NaiveValueHeuristics.hh"
00027
00028
00029
00030
00031
00032 int main() {
00033 unsigned long int nodes;
00034 unsigned long int steps;
00035 SmallestDomainFirst heur;
00036 SmallestValueFirst vHeur;
00037
00038
00039 int sc1[] = {1};
00040 Implicative test1(1,QECODE_UNIVERSAL,sc1);
00041 test1.QIntVar(0,1,3);
00042 test1.nextScope();
00043 post(test1.space(),test1.var(0) == 1);
00044 test1.makeStructure();
00045 QSolver s1(&test1,&heur,&vHeur);
00046 nodes=0;
00047 steps=0;
00048 bool ret1=s1.solve(nodes,steps);
00049 cout<<"Problem 1 : result = "<<(ret1?"TRUE":"FALSE")<<", sould be FALSE."<<endl;
00050 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00051
00052
00053
00054 int sc2[] = {1};
00055 Implicative test2(1,QECODE_EXISTENTIAL,sc2);
00056 test2.QIntVar(0,1,3);
00057 test2.nextScope();
00058 post(test2.space(),test2.var(0) == 1);
00059 test2.makeStructure();
00060 QSolver s2(&test2,&heur,&vHeur);
00061 nodes=0;
00062 steps=0;
00063 bool ret2=s2.solve(nodes,steps);
00064 cout<<"Problem 2 : result = "<<(ret2?"TRUE":"FALSE")<<", sould be TRUE."<<endl;
00065 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00066
00067
00068
00069
00070 int sc3[] = {1};
00071 Implicative test3(1,QECODE_UNIVERSAL,sc3);
00072 test3.QIntVar(0,1,3);
00073 post(test3.space(),test3.var(0) == 1);
00074 test3.nextScope();
00075 post(test3.space(),test3.var(0) == 2);
00076 test3.makeStructure();;
00077 QSolver s3(&test3,&heur,&vHeur);
00078 nodes=0;
00079 steps=0;
00080 bool ret3=s3.solve(nodes,steps);
00081 cout<<"Problem 3 : result = "<<(ret3?"TRUE":"FALSE")<<", sould be FALSE."<<endl;
00082 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00083
00084
00085
00086 int sc4[] = {1};
00087 Implicative test4(1,QECODE_EXISTENTIAL,sc4);
00088 test4.QIntVar(0,1,3);
00089 post(test4.space(),test4.var(0) == 1);
00090 test4.nextScope();
00091 post(test4.space(),test4.var(0) == 2);
00092 test4.makeStructure();
00093 QSolver s4(&test4,&heur,&vHeur);
00094 nodes=0;
00095 steps=0;
00096 bool ret4=s4.solve(nodes,steps);
00097 cout<<"Problem 4 : result = "<<(ret4?"TRUE":"FALSE")<<", sould be FALSE."<<endl;
00098 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00099
00100
00101
00102 int sc5[] = {1,1};
00103 Implicative test5(2,QECODE_UNIVERSAL,sc5);
00104 test5.QIntVar(0,1,3);
00105 test5.QIntVar(1,1,3);
00106 post(test5.space(),test5.var(0) == 1);
00107 test5.nextScope();
00108 post(test5.space(),test5.var(0) == 2);
00109 test5.nextScope();
00110 post(test5.space(),test5.var(1) == 1);
00111 test5.makeStructure();
00112 QSolver s5(&test5,&heur,&vHeur);
00113 nodes=0;
00114 steps=0;
00115 bool ret5=s5.solve(nodes,steps);
00116 cout<<"Problem 5 : result = "<<(ret5?"TRUE":"FALSE")<<", sould be FALSE."<<endl;
00117 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00118
00119
00120
00121 int sc6[] = {1,1};
00122 Implicative test6(2,QECODE_UNIVERSAL,sc6);
00123 test6.QIntVar(0,1,3);
00124 test6.QIntVar(1,1,3);
00125 post(test6.space(),test6.var(0) == 1);
00126 test6.nextScope();
00127 post(test6.space(),test6.var(0) == 1);
00128 test6.nextScope();
00129 post(test6.space(),test6.var(0) == 2);
00130 test6.makeStructure();
00131 QSolver s6(&test6,&heur,&vHeur);
00132 nodes=0;
00133 steps=0;
00134 bool ret6=s6.solve(nodes,steps);
00135 cout<<"Problem 6 : result = "<<(ret6?"TRUE":"FALSE")<<", sould be FALSE."<<endl;
00136 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00137
00138
00139
00140 int sc7[] = {1,1};
00141 Implicative test7(2,QECODE_EXISTENTIAL,sc7);
00142 test7.QIntVar(0,1,3);
00143 test7.QIntVar(1,0,3);
00144 test7.nextScope();
00145 post(test7.space(),test7.var(1) <= 2);
00146 test7.nextScope();
00147 post(test7.space(),test7.var(1) == 0);
00148 test7.makeStructure();
00149 QSolver s7(&test7,&heur,&vHeur);
00150 nodes=0;
00151 steps=0;
00152 bool ret7=s7.solve(nodes,steps);
00153 cout<<"Problem 7 : result = "<<(ret7?"TRUE":"FALSE")<<", sould be FALSE."<<endl;
00154 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00155
00156
00157
00158 int sc8[] = {1,1};
00159 Implicative test8(2,QECODE_EXISTENTIAL,sc8);
00160 test8.QIntVar(0,1,3);
00161 test8.QIntVar(1,0,3);
00162 test8.nextScope();
00163 post(test8.space(),test8.var(1) == 0);
00164 test8.nextScope();
00165 post(test8.space(),test8.var(1) == 0);
00166 test8.makeStructure();
00167 QSolver s8(&test8,&heur,&vHeur);
00168 nodes=0;
00169 steps=0;
00170 bool ret8=s8.solve(nodes,steps);
00171 cout<<"Problem 8 : result = "<<(ret8?"TRUE":"FALSE")<<", sould be TRUE."<<endl;
00172 cout<<nodes<<" nodes and "<<steps<<" steps."<<endl;
00173
00174
00175
00176
00177 }
00178
00179