action_utils.cpp
Go to the documentation of this file.
00001 #include <actasp/action_utils.h>
00002 
00003 
00004 #include <algorithm>
00005 #include <iterator>
00006 
00007 using namespace std;
00008 
00009 namespace actasp {
00010 
00011 struct ActionName {
00012   string operator()(const AspFluent& action) const {
00013     return action.getName();
00014   }
00015 
00016 };
00017 
00018 IsAnAction::IsAnAction(const ActionSet& actions) {
00019   transform(actions.begin(), actions.end(), inserter(actionNames, actionNames.begin()), ActionName());
00020 }
00021 
00022 bool IsAnAction::operator()(const AspFluent& fluent) const {
00023 
00024   return actionNames.find(fluent.getName()) != actionNames.end();
00025 }
00026 
00027 AnswerSet planToAnswerSet(const std::list<Action*>& plan) {
00028 
00029   list<Action*>::const_iterator actIt = plan.begin();
00030   set<AspFluent> fluents;
00031 
00032   for (int timeStep=0; actIt != plan.end(); ++actIt, ++timeStep) {
00033     fluents.insert((*actIt)->toFluent(timeStep));
00034   }
00035 
00036   return AnswerSet(fluents.begin(), fluents.end());
00037 }
00038 
00039 ActionSet actionMapToSet(const std::map<std::string, Action *>& actionMap) {
00040 
00041   ActionSet fluents;
00042 
00043   std::map<std::string, Action *>::const_iterator mapIt = actionMap.begin();
00044   for (; mapIt != actionMap.end(); ++mapIt)
00045     fluents.insert(AspFluent(mapIt->second->toFluent(0)));
00046 
00047   return fluents;
00048 }
00049 
00050 }


bwi_kr_execution
Author(s): Matteo Leonetti, Piyush Khandelwal
autogenerated on Thu Jun 6 2019 17:57:36