#include <astar.h>
Inheritance diagram for PathFind::AStar< MARKER, CLOSED >:
Pseudo algorithm for basic A* algorithm:
priorityqueue Open list Closed AStarSearch s.g = 0 // s is the start node s.h = GoalDistEstimate(s) s.f = s.g + s.h s.parent = null push s on Open while Open is not empty pop node n from Open // n has the lowest f if n is a goal node construct path return success for each successor n' of n newg = n.g + cost(n,n') if n' is in Open or Closed if n'.g <= newg skip remove n' from Open or Closed n'.parent = n n'.g = newg n'.h = GoalDistEstimate(n') n'.f = n'.g + n'.h push n' on Open push n onto Closed return failure // if no path found
This class is implemented as a template class taking the following template parameters:
Statistics (see Search::createStatistics and Search::getStatistics):
Definition at line 202 of file astar.h.
Public Member Functions | |
AStar () | |
StatisticsCollection | createStatistics () |
Create a StatisticsCollection. | |
bool | findPath (const Environment &env, int start, int target) |
Find a path. | |
const vector< int > & | getPath () const |
const StatisticsCollection & | getStatistics () const |
Get statistics of last search. | |
const vector< char > & | getVisitedNodes () const |
Get a vector with 'x' char labels for each visited node. | |
void | setNodesLimit (long long int nodesLimit) |
Set nodes limit for search engine. | |
int | getPathCost () const |
long long int | getNodesLimit () const |
Public Attributes | |
long long int | m_nodesLimit |
Private Member Functions | |
const AStarNode * | findNode (int nodeId) |
Find a node in open or closed lists. | |
void | findPathAStar (int start) |
void | finishSearch (int start, const AStarNode &node) |
Construct path and set statistics after target node was found. | |
AStarNode | getBestNodeFromOpen () |
Private Attributes | |
int | m_pathCost |
int | m_target |
const Environment * | m_env |
long long int | m_nodesExpanded |
long long int | m_nodesVisited |
CLOSED | m_closed |
vector< char > | m_visitedNodes |
vector< int > | m_path |
AStarOpen< MARKER > | m_open |
StatisticsCollection | m_statistics |
Statistics & | m_branchingFactor |
|
|
|
Create a StatisticsCollection. Contains Statistics instances for all values tracked. Useful for keeping accumulated statistics by creating the collection and merging the statistics of a search as returned by getStatistics(). Implements PathFind::Search. Definition at line 286 of file astar.h. References PathFind::StatisticsCollection::create(). |
|
Find a node in open or closed lists.
Definition at line 299 of file astar.h. References PathFind::AStar< MARKER, CLOSED >::m_closed, and PathFind::AStar< MARKER, CLOSED >::m_open. Referenced by PathFind::AStar< MARKER, CLOSED >::findPathAStar(). |
|
Find a path.
Implements PathFind::Search. Definition at line 310 of file astar.h. References PathFind::Statistics::add(), PathFind::StatisticsCollection::clear(), PathFind::AStar< MARKER, CLOSED >::findPathAStar(), PathFind::StatisticsCollection::get(), PathFind::Environment::isValidNodeId(), PathFind::AStar< MARKER, CLOSED >::m_env, PathFind::AStar< MARKER, CLOSED >::m_nodesExpanded, PathFind::AStar< MARKER, CLOSED >::m_nodesVisited, PathFind::AStar< MARKER, CLOSED >::m_path, PathFind::AStar< MARKER, CLOSED >::m_statistics, PathFind::AStar< MARKER, CLOSED >::m_target, and PathFind::AStar< MARKER, CLOSED >::m_visitedNodes. |
|
|
Construct path and set statistics after target node was found.
Definition at line 382 of file astar.h. References PathFind::Statistics::add(), PathFind::StatisticsCollection::get(), PathFind::AStar< MARKER, CLOSED >::m_closed, PathFind::AStarNode::m_f, PathFind::AStar< MARKER, CLOSED >::m_path, PathFind::AStar< MARKER, CLOSED >::m_pathCost, PathFind::AStar< MARKER, CLOSED >::m_statistics, and PathFind::AStar< MARKER, CLOSED >::m_target. Referenced by PathFind::AStar< MARKER, CLOSED >::findPathAStar(). |
|
Definition at line 391 of file astar.h. References PathFind::AStarNode::m_nodeId, PathFind::AStar< MARKER, CLOSED >::m_nodesVisited, PathFind::AStar< MARKER, CLOSED >::m_open, and PathFind::AStar< MARKER, CLOSED >::m_visitedNodes. Referenced by PathFind::AStar< MARKER, CLOSED >::findPathAStar(). |
|
Definition at line 48 of file search.h. References PathFind::Search::m_nodesLimit. |
|
Implements PathFind::Search. Definition at line 212 of file astar.h. References PathFind::AStar< MARKER, CLOSED >::m_path. |
|
Definition at line 230 of file astar.h. References PathFind::AStar< MARKER, CLOSED >::m_pathCost. |
|
Get statistics of last search.
Implements PathFind::Search. Definition at line 403 of file astar.h. References PathFind::AStar< MARKER, CLOSED >::m_statistics. |
|
Get a vector with 'x' char labels for each visited node.
Implements PathFind::Search. Definition at line 220 of file astar.h. References PathFind::AStar< MARKER, CLOSED >::m_visitedNodes. |
|
Set nodes limit for search engine. The default is -1 and means unlimited search. The nodes limit is a hint only, the search engine may ignore it. Reimplemented from PathFind::Search. Definition at line 225 of file astar.h. References PathFind::Search::m_nodesLimit. |
|
Definition at line 256 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPathAStar(). |
|
Definition at line 246 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findNode(), PathFind::AStar< MARKER, CLOSED >::findPathAStar(), and PathFind::AStar< MARKER, CLOSED >::finishSearch(). |
|
Definition at line 240 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), and PathFind::AStar< MARKER, CLOSED >::findPathAStar(). |
|
Definition at line 242 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), and PathFind::AStar< MARKER, CLOSED >::findPathAStar(). |
|
Definition at line 78 of file search.h. Referenced by PathFind::Search::getNodesLimit(), PathFind::Search::Search(), PathFind::IDAStar::searchPathIdaStar(), PathFind::Search::setNodesLimit(), and PathFind::AStar< MARKER, CLOSED >::setNodesLimit(). |
|
Definition at line 244 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), and PathFind::AStar< MARKER, CLOSED >::getBestNodeFromOpen(). |
|
Definition at line 252 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findNode(), PathFind::AStar< MARKER, CLOSED >::findPathAStar(), and PathFind::AStar< MARKER, CLOSED >::getBestNodeFromOpen(). |
|
Definition at line 250 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), PathFind::AStar< MARKER, CLOSED >::finishSearch(), and PathFind::AStar< MARKER, CLOSED >::getPath(). |
|
Definition at line 236 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPathAStar(), PathFind::AStar< MARKER, CLOSED >::finishSearch(), and PathFind::AStar< MARKER, CLOSED >::getPathCost(). |
|
Definition at line 254 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), PathFind::AStar< MARKER, CLOSED >::finishSearch(), and PathFind::AStar< MARKER, CLOSED >::getStatistics(). |
|
Definition at line 238 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), PathFind::AStar< MARKER, CLOSED >::findPathAStar(), and PathFind::AStar< MARKER, CLOSED >::finishSearch(). |
|
Definition at line 248 of file astar.h. Referenced by PathFind::AStar< MARKER, CLOSED >::findPath(), PathFind::AStar< MARKER, CLOSED >::getBestNodeFromOpen(), and PathFind::AStar< MARKER, CLOSED >::getVisitedNodes(). |