LLVM API Documentation
00001 //===-- Solution.h ------- PBQP Solution -----------------------*- C++ --*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // Annotated PBQP Graph class. This class is used internally by the PBQP solver 00011 // to cache information to speed up reduction. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H 00016 #define LLVM_CODEGEN_PBQP_SOLUTION_H 00017 00018 #include "PBQPMath.h" 00019 00020 namespace PBQP { 00021 00022 class Solution { 00023 00024 friend class SolverImplementation; 00025 00026 private: 00027 00028 std::vector<unsigned> selections; 00029 PBQPNum solutionCost; 00030 bool provedOptimal; 00031 unsigned r0Reductions, r1Reductions, 00032 r2Reductions, rNReductions; 00033 00034 public: 00035 00036 Solution() : 00037 solutionCost(0.0), provedOptimal(false), 00038 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {} 00039 00040 Solution(unsigned length, bool assumeOptimal) : 00041 selections(length), solutionCost(0.0), provedOptimal(assumeOptimal), 00042 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {} 00043 00044 void setProvedOptimal(bool provedOptimal) { 00045 this->provedOptimal = provedOptimal; 00046 } 00047 00048 void setSelection(unsigned nodeID, unsigned selection) { 00049 selections[nodeID] = selection; 00050 } 00051 00052 void setSolutionCost(PBQPNum solutionCost) { 00053 this->solutionCost = solutionCost; 00054 } 00055 00056 void incR0Reductions() { ++r0Reductions; } 00057 void incR1Reductions() { ++r1Reductions; } 00058 void incR2Reductions() { ++r2Reductions; } 00059 void incRNReductions() { ++rNReductions; } 00060 00061 unsigned numNodes() const { return selections.size(); } 00062 00063 unsigned getSelection(unsigned nodeID) const { 00064 return selections[nodeID]; 00065 } 00066 00067 PBQPNum getCost() const { return solutionCost; } 00068 00069 bool isProvedOptimal() const { return provedOptimal; } 00070 00071 unsigned getR0Reductions() const { return r0Reductions; } 00072 unsigned getR1Reductions() const { return r1Reductions; } 00073 unsigned getR2Reductions() const { return r2Reductions; } 00074 unsigned getRNReductions() const { return rNReductions; } 00075 00076 bool operator==(const Solution &other) const { 00077 return (selections == other.selections); 00078 } 00079 00080 bool operator!=(const Solution &other) const { 00081 return !(*this == other); 00082 } 00083 00084 }; 00085 00086 } 00087 00088 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H