1 //===-- Solution.h ------- PBQP Solution -----------------------*- C++ --*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Annotated PBQP Graph class. This class is used internally by the PBQP solver
11 // to cache information to speed up reduction.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
16 #define LLVM_CODEGEN_PBQP_SOLUTION_H
24 friend class SolverImplementation
;
28 std::vector
<unsigned> selections
;
31 unsigned r0Reductions
, r1Reductions
,
32 r2Reductions
, rNReductions
;
37 solutionCost(0.0), provedOptimal(false),
38 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
40 Solution(unsigned length
, bool assumeOptimal
) :
41 selections(length
), solutionCost(0.0), provedOptimal(assumeOptimal
),
42 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
44 void setProvedOptimal(bool provedOptimal
) {
45 this->provedOptimal
= provedOptimal
;
48 void setSelection(unsigned nodeID
, unsigned selection
) {
49 selections
[nodeID
] = selection
;
52 void setSolutionCost(PBQPNum solutionCost
) {
53 this->solutionCost
= solutionCost
;
56 void incR0Reductions() { ++r0Reductions
; }
57 void incR1Reductions() { ++r1Reductions
; }
58 void incR2Reductions() { ++r2Reductions
; }
59 void incRNReductions() { ++rNReductions
; }
61 unsigned numNodes() const { return selections
.size(); }
63 unsigned getSelection(unsigned nodeID
) const {
64 return selections
[nodeID
];
67 PBQPNum
getCost() const { return solutionCost
; }
69 bool isProvedOptimal() const { return provedOptimal
; }
71 unsigned getR0Reductions() const { return r0Reductions
; }
72 unsigned getR1Reductions() const { return r1Reductions
; }
73 unsigned getR2Reductions() const { return r2Reductions
; }
74 unsigned getRNReductions() const { return rNReductions
; }
76 bool operator==(const Solution
&other
) const {
77 return (selections
== other
.selections
);
80 bool operator!=(const Solution
&other
) const {
81 return !(*this == other
);
88 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H