1 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
2 #define LLVM_CODEGEN_PBQP_SOLUTION_H
10 friend class SolverImplementation;
14 std::vector<unsigned> selections;
17 unsigned r0Reductions, r1Reductions,
18 r2Reductions, rNReductions;
23 solutionCost(0.0), provedOptimal(false),
24 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
26 Solution(unsigned length, bool assumeOptimal) :
27 selections(length), solutionCost(0.0), provedOptimal(assumeOptimal),
28 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
30 void setProvedOptimal(bool provedOptimal) {
31 this->provedOptimal = provedOptimal;
34 void setSelection(unsigned nodeID, unsigned selection) {
35 selections[nodeID] = selection;
38 void setSolutionCost(PBQPNum solutionCost) {
39 this->solutionCost = solutionCost;
42 void incR0Reductions() { ++r0Reductions; }
43 void incR1Reductions() { ++r1Reductions; }
44 void incR2Reductions() { ++r2Reductions; }
45 void incRNReductions() { ++rNReductions; }
47 unsigned numNodes() const { return selections.size(); }
49 unsigned getSelection(unsigned nodeID) const {
50 return selections[nodeID];
53 PBQPNum getCost() const { return solutionCost; }
55 bool isProvedOptimal() const { return provedOptimal; }
57 unsigned getR0Reductions() const { return r0Reductions; }
58 unsigned getR1Reductions() const { return r1Reductions; }
59 unsigned getR2Reductions() const { return r2Reductions; }
60 unsigned getRNReductions() const { return rNReductions; }
62 bool operator==(const Solution &other) const {
63 return (selections == other.selections);
66 bool operator!=(const Solution &other) const {
67 return !(*this == other);
74 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H