Go to the documentation of this file.00001
00004
00005
00006
00007
00008
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
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
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;
00044 int maxExcessUncOutcome;
00045 double maxExcessUnc;
00046 };
00047
00048 class SampleBP: public Sample{
00049 private:
00050
00051 #if USE_HSVI_ADAPTIVE_DEPTH
00052 std::vector<int> depthArr;
00053 double logOcc;
00054 double maxDepth,oldMaxDepth;
00055 double oldQualitySum, newQualitySum;
00056 int oldNumUpdates, newNumUpdates;
00057 #endif
00058
00059
00060
00061
00062
00063 std::vector<list<cacherow_stval> > priorityQueueArr;
00064
00065
00066 public:
00067 int numTrials;
00068 int numSubOptimal;
00069
00070 BinManagerSet * bm;
00071 int numBinProceed;
00072 std::vector<double> nextNodeTargetUbArr;
00073 bool isRoot;
00074 std::vector<double> nextNodeTargetLbArr;
00075
00076 std::vector<double> trialTargetPrecisionArr;
00077
00078 std::vector<int> newTrialFlagArr;
00079
00080
00081 SampleBP();
00082 virtual void setup(SharedPointer<MOMDP> _problem, SARSOP* _solver);
00083
00084 SARSOP* solver;
00085
00086 list<cacherow_stval> sample(cacherow_stval currentBeliefIndex, unsigned int currentRoot);
00087
00088
00089 void getMaxExcessUncOutcome(BeliefTreeNode& cn, BPUpdateResult& r, unsigned int currentRoot) const;
00090
00091
00092
00093 void setTargetPrecision(double _targetPrecision);
00094 void setBinManager(BinManagerSet* _bm);
00095
00096 bool CompareIfLowerBoundImprovesAction(int action, int observation, int xstate, BeliefTreeNode & currentNode, unsigned int currentRoot);
00097
00098
00099 double calculateLowerBoundValue(int action, BeliefTreeNode & currentNode);
00100 int chooseAction(BeliefTreeNode & currentNode);
00101
00102 bool doRandomization;
00103 void setRandomization(bool newFlag);
00104 ~SampleBP(){}
00105 };
00106
00107 };
00108 #endif