HOG2
|
A templated version of A*, based on HOG genericAStar. More...
#include <OptimisticSearch.h>
Public Types | |
typedef AStarOpenClosed< state, OptimisticCompare< state >, OptimisticOpenClosedData< state > > | openList |
Public Member Functions | |
OptimisticSearch () | |
virtual | ~OptimisticSearch () |
void | GetPath (environment *env, const state &from, const state &to, std::vector< state > &thePath) |
Perform an A* search between two states. More... | |
void | GetPath (environment *, const state &, const state &, std::vector< action > &) |
bool | InitializeSearch (environment *env, const state &from, const state &to, std::vector< state > &thePath) |
Initialize the A* search. More... | |
bool | DoSingleSearchStep (std::vector< state > &thePath) |
Expand a single node. More... | |
void | AddAdditionalStartState (state &newState) |
Add additional start state to the search. More... | |
void | AddAdditionalStartState (state &newState, double cost) |
Add additional start state to the search. More... | |
state | CheckNextNode () |
Returns the next state on the open list (but doesn't pop it off the queue). More... | |
void | ExtractPathToStart (state &node, std::vector< state > &thePath) |
void | ExtractPathToStartFromID (uint64_t node, std::vector< state > &thePath) |
Get the path from a goal state to the start state. More... | |
const state & | GetParent (const state &s) |
virtual const char * | GetName () |
Return the name of the algorithm. More... | |
void | PrintStats () |
A function that prints the number of states in the closed list and open queue. More... | |
uint64_t | GetUniqueNodesExpanded () |
void | ResetNodeCount () |
int | GetMemoryUsage () |
Return the amount of memory used by OptimisticSearch. More... | |
bool | GetClosedListGCost (const state &val, double &gCost) const |
Get state from the closed list. More... | |
bool | GetOpenListGCost (const state &val, double &gCost) const |
bool | GetFocalListGCost (const state &val, double &gCost) const |
bool | GetClosedItem (const state &s, OptimisticOpenClosedData< state > &) |
unsigned int | GetNumOpenItems () |
const OptimisticOpenClosedData< state > & | GetOpenItem (unsigned int which) |
unsigned int | GetNumFocalItems () |
const OptimisticOpenClosedData< state > & | GetFocalItem (unsigned int which) |
state | CheckNextOpenNode () |
state | CheckNextFocalNode () |
const int | GetNumItems () |
const OptimisticOpenClosedData< state > & | GetItem (unsigned int which) |
bool | HaveExpandedState (const state &val) |
dataLocation | GetStateLocation (const state &val) |
void | SetReopenNodes (bool re) |
bool | GetReopenNodes () |
void | SetHeuristic (Heuristic< state > *h) |
uint64_t | GetNodesExpanded () const |
uint64_t | GetNodesTouched () const |
void | LogFinalStats (StatCollection *) |
void | OpenGLDraw () const |
Draw the open/closed list. More... | |
void | Draw (Graphics::Display &d) const |
void | SetWeight (double w) |
double | GetWeight () |
void | SetOptimalityBound (double w) |
double | GetOptimalityBound () |
Public Member Functions inherited from GenericSearchAlgorithm< state, action, environment > | |
GenericSearchAlgorithm () | |
virtual | ~GenericSearchAlgorithm () |
virtual void | OpenGLDraw (const environment *env) const |
Public Attributes | |
openList | f |
openList | fhat |
state | goal |
state | start |
Private Attributes | |
uint64_t | nodesTouched |
uint64_t | nodesExpanded |
std::vector< state > | neighbors |
environment * | env |
double | bestSolution |
double | weight |
double | bound |
bool | reopenNodes |
uint64_t | uniqueNodesExpanded |
Heuristic< state > * | theHeuristic |
A templated version of A*, based on HOG genericAStar.
Definition at line 58 of file OptimisticSearch.h.
typedef AStarOpenClosed<state, OptimisticCompare<state>, OptimisticOpenClosedData<state> > OptimisticSearch< state, action, environment >::openList |
Definition at line 65 of file OptimisticSearch.h.
|
inline |
Definition at line 60 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::bound, OptimisticSearch< state, action, environment >::env, OptimisticSearch< state, action, environment >::ResetNodeCount(), OptimisticSearch< state, action, environment >::theHeuristic, and OptimisticSearch< state, action, environment >::weight.
|
inlinevirtual |
Definition at line 61 of file OptimisticSearch.h.
void OptimisticSearch< state, action, environment >::AddAdditionalStartState | ( | state & | newState | ) |
Add additional start state to the search.
This should only be called after Initialize Search and before DoSingleSearchStep.
Definition at line 258 of file OptimisticSearch.h.
void OptimisticSearch< state, action, environment >::AddAdditionalStartState | ( | state & | newState, |
double | cost | ||
) |
Add additional start state to the search.
This should only be called after Initialize Search
Definition at line 270 of file OptimisticSearch.h.
|
inline |
Definition at line 103 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::fhat, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and AStarOpenClosed< state, CmpKey, dataStructure >::Peek().
state OptimisticSearch< state, action, environment >::CheckNextNode |
Returns the next state on the open list (but doesn't pop it off the queue).
Definition at line 466 of file OptimisticSearch.h.
|
inline |
Definition at line 98 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::f, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and AStarOpenClosed< state, CmpKey, dataStructure >::Peek().
|
virtual |
Expand a single node.
thePath | will contain an optimal path from start to goal if the function returns TRUE |
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
Definition at line 287 of file OptimisticSearch.h.
References d, fequal(), fless(), kClosedList, kNotFound, and kOpenList.
void OptimisticSearch< state, action, environment >::Draw | ( | Graphics::Display & | d | ) | const |
Definition at line 664 of file OptimisticSearch.h.
References d, kClosedList, and kOpenList.
|
inline |
Definition at line 78 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::env, OptimisticSearch< state, action, environment >::ExtractPathToStartFromID(), OptimisticSearch< state, action, environment >::fhat, and AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
void OptimisticSearch< state, action, environment >::ExtractPathToStartFromID | ( | uint64_t | node, |
std::vector< state > & | thePath | ||
) |
Get the path from a goal state to the start state.
goalNode | the goal state |
thePath | will contain the path from goalNode to the start state |
Definition at line 484 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::ExtractPathToStart().
bool OptimisticSearch< state, action, environment >::GetClosedItem | ( | const state & | s, |
OptimisticOpenClosedData< state > & | result | ||
) |
Definition at line 579 of file OptimisticSearch.h.
References kClosedList.
bool OptimisticSearch< state, action, environment >::GetClosedListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Get state from the closed list.
val | The state to lookup in the closed list @gCost The g-cost of the node in the closed list |
Definition at line 540 of file OptimisticSearch.h.
References kClosedList.
|
inline |
Definition at line 96 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::fhat, AStarOpenClosed< state, CmpKey, dataStructure >::GetOpenItem(), and AStarOpenClosed< state, CmpKey, dataStructure >::Lookat().
bool OptimisticSearch< state, action, environment >::GetFocalListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Definition at line 566 of file OptimisticSearch.h.
References kOpenList.
|
inline |
Definition at line 111 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::fhat, and AStarOpenClosed< state, CmpKey, dataStructure >::Lookat().
int OptimisticSearch< state, action, environment >::GetMemoryUsage |
Return the amount of memory used by OptimisticSearch.
Definition at line 524 of file OptimisticSearch.h.
|
virtual |
Return the name of the algorithm.
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 161 of file OptimisticSearch.h.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 122 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::nodesExpanded.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 123 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::nodesTouched.
|
inline |
Definition at line 95 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::fhat, and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().
|
inline |
Definition at line 110 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::fhat, and AStarOpenClosed< state, CmpKey, dataStructure >::size().
|
inline |
Definition at line 93 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::f, and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().
|
inline |
Definition at line 94 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::f, AStarOpenClosed< state, CmpKey, dataStructure >::GetOpenItem(), and AStarOpenClosed< state, CmpKey, dataStructure >::Lookat().
bool OptimisticSearch< state, action, environment >::GetOpenListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Definition at line 553 of file OptimisticSearch.h.
References kOpenList.
|
inline |
Definition at line 133 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::bound.
const state & OptimisticSearch< state, action, environment >::GetParent | ( | const state & | s | ) |
Definition at line 495 of file OptimisticSearch.h.
|
virtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 195 of file OptimisticSearch.h.
|
virtual |
Perform an A* search between two states.
_env | The search environment |
from | The start state |
to | The goal state |
thePath | A vector of states which will contain an optimal path between from and to when the function returns, if one exists. |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 180 of file OptimisticSearch.h.
|
inline |
Definition at line 118 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::reopenNodes.
|
inline |
Definition at line 114 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::env, OptimisticSearch< state, action, environment >::fhat, and AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
|
inline |
Definition at line 85 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::uniqueNodesExpanded.
|
inline |
Definition at line 131 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::weight.
|
inline |
Definition at line 112 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::env, OptimisticSearch< state, action, environment >::fhat, kNotFound, and AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
|
virtual |
Initialize the A* search.
_env | The search environment |
from | The start state |
to | The goal state |
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
Definition at line 224 of file OptimisticSearch.h.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 125 of file OptimisticSearch.h.
|
virtual |
Draw the open/closed list.
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
Definition at line 600 of file OptimisticSearch.h.
References fgreater(), kClosedList, and kOpenList.
void OptimisticSearch< state, action, environment >::PrintStats |
A function that prints the number of states in the closed list and open queue.
Definition at line 510 of file OptimisticSearch.h.
|
inline |
Definition at line 86 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::nodesExpanded, OptimisticSearch< state, action, environment >::nodesTouched, and OptimisticSearch< state, action, environment >::uniqueNodesExpanded.
Referenced by OptimisticSearch< state, action, environment >::OptimisticSearch().
|
inline |
Definition at line 120 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::theHeuristic.
|
inline |
Definition at line 132 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::bound.
|
inline |
Definition at line 117 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::reopenNodes.
|
inline |
Definition at line 130 of file OptimisticSearch.h.
References OptimisticSearch< state, action, environment >::weight.
|
private |
Definition at line 142 of file OptimisticSearch.h.
|
private |
|
private |
Definition at line 141 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::ExtractPathToStart(), OptimisticSearch< state, action, environment >::GetStateLocation(), OptimisticSearch< state, action, environment >::HaveExpandedState(), and OptimisticSearch< state, action, environment >::OptimisticSearch().
openList OptimisticSearch< state, action, environment >::f |
openList OptimisticSearch< state, action, environment >::fhat |
Definition at line 69 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::CheckNextFocalNode(), OptimisticSearch< state, action, environment >::ExtractPathToStart(), OptimisticSearch< state, action, environment >::GetFocalItem(), OptimisticSearch< state, action, environment >::GetItem(), OptimisticSearch< state, action, environment >::GetNumFocalItems(), OptimisticSearch< state, action, environment >::GetNumItems(), OptimisticSearch< state, action, environment >::GetStateLocation(), and OptimisticSearch< state, action, environment >::HaveExpandedState().
state OptimisticSearch< state, action, environment >::goal |
Definition at line 70 of file OptimisticSearch.h.
|
private |
Definition at line 137 of file OptimisticSearch.h.
|
private |
Definition at line 135 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::GetNodesExpanded(), and OptimisticSearch< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 135 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::GetNodesTouched(), and OptimisticSearch< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 145 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::GetReopenNodes(), and OptimisticSearch< state, action, environment >::SetReopenNodes().
state OptimisticSearch< state, action, environment >::start |
Definition at line 70 of file OptimisticSearch.h.
|
private |
Definition at line 147 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::OptimisticSearch(), and OptimisticSearch< state, action, environment >::SetHeuristic().
|
private |
Definition at line 146 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::GetUniqueNodesExpanded(), and OptimisticSearch< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 143 of file OptimisticSearch.h.
Referenced by OptimisticSearch< state, action, environment >::GetWeight(), OptimisticSearch< state, action, environment >::OptimisticSearch(), and OptimisticSearch< state, action, environment >::SetWeight().