File: WorkComparators.hh

package info (click to toggle)
gecode 6.2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,380 kB
  • sloc: cpp: 337,599; perl: 2,048; makefile: 1,798; sh: 215
file content (67 lines) | stat: -rw-r--r-- 1,595 bytes parent folder | download | duplicates (4)
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;
	}
};