blob: 316c9de5bd1bee6022238ac65f98b7c628c9f409 [file] [log] [blame]
Lang Hames6699fb22009-08-06 23:32:48 +00001#ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
2#define LLVM_CODEGEN_PBQP_SOLUTION_H
3
4#include "PBQPMath.h"
5
6namespace PBQP {
7
8class Solution {
9
10 friend class SolverImplementation;
11
12private:
13
14 std::vector<unsigned> selections;
15 PBQPNum solutionCost;
16 bool provedOptimal;
17 unsigned r0Reductions, r1Reductions,
18 r2Reductions, rNReductions;
19
20public:
21
22 Solution() :
23 solutionCost(0.0), provedOptimal(false),
24 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
25
26 Solution(unsigned length, bool assumeOptimal) :
27 selections(length), solutionCost(0.0), provedOptimal(assumeOptimal),
28 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
29
30 void setProvedOptimal(bool provedOptimal) {
31 this->provedOptimal = provedOptimal;
32 }
33
34 void setSelection(unsigned nodeID, unsigned selection) {
35 selections[nodeID] = selection;
36 }
37
38 void setSolutionCost(PBQPNum solutionCost) {
39 this->solutionCost = solutionCost;
40 }
41
42 void incR0Reductions() { ++r0Reductions; }
43 void incR1Reductions() { ++r1Reductions; }
44 void incR2Reductions() { ++r2Reductions; }
45 void incRNReductions() { ++rNReductions; }
46
47 unsigned numNodes() const { return selections.size(); }
48
49 unsigned getSelection(unsigned nodeID) const {
50 return selections[nodeID];
51 }
52
53 PBQPNum getCost() const { return solutionCost; }
54
55 bool isProvedOptimal() const { return provedOptimal; }
56
57 unsigned getR0Reductions() const { return r0Reductions; }
58 unsigned getR1Reductions() const { return r1Reductions; }
59 unsigned getR2Reductions() const { return r2Reductions; }
60 unsigned getRNReductions() const { return rNReductions; }
61
62 bool operator==(const Solution &other) const {
63 return (selections == other.selections);
64 }
65
66 bool operator!=(const Solution &other) const {
67 return !(*this == other);
68 }
69
70};
71
72}
73
74#endif // LLVM_CODEGEN_PBQP_SOLUTION_H