00001 #ifndef BeliefTreeNode_H 00002 #define BeliefTreeNode_H 00003 00004 #include <vector> 00005 #include "Const.h" 00006 #include "FacmodelStructs.h" 00007 #include "MObject.h" 00008 00009 using namespace std; 00010 using namespace momdp; 00011 namespace momdp 00012 { 00013 #define CB_QVAL_UNDEFINED (-99e+20) 00014 #define CB_INITIALIZATION_PRECISION_FACTOR (1e-2) 00015 00016 class BeliefTreeNode; 00017 class BeliefCache; 00018 class Tuple; 00019 00020 class BeliefTreeEdge 00021 { 00022 public: 00023 double obsProb; // note that this is the joint prob of observation and next_x value 00024 BeliefTreeNode* nextState; 00025 BeliefTreeEdge(); 00026 ~BeliefTreeEdge(); 00027 }; 00028 00029 00030 // added for factored - SYL 17072008 00031 class BeliefTreeObsState 00032 { 00033 public: 00034 Tuple* extraData; 00035 vector<BeliefTreeEdge*> outcomes; 00036 size_t getNumOutcomes(void) const { return outcomes.size(); } 00037 BeliefTreeObsState() 00038 { 00039 extraData = NULL; 00040 } 00041 }; 00042 00043 class BeliefTreeQEntry 00044 { 00045 public: 00046 double immediateReward; 00047 //std::vector<BeliefTreeEdge*> outcomes; // removed for factored - SYL 17072008 00048 vector<BeliefTreeObsState*> stateOutcomes; // added for factored - SYL 17072008 00049 Tuple* extraData; 00050 double lbVal, ubVal; 00051 bool valid;//added rn 12/18/2006 //for purpose of record which entries are valid (not sub-optimal) 00052 size_t getNumStateOutcomes(void) const { return stateOutcomes.size(); } 00053 BeliefTreeQEntry() 00054 { 00055 extraData = NULL; 00056 } 00057 }; 00058 00059 struct cacherow_stval 00060 { 00061 int row; 00062 state_val sval; 00063 }; 00064 00065 class BeliefTreeNode : public MObject 00066 { 00067 public: 00068 BeliefTreeNode(void); 00069 virtual ~BeliefTreeNode(void); 00070 00071 00072 int count;//the count of valid paths which led to the belief node in the reachable tree 00073 SharedPointer<BeliefWithState> s; // added for factored - SYL 17072008 00074 cacherow_stval cacheIndex; // added for factored - SYL 17072008 00075 00076 vector<BeliefTreeQEntry> Q; 00077 00078 /*double lastUbVal; 00079 list<int> depth; 00080 list<int> depth2; 00081 list<double> targetUb; 00082 list<bool> examined;*/ 00083 00084 void print(); 00085 00086 // TODO: migrate checked to Pruning data tuple 00087 bool checked; 00088 00089 bool isFringe(void) const { return Q.empty(); } 00090 size_t getNodeNumActions(void) const { return Q.size(); } 00091 BeliefTreeNode& getNextState(int a, int o, int x) { return *Q[a].stateOutcomes[x]->outcomes[o]->nextState; } // added for factored - SYL 17072008 00092 00093 Tuple* extraData; 00094 00095 }; 00096 00097 } 00098 00099 00100 #endif