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