/**** , [ stress_test.cpp ], Copyright (c) 2007 Universite d'Orleans - Jeremie Vautard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *************************************************************************/ #include "qsolver.hh" #include "implicative.hh" #include using namespace std; // This is a set of tiny problems which are used to dtect errors in QeCode. // This set is likely to progressively enlarge... int main() { unsigned long int nodes; unsigned long int steps; // Ax in 1..3 [] -> x=1 int sc1[] = {1}; bool q1[] = {QECODE_UNIVERSAL}; Implicative test1(1,q1,sc1); test1.QIntVar(0,1,3); IntVarArgs b1(1); b1[0] = test1.var(0); branch(test1.space(),b1,INT_VAR_SIZE_MIN,INT_VAL_MIN); test1.nextScope(); post(test1.space(),test1.var(0) == 1); test1.makeStructure(); QSolver s1(&test1); nodes=0; Strategy ret1=s1.solve(nodes); cout<<"Problem 1 : result = "<<(ret1.isFalse()?"FALSE":"TRUE")<<", sould be FALSE."< x=2 int sc3[] = {1}; bool q3[] = {QECODE_UNIVERSAL}; Implicative test3(1,q3,sc3); test3.QIntVar(0,1,3); post(test3.space(),test3.var(0) == 1); IntVarArgs b3(1); b3[0] = test3.var(0); branch(test3.space(),b3,INT_VAR_SIZE_MIN,INT_VAL_MIN); test3.nextScope(); post(test3.space(),test3.var(0) == 2); test3.makeStructure();; QSolver s3(&test3); nodes=0; steps=0; Strategy ret3=s3.solve(nodes); cout<<"Problem 3 : result = "<<(ret3.isFalse()?"FALSE":"TRUE")<<", sould be FALSE."< Ey in 1..3 [x=2] -> y=1 int sc5[] = {1,1}; bool q5[] = {QECODE_UNIVERSAL,QECODE_EXISTENTIAL}; Implicative test5(2,q5,sc5); test5.QIntVar(0,1,3); test5.QIntVar(1,1,3); post(test5.space(),test5.var(0) == 1); IntVarArgs b5(1); b5[0] = test5.var(0); branch(test5.space(),b5,INT_VAR_SIZE_MIN,INT_VAL_MIN); test5.nextScope(); post(test5.space(),test5.var(0) == 2); IntVarArgs b52(2); b52[0] = test5.var(0); b52[1] = test5.var(1); branch(test5.space(),b52,INT_VAR_SIZE_MIN,INT_VAL_MIN); test5.nextScope(); post(test5.space(),test5.var(1) == 1); test5.makeStructure(); QSolver s5(&test5); nodes=0; steps=0; Strategy ret5=s5.solve(nodes); cout<<"Problem 5 : result = "<<(ret5.isFalse()?"FALSE":"TRUE")<<", sould be FALSE."< Ey in 1..3 [x=1] -> x=2 int sc6[] = {1,1}; bool q6[] = {QECODE_UNIVERSAL,QECODE_EXISTENTIAL}; Implicative test6(2,q6,sc6); test6.QIntVar(0,1,3); test6.QIntVar(1,1,3); post(test6.space(),test6.var(0) == 1); IntVarArgs b6(1); b6[0] = test6.var(0); branch(test6.space(),b6,INT_VAR_SIZE_MIN,INT_VAL_MIN); test6.nextScope(); post(test6.space(),test6.var(0) == 1); IntVarArgs b62(2); b62[0] = test6.var(0); b62[1] = test6.var(1); branch(test6.space(),b62,INT_VAR_SIZE_MIN,INT_VAL_MIN); test6.nextScope(); post(test6.space(),test6.var(0) == 2); test6.makeStructure(); QSolver s6(&test6); nodes=0; steps=0; Strategy ret6=s6.solve(nodes); cout<<"Problem 6 : result = "<<(ret6.isFalse()?"FALSE":"TRUE")<<", sould be FALSE."< y=0 int sc7[] = {1,1}; bool q7[] = {QECODE_EXISTENTIAL,QECODE_UNIVERSAL}; Implicative test7(2,q7,sc7); test7.QIntVar(0,1,3); test7.QIntVar(1,0,3); IntVarArgs b7(1); b7[0] = test7.var(0); branch(test7.space(),b7,INT_VAR_SIZE_MIN,INT_VAL_MIN); test7.nextScope(); post(test7.space(),test7.var(1) <= 2); IntVarArgs b72(2); b72[0] = test7.var(0); b72[1] = test7.var(1); branch(test7.space(),b72,INT_VAR_SIZE_MIN,INT_VAL_MIN); test7.nextScope(); post(test7.space(),test7.var(1) == 0); test7.makeStructure(); QSolver s7(&test7); nodes=0; steps=0; Strategy ret7=s7.solve(nodes); cout<<"Problem 7 : result = "<<(ret7.isFalse()?"FALSE":"TRUE")<<", sould be FALSE."< y=0 int sc8[] = {1,1}; bool q8[] = {QECODE_EXISTENTIAL,QECODE_UNIVERSAL}; Implicative test8(2,q8,sc8); test8.QIntVar(0,1,3); test8.QIntVar(1,0,3); IntVarArgs b8(1); b8[0] = test8.var(0); branch(test8.space(),b8,INT_VAR_SIZE_MIN,INT_VAL_MIN); test8.nextScope(); post(test8.space(),test8.var(1) == 0); IntVarArgs b82(2); b82[0] = test8.var(0); b82[1] = test8.var(1); branch(test8.space(),b82,INT_VAR_SIZE_MIN,INT_VAL_MIN); test8.nextScope(); post(test8.space(),test8.var(1) == 0); test8.makeStructure(); QSolver s8(&test8); nodes=0; steps=0; Strategy ret8=s8.solve(nodes); cout<<"Problem 8 : result = "<<(ret8.isFalse()?"FALSE":"TRUE")<<", sould be TRUE."<