/Users/jamian/Desktop/gecode-2.0.1/contribs/qecode/qecore.hh

Go to the documentation of this file.
00001 /*****************************************************************[qecore.hh]
00002 Copyright (c) 2007, Universite d'Orleans - Jeremie Vautard, Marco Benedetti,
00003 Arnaud Lallouet.
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021 THE SOFTWARE.
00022 *****************************************************************************/
00023 #ifndef __QECODE_QECORE__
00024 #define __QECODE_QECORE__
00025 
00026 
00027 #include "qecode.hh"
00028 #include <cstdlib>
00029 #include <vector>
00030 #include <list>
00031 #include <stack>
00032 #include "extensivecomparator.hh"
00033 #include "heap.cc"
00034 #include "gecode/minimodel.hh"
00035 #include "vartype.hh"
00036 
00037 using namespace Gecode;
00038 using namespace std;
00039 using namespace Gecode::Int;
00040 
00041 
00042 class BranchingHeuristic;
00043 
00044 
00048 class QECODE_VTABLE_EXPORT QSpace {
00049 protected:
00050   unsigned int n; 
00051   unsigned long int ps;
00052 public:
00053 
00055   QECODE_EXPORT QSpace();
00056 
00057 
00059   QECODE_EXPORT QSpace(QSpace& qs);
00060 
00061   QECODE_EXPORT virtual ~QSpace() {delete [] v;}
00062 
00063 
00067   QECODE_EXPORT int nv() {return n;}
00068 
00069 
00073   void** v;
00074   
00079   VarType* type_of_v;
00080 
00081 
00086   virtual bool quantification(int v)=0;
00087 
00088 
00089 
00095   virtual int status(int var, unsigned long int& propsteps)=0;
00096 
00101   virtual int finalStatus(unsigned long int& propsteps)=0;
00102 
00107   virtual bool subsumed(int var)=0;
00108 
00109 
00112   virtual QSpace* clone()=0; 
00113 
00114 
00121   virtual void assign_int(int var,int** vals,int nbVals)=0;
00122   
00129   virtual void remove_int(int var,int** vals,int nbVals)=0;
00130   
00137   virtual void assign_bool(int var,int** vals,int nbVals)=0;
00138   
00145   virtual void remove_bool(int var,int** vals,int nbVals)=0;
00146   
00152   virtual void assign_bool(int var,int b)=0;
00153 
00159   virtual void remove_bool(int var,int b)=0;
00160   
00161 
00165   virtual void backtrack()=0;       
00166 
00167 
00171   virtual void indicateBranchingHeuristic(BranchingHeuristic* bh)=0;
00172   
00175   virtual void print()=0;
00176 };
00177 
00178 
00179 
00183 class VariableHeuristic {    
00184 public:
00185 
00191   virtual int score(QSpace* qs,int var)=0;
00192 };
00193 
00194 
00195 typedef Heap<ExtensiveComparator> cheap;
00196 typedef stack<int> stackint;
00197 
00198 
00199 
00203 class QECODE_VTABLE_EXPORT BranchingHeuristic {
00204 private : 
00205   int size;
00206   int blocks;
00207   int* bloc; 
00208   stackint treated;
00209   cheap* heaps;
00210   stackint touched;
00211   int* score;
00212   int curHeap;
00213   VariableHeuristic* eval;
00214 
00215 public : 
00216       QECODE_EXPORT void updateVar(int pos, QSpace* qs);
00217 
00223   QECODE_EXPORT BranchingHeuristic(QSpace* qs, VariableHeuristic* ev);
00224 
00228   QECODE_EXPORT int nextVar(QSpace* qs);
00229 
00230 
00234   QECODE_EXPORT void backtrack(QSpace* qs);
00235 
00236 
00237 
00241   QECODE_EXPORT void vartouched(int pos,QSpace* qs);
00242 };
00243 
00244 
00245 
00246 
00247 #endif

Generated on Thu Feb 7 14:33:45 2008 for qecode by  doxygen 1.5.2