00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef PATHFIND_IDASTAR_H
00011 #define PATHFIND_IDASTAR_H
00012
00013 #include "search.h"
00014
00015
00016
00017 namespace PathFind
00018 {
00019 using namespace std;
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class IDAStar
00044 : public Search
00045 {
00046 public:
00047
00048 typedef enum {
00049
00050 NO_CACHING,
00051
00052
00053 f_CACHING,
00054
00055
00056 F_CACHING
00057 } Caching;
00058
00059 IDAStar(Caching caching = NO_CACHING);
00060
00061 StatisticsCollection createStatistics();
00062
00063 bool findPath(const Environment& env, int start, int target);
00064
00065 const vector<int>& getPath() const
00066 {
00067 return m_path;
00068 }
00069
00070 const StatisticsCollection& getStatistics() const;
00071
00072 const vector<char>& getVisitedNodes() const
00073 {
00074 return m_visitedNodes;
00075 }
00076
00077 private:
00078
00079 class CacheNode
00080 {
00081 public:
00082 int m_iter;
00083
00084 int m_f;
00085
00086 int m_g;
00087 };
00088
00089
00090 bool m_abortSearch;
00091
00092 int m_target;
00093
00094 int m_fLimit;
00095
00096 Caching m_caching;
00097
00098 const Environment* m_env;
00099
00100 long long int m_nodesExpanded;
00101
00102 long long int m_nodesVisited;
00103
00104 vector<char> m_visitedNodes;
00105
00106 vector<CacheNode> m_cache;
00107
00108 vector<int> m_path;
00109
00110 vector<vector<Environment::Successor> > m_successorStack;
00111
00112 StatisticsCollection m_statistics;
00113
00114 Statistics& m_branchingFactor;
00115
00116 void addCache(int nodeId, int f, int g, int iteration)
00117 {
00118 m_cache[nodeId].m_iter = iteration;
00119 m_cache[nodeId].m_f = f;
00120 m_cache[nodeId].m_g = g;
00121 }
00122
00123
00124
00125
00126 bool checkCache(int nodeId, int f, int g, int iteration, int& f_min);
00127
00128 void findPathIdaStar(int start);
00129
00130 void markVisitedNode(int nodeId, int iteration);
00131
00132 bool searchPathIdaStar(int iteration, int node, int lastNode,
00133 int depth, int g, int& f_min);
00134 };
00135 }
00136
00137
00138
00139 #endif