PolicyGraphGenerator.h
Go to the documentation of this file.
00001 #ifndef PolicyGraphGenerator_H
00002 #define PolicyGraphGenerator_H
00003 
00004 #include <vector>
00005 #include <ostream>
00006 #include <string>
00007 #include <set>
00008 #include "MOMDP.h"
00009 #include "BeliefTreeNode.h"
00010 using namespace std;
00011 using namespace momdp;
00012 
00013 namespace momdp
00014 {
00015     class AlphaVectorPolicy;
00016     class BeliefForest;
00017     class BeliefTreeNode;
00018     class BeliefCache;
00019     class Sample;
00020     class SolverParams;
00021 
00022     class NodeRelation
00023     {
00024         public:
00025             BeliefTreeNode *srcNode;
00026             BeliefTreeNode *destNode;
00027             int X;
00028             double xProb;
00029 
00030             int o;
00031             double oProb;
00032 
00033     };
00034 
00035     class PolicyGraphParam
00036     {
00037         public:
00038             bool useLookahead;
00039             int depth;
00040             double probThreshold;               //only show edges with probability above probThreshold
00041             int maxEdge;                        //max number of outgoing edges from a node      
00042 
00043             PolicyGraphParam()
00044             {
00045                 depth = 0;              //depth of the graph, 0 for no limit
00046                 useLookahead = true;
00047                 probThreshold = 0;      
00048                 maxEdge = 0;            
00049             }
00050 
00051     };
00052 
00053     class PolicyGraphGenerator
00054     {
00055         private:
00056             SharedPointer<MOMDP> problem;
00057             SharedPointer<AlphaVectorPolicy> policy;
00058             BeliefForest* beliefForest;
00059             Sample* sampleEngine;
00060             vector <BeliefCache *>  beliefCacheSet;
00061             PolicyGraphParam graphParam;
00062 
00063             set<BeliefTreeNode*> nodesList;             //list of node used in graph
00064             vector<NodeRelation> nodeRelationsList;     //list of edges
00065 
00066             void expandNode(BeliefTreeNode* curNode, int bestAction, vector<NodeRelation>& expansion);
00067             void generateNodesDot(ostream& output, BeliefTreeNode* node);
00068             string formatTuple(string name, int index, map<string, string> dataMap);
00069             void convertStCacheIndex(ostream& output, cacherow_stval& stRowIndex);
00070             void generateNodesRelation(ostream& output, vector<NodeRelation>& nodeRelations, set<BeliefTreeNode*> firstLevelNodes);
00071             void drawRootNodeDot(ostream& output, SharedPointer<SparseVector> initialBeliefY, SharedPointer<DenseVector> initialBeliefX, int bestAction);
00072             void dfsBeliefForest(BeliefTreeNode* curNode, vector<BeliefTreeNode*>& path ,int level);
00073 
00074         public:
00075             PolicyGraphGenerator(SharedPointer<MOMDP> _problem, SharedPointer<AlphaVectorPolicy> _policy, PolicyGraphParam _graphParam);
00076             void generateGraph(ostream& output);        //generate policy graph in DOT format
00077             ~PolicyGraphGenerator(void);
00078     };
00079 
00080 }
00081 #endif
00082 


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