00001 #ifndef actasp_GraphPolicy_h__guard 00002 #define actasp_GraphPolicy_h__guard 00003 00004 #include <actasp/PartialPolicy.h> 00005 00006 #include <actasp/AspFluent.h> 00007 #include <actasp/state_utils.h> 00008 00009 #include <map> 00010 #include <set> 00011 #include <list> 00012 00013 namespace actasp { 00014 00015 struct GraphPolicy : public PartialPolicy { 00016 public: 00017 00018 GraphPolicy(const ActionSet& actions); 00019 00020 ActionSet actions(const std::set<AspFluent>& state) const throw(); 00021 00022 void merge(const AnswerSet& plan) throw(std::logic_error); 00023 00024 void merge(const PartialPolicy* otherPolicy); 00025 00026 void merge(const GraphPolicy* otherPolicy); 00027 00028 bool empty() const throw(); 00029 00030 std::vector<actasp::AnswerSet> plansFrom(const std::set<AspFluent>& state) throw(); 00031 00032 private: 00033 00034 typedef std::map<std::set<AspFluent>, ActionSet, StateComparator<AspFluent> > PolicyMap; 00035 typedef std::list< std::list< AspFluent> > PlanList; 00036 typedef std::list< std::pair< PlanList::const_iterator, std::list< AspFluent>::const_iterator> > PlanReference; 00037 typedef std::map<std::set<AspFluent>, PlanReference , StateComparator<AspFluent> > PlanIndex; 00038 00039 PolicyMap policy; 00040 ActionSet allActions; 00041 PlanList plans; 00042 PlanIndex planIndex; 00043 00044 }; 00045 00046 } 00047 00048 #endif