this repo has no description
at develop 2.7 kB view raw
1/**** , [ qsolver.hh ], 2Copyright (c) 2010 Universite de Caen-Basse Normandie - Jeremie Vautard 3 4Permission is hereby granted, free of charge, to any person obtaining a copy 5of this software and associated documentation files (the "Software"), to deal 6in the Software without restriction, including without limitation the rights 7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8copies of the Software, and to permit persons to whom the Software is 9furnished to do so, subject to the following conditions: 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20THE SOFTWARE. 21 *************************************************************************/ 22#ifndef __QECODE_QSOLVER_QCSP__ 23#define __QECODE_QSOLVER_QCSP__ 24 25#include "QCOPPlus.hh" 26#include <iostream> 27#include <cstdlib> 28#include "gecode/minimodel.hh" 29#include "gecode/search.hh" 30#include "gecode/search/support.hh" 31#include "gecode/search/sequential/dfs.hh" 32#include <climits> 33#include "Strategy.hh" 34#include "qecode.hh" 35 36using namespace std; 37using namespace Gecode::Support; 38using namespace Gecode::Search; 39using namespace Gecode::Search::Sequential; 40 41/** General QCSP+ / QCOP+ Solver. 42 * This class is the search engine for Qcop objects. 43*/ 44class QECODE_VTABLE_EXPORT QCSP_Solver { 45 46private: 47 unsigned int limit; 48 int n; 49 Qcop* sp; 50 int* nbRanges; 51 Strategy rSolve(Qcop* qs,int scope,Engine* L,unsigned long int& nodes,bool allStrategies); 52public: 53 /** Public constructor. 54 @param sp The problem to solve 55 */ 56 QECODE_EXPORT QCSP_Solver(Qcop* sp); 57 58 /** Solves the problem and returns a corresponding winning strategy. 59 @param nodes : A reference that is increased by the number of nodes encountered in the search tree. 60 @param limit : limit of the depth of the Strategy object returned. Any branch longer than this limit will be truncated. 61 @param allStrategies : indicate if the solver should return only one winning strategy, or all of them (condensed in one Strategy object, where existential nodes will not be unique) 62 */ 63 QECODE_EXPORT Strategy solve(unsigned long int& nodes,unsigned int limit=INT_MAX,bool allStrategies=false); 64}; 65 66#endif