00001 00007 /********** tell emacs we use -*- c++ -*- style comments ******************* 00008 $Revision: 2.10 $ $Author: duyanzhu $ $Date: 2008/06/14 01:41:14 $ 00009 00010 @file Sample.h 00011 @brief the superclass of all the sample classes 00012 00013 ***************************************************************************/ 00014 #ifndef Sample_H 00015 #define Sample_H 00016 00017 #include <list> 00018 #include <vector> 00019 #include "Belief.h" 00020 #include "BeliefTreeNode.h" 00021 #include "BeliefForest.h" 00022 #include "PointBasedAlgorithm.h" 00023 using namespace std; 00024 using namespace momdp; 00025 00026 namespace momdp 00027 { 00028 class MOMDP; 00029 00030 00031 class Sample 00032 { 00033 public: 00034 typedef void (*GetNodeCallback)(PointBasedAlgorithm *solver, BeliefTreeNode *node, SharedPointer<BeliefWithState>& belief) ; 00035 00036 protected: 00037 vector<GetNodeCallback> onGetNode; 00038 00039 vector <BeliefCache *> *beliefCacheSet; 00040 BeliefForest *beliefForest; 00041 00042 00043 public: 00044 SharedPointer<MOMDP> problem; 00045 PointBasedAlgorithm* solver; 00046 00047 int numStatesExpanded; 00048 bool dumpData; 00049 bool dumpPolicyTrace; 00050 bool dumpPolicyTraceTime; 00051 00052 Sample() 00053 { 00054 numStatesExpanded = 0; 00055 } 00056 00057 virtual void setup(PointBasedAlgorithm* _solver, SharedPointer<MOMDP> _problem, vector <BeliefCache *> *_beliefCacheSet, BeliefForest* _beliefForest) 00058 { 00059 solver = _solver; 00060 problem = _problem; 00061 beliefCacheSet = _beliefCacheSet; 00062 beliefForest = _beliefForest; 00063 00064 } 00065 00066 virtual void appendOnGetNodeHandler(GetNodeCallback _callback) 00067 { 00068 onGetNode.push_back( _callback); 00069 } 00070 00071 00072 00073 virtual list<cacherow_stval> sample(cacherow_stval beliefIndex, unsigned int currentRoot) // modified for factored, prevly, virtual list<int> 00074 { 00075 return list<cacherow_stval>(); 00076 } 00077 00078 //virtual list<cacherow_stval> sample(cacherow_stval beliefIndex)=0; // modified for factored, prevly, virtual list<int> sample(int beliefIndex)=0; 00079 virtual void samplePrepare(cacherow_stval beliefIndex_Sval); // modified for factored, prevly, void samplePrepare(int beliefIndex); 00080 virtual void samplePrepare(BeliefTreeNode* cn); 00081 00082 //tree related methods 00083 //XXX ??? 00084 virtual BeliefTreeNode* getNode(SharedPointer<BeliefWithState>& s); // modified for factored, prevly, BeliefTreeNode* getNode(const state_vector& s); 00085 virtual void expand(BeliefTreeNode& cn); 00086 00087 virtual BeliefForest* getGlobalNode(void); 00088 00089 //destructor 00090 virtual ~Sample(void){} 00091 00092 00093 }; 00094 00095 }; // namespace momdp 00096 00097 #endif 00098 00099 /*************************************************************************** 00100 * REVISION HISTORY: 00101 * 00102 ***************************************************************************/ 00103