00001 #ifndef actasp_IsNotLocallyOptimal_h__guard 00002 #define actasp_IsNotLocallyOptimal_h__guard 00003 00004 #include "LexComparator.h" 00005 00006 #include <list> 00007 #include <set> 00008 #include <functional> 00009 00010 #include <actasp/AspFluent.h> 00011 00012 namespace actasp { 00013 00014 class AnswerSet; 00015 00016 struct IsNotLocallyOptimal : public std::unary_function<const AnswerSet&, bool> { 00017 00018 typedef std::set< std::list <AspFluentRef>, LexComparator > PlanSet; 00019 00020 IsNotLocallyOptimal(const PlanSet* good, PlanSet* bad, const ActionSet& allActions, 00021 unsigned int shortestLength, bool planFitered); 00022 00023 bool operator()(const AnswerSet& plan); 00024 00025 std::list<AspFluentRef> cleanPlan(const AnswerSet& plan) const; 00026 00027 std::list<AspFluentRef>::const_iterator findFirstSuspiciousAction(const std::list<AspFluentRef>&) const; 00028 00029 bool validFrom(const std::list<AspFluentRef>& planCleaned, std::list<AspFluentRef>::const_iterator firstSuspect) const; 00030 00031 bool checkPlanValidity(const std::list<AspFluentRef>&) const; 00032 00033 bool checkSectionWithLength(const std::list<AspFluentRef>& planCleaned, 00034 std::list<AspFluentRef>::const_iterator firstSuspect, 00035 int length) const; 00036 00037 bool hasLoops(const AnswerSet& plan) const; 00038 00039 00040 00041 private: 00042 const PlanSet* good; 00043 PlanSet* bad; 00044 const ActionSet& allActions; 00045 unsigned int shortestLength; 00046 bool planFiltered; 00047 00048 }; 00049 00050 } 00051 00052 #endif