PruneBeliefValuePair.cpp
Go to the documentation of this file.
00001 
00008 #include "PruneBeliefValuePair.h"
00009 #include "BeliefValuePair.h"
00010 #include "BeliefValuePairPool.h"
00011 
00012 using namespace std;
00013 using namespace momdp;
00014 
00015 namespace momdp{
00016 
00017         void PruneBeliefValuePair::prune(void) 
00018         {
00019                 unsigned int nextPruneNumPts = max(lastPruneNumPts + PRUNE_PTS_INCREMENT, (int) (lastPruneNumPts * PRUNE_PTS_FACTOR));
00020                 if (bvPairPool->points.size() > nextPruneNumPts) 
00021                 {
00022                         prunePoints();
00023                 }
00024         }
00025 
00026         void PruneBeliefValuePair::prunePoints(void) 
00027         {
00028 #if USE_DEBUG_PRINT
00029                 int oldNum = bvPairPool->points.size();
00030 #endif
00031 
00032                 list< std::list<SharedPointer<BeliefValuePair> >::iterator > erase_ptrs;
00033 
00034                 LISTFOREACH_NOCONST(SharedPointer<BeliefValuePair> , ptp,  bvPairPool->points) 
00035                 {
00036                         SharedPointer<BeliefValuePair> try_pair = *ptp;
00037                         try_pair->disabled = true;
00038                         // put pt back in if v is at least epsilon smaller than
00039                         // upperBound(b) (smaller is better because it means the upper
00040                         // bound is tighter)
00041                         if (try_pair->v <= bvPairPool->getValue((try_pair->b)) - ZMDP_BOUNDS_PRUNE_EPS) 
00042                         {
00043                                 try_pair->disabled = false;
00044                         } 
00045                         else
00046                         {
00047                                 erase_ptrs.push_back(ptp);
00048                         }
00049                 }
00050 
00051                 LISTFOREACH(list<SharedPointer<BeliefValuePair> >::iterator, erase_ptr,  erase_ptrs) 
00052                 {
00053                         list<SharedPointer<BeliefValuePair> >::iterator  x, xp1;
00054                         x = xp1 = (*erase_ptr);
00055                         xp1++;
00056                         bvPairPool->points.erase( x, xp1 );
00057                 }
00058 
00059 #if USE_DEBUG_PRINT
00060                 cout << "... pruned # points from " << oldNum << " down to " << points.size() << endl;
00061 #endif
00062                 lastPruneNumPts = bvPairPool->points.size();
00063         }
00064 
00065 
00066 
00067 
00068 
00069 };
00070 


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