SampleBP.h
Go to the documentation of this file.
00001 
00004 /***************************************************************************
00005 File: SampleBP.h
00006 Data: 20/03/2007
00007 Author: rn
00008 Brief: Sample subclass for BP sampling
00009  ***************************************************************************/
00010 #ifndef SAMPLEBP_H
00011 #define SAMPLEBP_H
00012 
00013 #define BP_INIT_MAX_DEPTH (10)
00014 #define BP_MAX_DEPTH_ADJUST_RATIO (1.1)
00015 //#define BP_IMPROVEMENT_CONSTANT (0.95)  // now is a variable in SolverParams
00016 
00017 #define USE_HSVI_ADAPTIVE_DEPTH 1
00018 
00019 #include "Sample.h"
00020 #include "BeliefCache.h"
00021 #include "BinManager.h"
00022 #include "BinManagerSet.h"
00023 #include "PointBasedAlgorithm.h"
00024 #include "BeliefTreeNode.h"
00025 
00026 
00027 using namespace std;
00028 using namespace momdp;
00029 
00030 /****************************************
00031   DECLARATION OF SampleBP
00032  ****************************************/
00033 
00034 namespace momdp{
00035 
00036 
00037     class SARSOP;
00038 
00039     struct BPUpdateResult {
00040         int maxUBAction;
00041         double maxUBVal;
00042         double ubResidual;
00043         int maxExcessUncStateOutcome;  // chosen value of observed state variable       
00044         int maxExcessUncOutcome;        // chosen value of observation variable
00045         double maxExcessUnc;
00046     };
00047 
00048     class SampleBP: public Sample{
00049         private:
00050             //attributes
00051 #if USE_HSVI_ADAPTIVE_DEPTH
00052             std::vector<int> depthArr; //int depth;             // SYLMOD17102008 for parallel trials
00053             double logOcc;
00054             double maxDepth,oldMaxDepth;
00055             double oldQualitySum, newQualitySum;
00056             int oldNumUpdates, newNumUpdates;
00057 #endif
00058             //  std::vector<double> trialTargetPrecisionArr;  // double trialTargetPrecision;           // SYLMOD17102008 for parallel trials
00059 
00060 
00061 
00062             //BeliefCache* beliefCache;  // removed for factored, now accessed through Bounds class
00063             std::vector<list<cacherow_stval> > priorityQueueArr; //list<cacherow_stval> priorityQueue; // modified for factored, prevly, list <int> priorityQueue;
00064             // SYLMOD17102008 for parallel trials
00065 
00066         public:
00067             int numTrials;
00068             int numSubOptimal; //xan-edit to count no of suboptimal paths found
00069             //double targetPrecision; //xan-edit                // SYLMOD17102008 doesnt seem to be used
00070             BinManagerSet * bm;//for Bin Heuristic
00071             int numBinProceed;//for Bin Heuristic
00072             std::vector<double> nextNodeTargetUbArr;  //double nextNodeTargetUb;  // SYLMOD17102008 for parallel trials //for BP (revised)
00073             bool isRoot;//for BP (revised)
00074             std::vector<double> nextNodeTargetLbArr; //double nextNodeTargetLb;// SYLMOD17102008 for parallel trials //new heuristic
00075 
00076             std::vector<double> trialTargetPrecisionArr;
00077 
00078             std::vector<int> newTrialFlagArr; //int newTrialFlag; //ADD SYLTAG : 1 indicates to the chooser of roots that a new trial should start 
00079             // SYLMOD17102008 for parallel trials
00080             //constructor
00081             SampleBP();
00082             virtual void setup(SharedPointer<MOMDP> _problem, SARSOP* _solver);
00083 
00084             SARSOP* solver;
00085             //methods
00086             list<cacherow_stval> sample(cacherow_stval currentBeliefIndex, unsigned int currentRoot);
00087             // SYLMOD17102008 for parallel trials
00088             //list<cacherow_stval> sample(cacherow_stval currentBeliefIndex); // prevly, list<int> sample(int currentBeliefIndex);
00089             void getMaxExcessUncOutcome(BeliefTreeNode& cn, BPUpdateResult& r, unsigned int currentRoot) const;
00090             // SYLMOD17102008 for parallel trials       
00091             //void getMaxExcessUncOutcome(BeliefTreeNode& cn, BPUpdateResult& r) const;
00092 
00093             void setTargetPrecision(double _targetPrecision);
00094             void setBinManager(BinManagerSet* _bm);
00095             //bool CompareIfLowerBoundImprovesAction(int action, int observation, BeliefTreeNode & currentNode);
00096             bool CompareIfLowerBoundImprovesAction(int action, int observation, int xstate, BeliefTreeNode & currentNode, unsigned int currentRoot);
00097             // SYLMOD17102008 for parallel trials               
00098             //bool CompareIfLowerBoundImprovesAction(int action, int observation, int xstate, BeliefTreeNode & currentNode);
00099             double calculateLowerBoundValue(int action, BeliefTreeNode & currentNode);
00100             int chooseAction(BeliefTreeNode & currentNode);
00101 
00102             bool doRandomization;
00103             void setRandomization(bool newFlag);
00104             ~SampleBP(){}
00105     };//end class SampleBP
00106 
00107 };//end namespace momdp
00108 #endif


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