00001 #ifndef BeliefValuePairPool_H 00002 #define BeliefValuePairPool_H 00003 00004 #include "Bound.h" 00005 #include "Backup.h" 00006 #include "Tuple.h" 00007 #include "IndexedTuple.h" 00008 #include "BeliefValuePair.h" 00009 #include "PruneBeliefValuePair.h" 00010 #include <exception> 00011 #include <list> 00012 #include <vector> 00013 #include <stdexcept> 00014 00015 00016 using namespace std; 00017 using namespace momdp; 00018 namespace momdp 00019 { 00020 00021 #define CORNER_EPS (1e-6) 00022 #define MIN_RATIO_EPS (1e-10) 00023 00024 class BeliefValuePairPoolDataTuple :public Tuple 00025 { 00026 public: 00027 int UB_ACTION; /*the max ub action*/ 00028 }; 00029 00030 00031 class BeliefValuePairPool : public Bound<BeliefValuePair> 00032 { 00033 public: 00034 BeliefCache *beliefCache; 00035 void setBeliefCache(BeliefCache *p) 00036 { 00037 beliefCache = p; 00038 } 00039 IndexedTuple<BeliefValuePairPoolDataTuple> *dataTable; 00040 void setDataTable(IndexedTuple<BeliefValuePairPoolDataTuple> *p) 00041 { 00042 dataTable = p; 00043 } 00044 00045 SharedPointer<MOMDP> problem; 00046 void setProblem(SharedPointer<MOMDP> p) 00047 { 00048 problem = p; 00049 } 00050 void setSolver(PointBasedAlgorithm *p) 00051 { 00052 //solver = p; 00053 } 00054 00055 BeliefValuePairPool(Backup<BeliefValuePair> *_backupEngine) 00056 { 00057 this->setBackupEngine(_backupEngine); 00058 cornerPointsVersion = 0; 00059 } 00060 PruneBeliefValuePair* pruneEngine; 00061 00062 virtual ~BeliefValuePairPool(void) 00063 { 00064 } 00065 00066 00067 virtual REAL_VALUE getValue(SharedPointer<Belief>& belief); 00068 double getValue_NoInterpolation(const belief_vector& b); 00069 00070 virtual SharedPointer<BeliefValuePair> backup(BeliefTreeNode * node) 00071 { 00072 SharedPointer<BeliefValuePair> result = backupEngine->backup(node); 00073 for(size_t i = 0 ; i < onBackup.size(); i++) 00074 { 00075 (*onBackup[i])(solver, node, result); 00076 } 00077 throw runtime_error("Not finished..."); 00078 return result; 00079 } 00080 00081 00082 unsigned int cornerPointsVersion; 00083 DenseVector cornerPoints; 00084 00085 00086 list<SharedPointer<BeliefValuePair> > points; 00087 // update helper functions 00088 SharedPointer<BeliefValuePair> addPoint(SharedPointer<belief_vector>& b, double val); 00089 int whichCornerPoint(const SharedPointer<belief_vector>& b) const; 00090 00091 private: 00092 void printCorners() const; 00093 00094 00095 }; 00096 00097 00098 } 00099 00100 #endif 00101