00001 #ifndef actasp_MultiPolicyExecutor_h__guard 00002 #define actasp_MultiPolicyExecutor_h__guard 00003 00004 #include <actasp/ActionExecutor.h> 00005 #include <actasp/PartialPolicy.h> 00006 #include <actasp/AspRule.h> 00007 00008 #include <vector> 00009 #include <list> 00010 #include <map> 00011 00012 namespace actasp { 00013 00014 class Action; 00015 class AspKR; 00016 class MultiPlanner; 00017 class ActionSelector; 00018 class ExecutionObserver; 00019 class PlanningObserver; 00020 00021 class PartialPolicyExecutor : public ActionExecutor { 00022 public: 00023 00024 PartialPolicyExecutor(AspKR* kr, MultiPlanner *planner, ActionSelector *selector, 00025 const std::map<std::string, Action * >& actionMap, double suboptimality); 00026 00027 using ActionExecutor::setGoal; 00028 void setGoal(const std::vector<actasp::AspRule>& goalRules) throw(); 00029 00030 bool goalReached() const throw(); 00031 bool failed() const throw(); 00032 00033 void executeActionStep(); 00034 00035 void addExecutionObserver(ExecutionObserver *observer) throw(); 00036 void removeExecutionObserver(ExecutionObserver *observer) throw(); 00037 00038 ~PartialPolicyExecutor(); 00039 00040 private: 00041 00042 //state 00043 bool isGoalReached; 00044 bool hasFailed; 00045 unsigned int actionCounter; 00046 bool newAction; 00047 Action *active; 00048 00049 //KR stuff 00050 AspKR* kr; 00051 MultiPlanner *planner; 00052 std::vector<actasp::AspRule> goalRules; 00053 00054 PartialPolicy* policy; 00055 00056 //customization 00057 double suboptimality; 00058 ActionSelector *selector; 00059 std::map<std::string, Action * > actionMap; 00060 00061 //observers 00062 std::list<ExecutionObserver*> executionObservers; 00063 00064 }; 00065 00066 } 00067 00068 #endif