HOG2
|
Cluster abstraction for HPA* algorithm as described in (Botea,Mueller,Schaeffer 2004). More...
#include <ClusterAbstraction.h>
Public Member Functions | |
ClusterAbstraction (Map *map, int _clusterSize) | |
create a cluster abstraction for the given map. More... | |
~ClusterAbstraction () | |
MapAbstraction * | Clone (Map *map) |
int | getClusterSize () |
bool | Pathable (node *start, node *goal) |
Check if there is a path between two nodes. More... | |
void | VerifyHierarchy () |
void | removeNodes (node *start, node *goal) |
remove a start or goal node after the search has been completed. More... | |
void | RemoveNode (node *) |
void | RemoveEdge (edge *, unsigned int) |
void | AddNode (node *) |
void | AddEdge (edge *, unsigned int) |
void | RepairAbstraction () |
node * | insertNode (node *n, int &expanded, int &touched) |
insert a start or goal node in to the abstract Graph (for searching purposes). More... | |
path * | getCachedPath (edge *e) |
get the map-level path that corresponds to abstract edge e More... | |
node * | getLowLevelNode (node *abstract) |
get the map-level node that is at the (x,y) coordinates of the abstract node More... | |
int | getClusterIdFromNode (node *n) |
Given a map node, return the ID of the cluster it's in. More... | |
int | getClusterIdFromCoord (int row, int col) const |
given a node's coordinates, find the cluster it's in More... | |
void | printMapCoord (node *n) |
void | printPathAsCoord (path *p) |
virtual void | OpenGLDraw () const |
Private Member Functions | |
int | min (int, int) |
void | createClustersAndEntrances () |
create clusters on the abstract level and create corresponding entrances. More... | |
void | createAbstractGraph () |
void | addCluster (Cluster c) |
void | createHorizEntrances (int, int, int, int, int) |
based on the function from HPA* abswizard.cpp with the same name More... | |
void | createVertEntrances (int, int, int, int, int) |
based on the function from HPA* abstiling.cpp with the same name More... | |
void | linkEntrancesAndClusters () |
from original HPA* abstiling.cpp More... | |
void | addAbsNodes (Graph *g) |
Add a node for cluster for each entrance. More... | |
void | computeClusterPaths (Graph *g) |
void | addEntrance (Entrance e) |
int | getClusterId (int row, int col) const |
given a cluster row and column (NOT map row/column), return the cluster's ID. More... | |
Cluster & | getCluster (int id) |
get the cluster from it's ID More... | |
int | nodeExists (const Cluster &c, double x, double y, Graph *g) |
check if a node already exists in a certain cluster with a particular set of coordinates More... | |
void | setUpParents (Graph *g) |
Nodes are assigned the closest entrance node in the abstract Graph as their parent. More... | |
void | buildNodeIntoParent (node *n, node *parent) |
void | abstractionBFS (node *which, node *parent, int cluster, int numOrigNodes, int numNodesAfter) |
'borrowed' from MapSectorAbstraction.cpp More... | |
void | createConnectivityGraph () |
Add a 2nd level to the Graph. More... | |
void | connectedBFS (node *which, node *parent) |
Private Attributes | |
int | clusterSize |
int | rows |
int | columns |
std::vector< Cluster > | clusters |
std::vector< Entrance > | entrances |
clusterUtil::PathLookupTable | paths |
clusterUtil::PathLookupTable | temp |
std::vector< path * > | newPaths |
Cluster abstraction for HPA* algorithm as described in (Botea,Mueller,Schaeffer 2004).
Source code based on HPA* code found at http://www.cs.ualberta.ca/~adib/Home/Download/hpa.tgz
Definition at line 122 of file ClusterAbstraction.h.
ClusterAbstraction::ClusterAbstraction | ( | Map * | map, |
int | _clusterSize | ||
) |
create a cluster abstraction for the given map.
Clusters are square, with height = width = clustersize.
Definition at line 95 of file ClusterAbstraction.cpp.
References createAbstractGraph(), createClustersAndEntrances(), GetMapGraph(), and linkEntrancesAndClusters().
Referenced by Clone().
ClusterAbstraction::~ClusterAbstraction | ( | ) |
Definition at line 104 of file ClusterAbstraction.cpp.
References Graph::edgeIterNext(), Graph::getEdgeIter(), paths, and temp.
|
private |
'borrowed' from MapSectorAbstraction.cpp
Definition at line 911 of file ClusterAbstraction.cpp.
References Cluster::addParent(), buildNodeIntoParent(), getCluster(), getClusterIdFromNode(), node::GetLabelL(), node::getNeighborIter(), GraphAbstractionConstants::kParent, and node::nodeNeighborNext().
Referenced by setUpParents().
|
private |
Add a node for cluster for each entrance.
Definition at line 392 of file ClusterAbstraction.cpp.
References Graph::AddEdge(), Cluster::AddNode(), Graph::AddNode(), entrances, Entrance::getCenter1Col(), Entrance::getCenter1Row(), getCluster(), Entrance::getCluster1Id(), Entrance::getCluster2Id(), Map::GetOpenGLCoord(), Entrance::getOrientation(), HORIZONTAL, GraphAbstractionConstants::kAbstractionLevel, GraphAbstractionConstants::kNumAbstractedNodes, GraphAbstractionConstants::kParent, GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, GraphAbstractionConstants::kZCoordinate, nodeExists(), node::SetLabelF(), node::SetLabelL(), verbose, VERTICAL, recVec::x, recVec::y, and recVec::z.
Referenced by createAbstractGraph().
|
private |
Definition at line 202 of file ClusterAbstraction.cpp.
References clusters.
Referenced by createClustersAndEntrances().
|
inline |
Definition at line 136 of file ClusterAbstraction.h.
|
private |
Definition at line 210 of file ClusterAbstraction.cpp.
References entrances.
Referenced by createHorizEntrances(), and createVertEntrances().
|
inline |
Definition at line 135 of file ClusterAbstraction.h.
Definition at line 999 of file ClusterAbstraction.cpp.
References node::GetLabelL(), node::GetNum(), GraphAbstractionConstants::kAbstractionLevel, GraphAbstractionConstants::kFirstData, GraphAbstractionConstants::kNumAbstractedNodes, GraphAbstractionConstants::kParent, and node::SetLabelL().
Referenced by abstractionBFS(), connectedBFS(), insertNode(), and setUpParents().
|
inline |
Definition at line 126 of file ClusterAbstraction.h.
References ClusterAbstraction(), and clusterSize.
|
private |
Definition at line 528 of file ClusterAbstraction.cpp.
References Graph::AddEdge(), clusters, Cluster::getIthNodeNum(), node::GetLabelF(), Graph::GetNode(), node::GetNum(), Cluster::GetNumNodes(), GenericAStar::GetPath(), Map::GetPointFromCoordinate(), GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, GraphAbstractionConstants::kZCoordinate, Cluster::parents, path, paths, point3d, ClusterSearchEnvironment::setCorridor(), and verbose.
Referenced by createAbstractGraph().
Definition at line 965 of file ClusterAbstraction.cpp.
References buildNodeIntoParent(), node::GetLabelL(), node::getNeighborIter(), GraphAbstractionConstants::kParent, and node::nodeNeighborNext().
Referenced by createConnectivityGraph().
|
private |
Definition at line 180 of file ClusterAbstraction.cpp.
References addAbsNodes(), computeClusterPaths(), createConnectivityGraph(), setUpParents(), and verbose.
Referenced by ClusterAbstraction().
|
private |
create clusters on the abstract level and create corresponding entrances.
Definition at line 125 of file ClusterAbstraction.cpp.
References addCluster(), clusterSize, columns, createHorizEntrances(), createVertEntrances(), Map::GetMapHeight(), Map::GetMapWidth(), min(), rows, and verbose.
Referenced by ClusterAbstraction().
|
private |
Add a 2nd level to the Graph.
If two nodes in the abstract (level 1) Graph have the same parent, there is a path between them.
Definition at line 933 of file ClusterAbstraction.cpp.
References Graph::AddNode(), connectedBFS(), Graph::getNodeIter(), GraphAbstractionConstants::kAbstractionLevel, GraphAbstractionConstants::kNodeBlocked, GraphAbstractionConstants::kNumAbstractedNodes, GraphAbstractionConstants::kParent, GraphAbstractionConstants::kUnknownPosition, GraphAbstractionConstants::kXCoordinate, node::SetLabelF(), and node::SetLabelL().
Referenced by createAbstractGraph().
|
private |
based on the function from HPA* abswizard.cpp with the same name
Create horizontal entrances. Between 2 obstacles, there is either one or two entrances, depending on how many tiles there are between these obstacles.
Definition at line 221 of file ClusterAbstraction.cpp.
References addEntrance(), Graph::FindEdge(), Map::GetNodeNum(), HORIZONTAL, and MAX_ENTRANCE_WIDTH.
Referenced by createClustersAndEntrances().
|
private |
based on the function from HPA* abstiling.cpp with the same name
create vertical entrances
Definition at line 284 of file ClusterAbstraction.cpp.
References addEntrance(), Graph::FindEdge(), Map::GetNodeNum(), MAX_ENTRANCE_WIDTH, and VERTICAL.
Referenced by createClustersAndEntrances().
get the map-level path that corresponds to abstract edge e
Definition at line 1263 of file ClusterAbstraction.cpp.
|
private |
get the cluster from it's ID
Definition at line 635 of file ClusterAbstraction.cpp.
References clusters.
Referenced by abstractionBFS(), addAbsNodes(), insertNode(), and removeNodes().
|
private |
given a cluster row and column (NOT map row/column), return the cluster's ID.
Definition at line 615 of file ClusterAbstraction.cpp.
References columns.
Referenced by getClusterIdFromCoord(), and linkEntrancesAndClusters().
int ClusterAbstraction::getClusterIdFromCoord | ( | int | row, |
int | col | ||
) | const |
given a node's coordinates, find the cluster it's in
Definition at line 624 of file ClusterAbstraction.cpp.
References clusterSize, and getClusterId().
Referenced by getClusterIdFromNode(), insertNode(), and removeNodes().
int ClusterAbstraction::getClusterIdFromNode | ( | node * | n | ) |
Given a map node, return the ID of the cluster it's in.
Only works for map
Definition at line 671 of file ClusterAbstraction.cpp.
References getClusterIdFromCoord(), node::GetLabelF(), node::GetLabelL(), Map::GetPointFromCoordinate(), GraphAbstractionConstants::kAbstractionLevel, GraphAbstractionConstants::kFirstData, GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, and point3d.
Referenced by abstractionBFS(), and setUpParents().
|
inline |
Definition at line 129 of file ClusterAbstraction.h.
References clusterSize.
get the map-level node that is at the (x,y) coordinates of the abstract node
Definition at line 1274 of file ClusterAbstraction.cpp.
References Map::GetPointFromCoordinate(), GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, and point3d.
Referenced by setUpParents().
insert a start or goal node in to the abstract Graph (for searching purposes).
The node is inserted in the same location as it is in on the map-Graph. Edges are added between this node and all entrance nodes in its cluster when there is a path between the nodes. The weight of the edge is set to the distance of the map-level path
Definition at line 1015 of file ClusterAbstraction.cpp.
References Graph::AddEdge(), Graph::AddNode(), buildNodeIntoParent(), getCluster(), getClusterIdFromCoord(), Cluster::getIthNodeNum(), node::GetLabelF(), node::GetLabelL(), Graph::GetNode(), GenericAStar::GetNodesExpanded(), GenericAStar::GetNodesTouched(), node::GetNum(), Cluster::GetNumNodes(), Map::GetOpenGLCoord(), GenericAStar::GetPath(), Map::GetPointFromCoordinate(), GraphAbstractionConstants::kAbstractionLevel, GraphAbstractionConstants::kFirstData, GraphAbstractionConstants::kNumAbstractedNodes, GraphAbstractionConstants::kParent, GraphAbstractionConstants::kUnknownPosition, GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, GraphAbstractionConstants::kZCoordinate, newPaths, nodeExists(), Cluster::parents, path, point3d, ClusterSearchEnvironment::setCorridor(), node::SetLabelF(), node::SetLabelL(), temp, verbose, recVec::x, recVec::y, and recVec::z.
|
private |
from original HPA* abstiling.cpp
Definition at line 351 of file ClusterAbstraction.cpp.
References entrances, getClusterId(), Entrance::getCol(), Entrance::getOrientation(), Entrance::getRow(), HORIZONTAL, Entrance::setCluster1Id(), Entrance::setCluster2Id(), verbose, and VERTICAL.
Referenced by ClusterAbstraction().
|
private |
Definition at line 168 of file ClusterAbstraction.cpp.
Referenced by createClustersAndEntrances().
check if a node already exists in a certain cluster with a particular set of coordinates
Definition at line 649 of file ClusterAbstraction.cpp.
References Cluster::getIthNodeNum(), node::GetLabelF(), Graph::GetNode(), Cluster::GetNumNodes(), GraphAbstractionConstants::kXCoordinate, and GraphAbstractionConstants::kYCoordinate.
Referenced by addAbsNodes(), insertNode(), and removeNodes().
|
virtual |
Definition at line 1323 of file ClusterAbstraction.cpp.
References clusterSize, Map::GetMapHeight(), Map::GetMapWidth(), and Map::GetOpenGLCoord().
Check if there is a path between two nodes.
Definition at line 984 of file ClusterAbstraction.cpp.
References node::GetLabelL(), and GraphAbstractionConstants::kParent.
void ClusterAbstraction::printMapCoord | ( | node * | n | ) |
Definition at line 1286 of file ClusterAbstraction.cpp.
References node::GetLabelF(), node::GetLabelL(), Graph::GetNode(), Map::GetPointFromCoordinate(), GraphAbstractionConstants::kParent, GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, point3d, px2, and py2.
Referenced by printPathAsCoord().
void ClusterAbstraction::printPathAsCoord | ( | path * | p | ) |
Definition at line 1307 of file ClusterAbstraction.cpp.
References path::n, path::next, and printMapCoord().
|
inline |
Definition at line 134 of file ClusterAbstraction.h.
|
inline |
Definition at line 133 of file ClusterAbstraction.h.
remove a start or goal node after the search has been completed.
The node is removed, as well as all the edges that were added to connect it to the cluster. The edges are also removed from the cache.
Definition at line 1169 of file ClusterAbstraction.cpp.
References node::edgeIterNext(), getCluster(), getClusterIdFromCoord(), node::getEdgeIter(), node::GetLabelF(), node::GetLabelL(), node::GetNum(), node::GetNumEdges(), Graph::GetNumNodes(), Map::GetPointFromCoordinate(), GraphAbstractionConstants::kParent, GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, newPaths, nodeExists(), point3d, px2, py2, Graph::RemoveEdge(), Graph::RemoveNode(), temp, and verbose.
|
inline |
Definition at line 137 of file ClusterAbstraction.h.
|
private |
Nodes are assigned the closest entrance node in the abstract Graph as their parent.
Connected components that cannot reach any entrance nodes will be assigned their own parent node.
Connected component code borrowed from MapSectorAbstraction.cpp
Definition at line 695 of file ClusterAbstraction.cpp.
References abstractionBFS(), Graph::AddNode(), buildNodeIntoParent(), clusters, getClusterIdFromNode(), Cluster::GetHeight(), Cluster::getHOrig(), Cluster::getIthNodeNum(), node::GetLabelF(), node::GetLabelL(), getLowLevelNode(), Graph::GetNode(), Map::GetNodeNum(), node::GetNum(), Cluster::GetNumNodes(), Graph::GetNumNodes(), GenericAStar::GetPath(), Map::GetPointFromCoordinate(), Cluster::getVOrig(), Cluster::getWidth(), GraphAbstractionConstants::kAbstractionLevel, GraphAbstractionConstants::kFirstData, GraphAbstractionConstants::kNodeBlocked, GraphAbstractionConstants::kNumAbstractedNodes, GraphAbstractionConstants::kParent, GraphAbstractionConstants::kUnknownPosition, GraphAbstractionConstants::kXCoordinate, GraphAbstractionConstants::kYCoordinate, path, point3d, Graph::RemoveNode(), ClusterSearchEnvironment::setCorridor(), node::SetLabelF(), node::SetLabelL(), and verbose.
Referenced by createAbstractGraph().
|
inline |
Definition at line 131 of file ClusterAbstraction.h.
|
private |
Definition at line 169 of file ClusterAbstraction.h.
Referenced by addCluster(), computeClusterPaths(), getCluster(), and setUpParents().
|
private |
Definition at line 165 of file ClusterAbstraction.h.
Referenced by Clone(), createClustersAndEntrances(), getClusterIdFromCoord(), getClusterSize(), and OpenGLDraw().
|
private |
Definition at line 167 of file ClusterAbstraction.h.
Referenced by createClustersAndEntrances(), and getClusterId().
|
private |
Definition at line 170 of file ClusterAbstraction.h.
Referenced by addAbsNodes(), addEntrance(), and linkEntrancesAndClusters().
|
private |
Definition at line 173 of file ClusterAbstraction.h.
Referenced by insertNode(), and removeNodes().
|
private |
Definition at line 171 of file ClusterAbstraction.h.
Referenced by computeClusterPaths(), getCachedPath(), and ~ClusterAbstraction().
|
private |
Definition at line 166 of file ClusterAbstraction.h.
Referenced by createClustersAndEntrances().
|
private |
Definition at line 172 of file ClusterAbstraction.h.
Referenced by getCachedPath(), insertNode(), removeNodes(), and ~ClusterAbstraction().