Go to the documentation of this file.00001 #ifndef CLOSED_LIST_H
00002 #define CLOSED_LIST_H
00003
00004
00005 #include <tr1/unordered_map>
00006 #include <algorithm>
00007 #include <vector>
00008
00009 #include "operator.h"
00010
00011 struct TssHash
00012 {
00013 std::size_t operator()(const TimeStampedState & tss) const;
00014 };
00015
00016 bool prevailEquals(const Prevail &prev1, const Prevail &prev2);
00017
00018 bool scheduledConditionEquals(const ScheduledCondition &cond1, const ScheduledCondition &cond2);
00019
00020 bool scheduledEffectEquals(const ScheduledEffect &eff1, const ScheduledEffect &eff2);
00021
00022 struct TssEquals
00023 {
00024 bool operator()(const TimeStampedState &tss1, const TimeStampedState &tss2) const;
00025 };
00026
00027 class ClosedList
00028 {
00029 struct PredecessorInfo
00030 {
00031 const TimeStampedState *predecessor;
00032 const Operator *annotation;
00033 PredecessorInfo(const TimeStampedState *pred,
00034 const Operator *annote) :
00035 predecessor(pred), annotation(annote)
00036 {
00037 }
00038 };
00039
00040 typedef tr1::unordered_multimap<TimeStampedState, PredecessorInfo, TssHash, TssEquals> ClosedListMap;
00041 typedef ClosedListMap::value_type ValuePair;
00042 ClosedListMap closed;
00043
00044 public:
00045 ClosedList();
00046 ~ClosedList();
00047 const TimeStampedState *insert(TimeStampedState &entry,
00048 const TimeStampedState *predecessor,
00049 const Operator *annotation);
00050 void clear();
00051
00052 bool contains(const TimeStampedState &entry) const;
00053
00054 const TimeStampedState& get(const TimeStampedState &state) const;
00055
00056 double get_min_ts_of_key(const TimeStampedState &state) const;
00057
00058 int size() const;
00059 double trace_path(const TimeStampedState &entry, std::vector<PlanStep> &path, PlanTrace &staes) const;
00060 double getCostOfPath(const TimeStampedState &entry) const;
00061 };
00062
00063 double getSumOfSubgoals(const vector<PlanStep> &plan);
00064 double getSumOfSubgoals(const PlanTrace &path);
00065
00066 #endif