/**** , [ qsolver_qcop.cc ], Copyright (c) 2010 Universite de Caen Basse Normandie - 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_qcop.hh" #include QCOP_solver::QCOP_solver(Qcop* sp) { this->sp = sp; nbRanges=new int; } Strategy QCOP_solver::solve(unsigned long int& nodes) { vector plop; plop.clear(); return rSolve(sp,0,plop,nodes); } Strategy QCOP_solver::rSolve(Qcop* qs,int scope, vector assignments, unsigned long int& nodes) { nodes++; // cout<<"rSolve for scope "<spaces()) { // cout<<"First case"<getGoal(); if (g == NULL) {/*cout<<"the goal was null"<nbVars();i++) { switch (g->type_of_v[i]) { case VTYPE_INT : rel(*g,*(static_cast(g->v[i])) == assignments[i]); break; case VTYPE_BOOL : rel(*g,*(static_cast(g->v[i])) == assignments[i]); break; default : cout<<"1Unknown variable type"<status() == SS_FAILED) { // cout<<"goal failed after assignments"<getSpace(scope); if (espace == NULL) cout<<"I caught a NULL for scope "<type_of_v[i]) { case VTYPE_INT : rel(*espace,*(static_cast(espace->v[i])) == assignments[i]); break; case VTYPE_BOOL : rel(*espace,*(static_cast(espace->v[i])) == assignments[i]); break; default : cout<<"2Unknown variable type"<quantification(scope)) { // cout<<"universal"<status() == SS_FAILED) { // cout<<"the scope is failed"< solutions(espace); MySpace* sol = solutions.next(); if (sol == NULL) { // cout<<"first sol is null"< assign; for (int i = 0; inbVars();i++) { switch (sol->type_of_v[i]) { case VTYPE_INT : assign.push_back( (static_cast(sol->v[i]))->val() ); break; case VTYPE_BOOL : assign.push_back( (static_cast(sol->v[i]))->val() ); break; default : cout<<"3Unknown variable type"<nbVarInScope(scope-1)) ); int vmax = (qs->nbVarInScope(scope))-1; vector zevalues; for (int i = vmin; i<=vmax;i++) { switch (sol->type_of_v[i]) { case VTYPE_INT : zevalues.push_back( (static_cast(sol->v[i]))->val() ); break; case VTYPE_BOOL : zevalues.push_back( (static_cast(sol->v[i]))->val() ); break; default : cout<<"4Unknown variable type"<status()) == SS_FAILED) { // cout<<"the Espace is failed"< solutions(espace); MySpace* sol =solutions.next(); if (sol == NULL) { // cout<<"the first sol is null"<getOptVar(scope); int opttype = qs->getOptType(scope); Strategy retour(StrategyNode::SFalse()); int score= ( (opttype == 1) ? INT_MAX : INT_MIN ); while (sol != NULL) { // cout<<"une solution"< assign; for (int i = 0; inbVars();i++) { switch (sol->type_of_v[i]) { case VTYPE_INT : assign.push_back( (static_cast(sol->v[i]))->val() ); break; case VTYPE_BOOL : assign.push_back( (static_cast(sol->v[i]))->val() ); break; default : cout<<"5Unknown variable type"<nbVarInScope(scope-1) ); int vmax = qs->nbVarInScope(scope)-1; vector zevalues; for (int i = vmin; i<=vmax;i++) { switch (sol->type_of_v[i]) { case VTYPE_INT : zevalues.push_back( (static_cast(sol->v[i]))->val() ); break; case VTYPE_BOOL : zevalues.push_back( (static_cast(sol->v[i]))->val() ); break; default : cout<<"6unknown Variable type"<getVal(candidate); // cout<<"score of candidate is "< score) { retour=candidate; score=score_of_candidate; } break; default : cout<<"Unknown opt type : "<