BeliefValuePairPoolSet.h
Go to the documentation of this file.
00001 #ifndef BeliefValuePairPoolSet_H
00002 #define BeliefValuePairPoolSet_H
00003 
00004 #include "Bound.h"
00005 #include "Backup.h"
00006 #include "MOMDP.h"
00007 #include "BeliefValuePair.h"
00008 #include "BeliefValuePairPool.h"
00009 #include "PruneBeliefValuePair.h"
00010 #include <exception>
00011 #include <vector>
00012 using namespace std;
00013 using namespace momdp;
00014 namespace momdp 
00015 {
00016 
00017 
00018         class BeliefValuePairPoolSet :  public Bound<BeliefValuePair>
00019         {
00020         private:
00021                 
00022         public:
00023                 vector<BeliefValuePairPool*> set;
00024                 vector<BeliefCache *> beliefCacheSet;
00025                 void setBeliefCache(vector<BeliefCache *> p)
00026                 {
00027                         beliefCacheSet = p;
00028                         for(size_t i = 0 ; i < set.size(); i ++)
00029                         {
00030                                 set[i]->setBeliefCache(p[i]);
00031                         }
00032                 }
00033 
00034                 vector<IndexedTuple<BeliefValuePairPoolDataTuple> *> dataTableSet;
00035                 void setDataTable(vector<IndexedTuple<BeliefValuePairPoolDataTuple> *> p)
00036                 {
00037                         dataTableSet = p;
00038                         for(size_t i = 0 ; i < set.size(); i ++)
00039                         {
00040                                 set[i]->setDataTable(p[i]);
00041                         }
00042                 }
00043 
00044                 SharedPointer<MOMDP> problem;
00045                 void setProblem(SharedPointer<MOMDP> p)
00046                 {
00047                         problem = p;
00048                 }
00049                 void setSolver(PointBasedAlgorithm *p)
00050                 {
00051                         solver = p;
00052                 }
00053 
00054                 BeliefValuePairPoolSet(Backup<BeliefValuePair> *_backupEngine)
00055                 {
00056                         this->setBackupEngine(_backupEngine);
00057                 }
00058 
00059                 void initialize()
00060                 {
00061                         set.resize(problem->XStates->size());
00062                         for(States::iterator iter = problem->XStates->begin(); iter != problem->XStates->end(); iter ++ )
00063                         {
00064                                 // Should not use BeliefValuePairPool's backup
00065                                 BeliefValuePairPool *bound = new BeliefValuePairPool(NULL);
00066                                 bound->setProblem(problem);
00067                                 bound->setSolver(solver);
00068                                 set[iter.index()] = bound;
00069                                 bound->pruneEngine = new PruneBeliefValuePair();
00070                                 bound->pruneEngine->setup(bound);
00071                         }
00072                 }
00073 
00074                 SharedPointer<BeliefValuePair> addPoint(SharedPointer<BeliefWithState> beliefandState, double val) 
00075                 {
00076                         state_val sval = beliefandState->sval;
00077                         SharedPointer<belief_vector>  b = beliefandState->bvec;
00078                         return set[sval]->addPoint(b, val);
00079                 }
00080 
00081                 virtual void appendOnBackupHandler(BackupCallback _onBackup)
00082                 {
00083                         for(size_t i = 0 ; i < set.size(); i ++)
00084                         {
00085                                 set[i]->appendOnBackupHandler(_onBackup);
00086                         }
00087                 }
00088                 virtual void removeOnBackupHandler(BackupCallback _onBackup)
00089                 {
00090                         for(size_t i = 0 ; i < set.size(); i ++)
00091                         {
00092                                 set[i]->removeOnBackupHandler(_onBackup);
00093                         }
00094                 }
00095                 virtual ~BeliefValuePairPoolSet(void)
00096                 {
00097                 }
00098 
00099                 virtual REAL_VALUE getValue(SharedPointer<BeliefWithState>& belief);
00100 
00101                 virtual SharedPointer<BeliefValuePair> backup(BeliefTreeNode * node)
00102                 {
00103                         SharedPointer<BeliefValuePair> result = backupEngine->backup(node);
00104                         for(size_t i = 0 ; i < onBackup.size(); i++)
00105                         {
00106                                 (*onBackup[i])(solver, node, result);
00107                         }
00108                         return result;
00109                 }
00110 
00111         };
00112 
00113 
00114 }
00115 
00116 #endif 
00117 


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:28