00001 #ifndef SARSOPPrune_H 00002 #define SARSOPPrune_H 00003 00004 #include "PointBasedAlgorithm.h" 00005 #include "Bound.h" 00006 #include "Prune.h" 00007 #include "BoundSet.h" 00008 #include "AlphaPlane.h" 00009 #include "BeliefValuePair.h" 00010 #include "SARSOP.h" 00011 00012 namespace momdp 00013 { 00014 class SARSOPPrune :public Prune 00015 { 00016 private: 00017 SARSOP* sarsopSolver; 00018 int pruneInterval; //numBackups between each 2 prunings 00019 int currentRound; 00020 00021 double elapsed; 00022 00023 // for pruning 00024 double bglobal_delta; 00025 int state; 00026 bool firstPass; 00027 00028 public: 00029 SARSOPPrune( SARSOP* _solver) :Prune(_solver) 00030 { 00031 sarsopSolver = _solver; 00032 pruneInterval = 50; 00033 currentRound = 1; 00034 00035 state = 2; 00036 firstPass = true; 00037 setDelta(sarsopSolver->solverParams->delta); 00038 00039 } 00040 00041 ~SARSOPPrune(void) 00042 { 00043 } 00044 00045 virtual void prune(void); 00046 void pruneLowerBound(); 00047 void pruneUpperBound(); 00048 void nullifySubOptimalBranches(); 00049 void nullifySubOptimalCerts(BeliefTreeNode* cn); 00050 void nullifySubOptimalCerts(BeliefTreeQEntry* e); 00051 void nullifyEntry(BeliefTreeQEntry* e); 00052 void uncheckAllSubNodes(BeliefTreeNode* cn); 00053 void uncheckEntry(BeliefTreeQEntry* e); 00054 void pruneDynamicDeltaVersion(); 00055 void updateDeltaVersion2(int overPrune, int underPrune); 00056 void increaseDelta(); 00057 void decreaseDelta(); 00058 00059 void setDelta(double newDelta); 00060 00061 static void onLowerBoundBackup (PointBasedAlgorithm* solver, BeliefTreeNode * node, SharedPointer<AlphaPlane> backupResult) 00062 { 00063 // updating certs, etc 00064 } 00065 00066 // Migrated from AlphaPlane 00067 bool hasMaxMetaAt(SharedPointer<AlphaPlane> alphaPlane, int index) 00068 { 00069 SARSOPAlphaPlaneTuple* dataTuple = (SARSOPAlphaPlaneTuple *) alphaPlane->solverData; 00070 FOREACH(AlphaPlaneMaxMeta* , entry, dataTuple->maxMeta) 00071 { 00072 if((*entry)->cacheIndex == index) 00073 { 00074 return true; 00075 } 00076 } 00077 return false; 00078 } 00079 00080 00081 00082 00083 }; 00084 } 00085 00086 #endif