this repo has no description
at develop 1.6 kB view raw
1/* 2 * WorkComparators.hh 3 * 4 * 5 * Created by Jérémie Vautard on 31/03/10. 6 * Copyright 2010 Université d'Orléans. All rights reserved. 7 * 8 */ 9 10#include "WorkManager.hh" 11#include "QCOPPlus.hh" 12 13class BidonComparator : public WorkComparator { 14 public : 15 virtual bool cmp(QWork a,QWork b) { 16 return false; 17 } 18}; 19 20class DeepFirstComparator : public WorkComparator { 21 public : 22 virtual bool cmp(QWork a,QWork b) { 23 if (a.root().size() > b.root().size()) return true; 24 if (a.root().size() < b.root().size()) return false; 25 return ((a.getRemaining()) < (b.getRemaining())); 26 } 27}; 28 29class QuantifierThenDepthComparator : public WorkComparator { 30 private : 31 Qcop* problem; 32 bool existsFirst; 33 bool deepestFirst; 34 35 public : 36 QuantifierThenDepthComparator(Qcop* p,bool existsFirst,bool deepestFirst) { 37 this->problem = p; 38 this->existsFirst = existsFirst; 39 this->deepestFirst = deepestFirst; 40 } 41 virtual bool cmp(QWork a,QWork b) { 42 bool q1 = (problem->qt_of_var(a.root().size()) != existsFirst); 43 bool q2 = (problem->qt_of_var(b.root().size()) != existsFirst); 44 if (q1 && !q2) return true; 45 if (!q1 && q2) return false; 46 int d1 = a.root().size(); 47 int d2 = b.root().size(); 48 if ( (d1 < d2) != deepestFirst) return true; 49 return false; 50 } 51}; 52 53class DepthComparator : public WorkComparator { 54 private : 55 bool deepestFirst; 56 public : 57 DepthComparator(bool deepestFirst) { 58 this->deepestfirst = deepestFirst; 59 } 60 61 virtual bool cmp(QWork a,QWork b) { 62 int d1 = a.root().size(); 63 int d2 = b.root().size(); 64 if ( (d1 < d2) != deepestFirst) return true; 65 return false; 66 } 67};