HOG2
|
A templated version of A*, based on HOG genericAStar. More...
#include <IOS.h>
Public Types | |
typedef AStarOpenClosed< state, IOSCompare< state >, IOSOpenClosedData< state > > | openList |
Public Member Functions | |
ImprovedOptimisticSearch () | |
virtual | ~ImprovedOptimisticSearch () |
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 ImprovedOptimisticSearch. 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, IOSOpenClosedData< state > &) |
unsigned int | GetNumOpenItems () |
const IOSOpenClosedData< state > & | GetOpenItem (unsigned int which) |
const int | GetNumItems () |
const IOSOpenClosedData< 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 () |
void | SetPhi (std::function< double(double, double)> p) |
double | Phi (double h, double g) |
Public Member Functions inherited from GenericSearchAlgorithm< state, action, environment > | |
GenericSearchAlgorithm () | |
virtual | ~GenericSearchAlgorithm () |
virtual void | OpenGLDraw (const environment *env) const |
Public Attributes | |
AStarOpenClosed< state, IOSCompare< state >, IOSOpenClosedData< state > > | openClosedList |
state | goal |
state | start |
Private Member Functions | |
void | DoGreedyStep (std::vector< state > &thePath) |
void | DoOptimalStep (std::vector< state > &thePath) |
Private Attributes | |
uint64_t | nodesTouched |
uint64_t | nodesExpanded |
std::vector< state > | internalPath |
std::vector< state > | neighbors |
std::vector< uint64_t > | neighborID |
std::vector< double > | edgeCosts |
std::vector< dataLocation > | neighborLoc |
environment * | env |
std::function< double(double, double)> | phi |
std::function< double(double, double)> | greedyPhi |
double | bestSolution |
double | solutionReduction |
double | weight |
double | bound |
bool | reopenNodes |
uint64_t | uniqueNodesExpanded |
Heuristic< state > * | theHeuristic |
bool | doneGreedy |
double | maxPriority |
A templated version of A*, based on HOG genericAStar.
typedef AStarOpenClosed<state, IOSCompare<state>, IOSOpenClosedData<state> > ImprovedOptimisticSearch< state, action, environment >::openList |
|
inline |
Definition at line 55 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::bound, ImprovedOptimisticSearch< state, action, environment >::env, ImprovedOptimisticSearch< state, action, environment >::greedyPhi, ImprovedOptimisticSearch< state, action, environment >::phi, ImprovedOptimisticSearch< state, action, environment >::ResetNodeCount(), ImprovedOptimisticSearch< state, action, environment >::theHeuristic, and ImprovedOptimisticSearch< state, action, environment >::weight.
|
inlinevirtual |
void ImprovedOptimisticSearch< 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 265 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode().
void ImprovedOptimisticSearch< 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 277 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode().
state ImprovedOptimisticSearch< state, action, environment >::CheckNextNode |
Returns the next state on the open list (but doesn't pop it off the queue).
Definition at line 526 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and AStarOpenClosed< state, CmpKey, dataStructure >::Peek().
|
private |
Definition at line 324 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode(), AStarOpenClosed< state, CmpKey, dataStructure >::Close(), AStarOpenClosed< state, CmpKey, dataStructure >::CloseAllOnOpen(), fless(), kClosedList, AStarOpenClosed< state, CmpKey, dataStructure >::KeyChanged(), kNotFound, kOpenList, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), max, and AStarOpenClosed< state, CmpKey, dataStructure >::Reopen().
|
private |
Definition at line 416 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode(), AStarOpenClosed< state, CmpKey, dataStructure >::Close(), fless(), kClosedList, AStarOpenClosed< state, CmpKey, dataStructure >::KeyChanged(), kNotFound, kOpenList, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), max, and AStarOpenClosed< state, CmpKey, dataStructure >::Reopen().
|
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 294 of file IOS.h.
References flesseq(), and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().
void ImprovedOptimisticSearch< state, action, environment >::Draw | ( | Graphics::Display & | d | ) | const |
Definition at line 634 of file IOS.h.
References kClosedList, kOpenList, AStarOpenClosed< state, CmpKey, dataStructure >::Lookat(), AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize(), AStarOpenClosed< state, CmpKey, dataStructure >::Peek(), and AStarOpenClosed< state, CmpKey, dataStructure >::size().
|
inline |
Definition at line 76 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::env, ImprovedOptimisticSearch< state, action, environment >::ExtractPathToStartFromID(), kNotFound, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and ImprovedOptimisticSearch< state, action, environment >::openClosedList.
void ImprovedOptimisticSearch< state, action, environment >::ExtractPathToStartFromID | ( | uint64_t | node, |
std::vector< state > & | thePath | ||
) |
Get the path from a goal state to the start state.
node | the state from which to extract the goal |
thePath | will contain the path from goalNode to the start state |
Definition at line 541 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
Referenced by ImprovedOptimisticSearch< state, action, environment >::ExtractPathToStart().
bool ImprovedOptimisticSearch< state, action, environment >::GetClosedItem | ( | const state & | s, |
IOSOpenClosedData< state > & | |||
) |
bool ImprovedOptimisticSearch< 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 597 of file IOS.h.
References kClosedList, AStarOpenClosed< state, CmpKey, dataStructure >::Lookat(), and AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
bool ImprovedOptimisticSearch< state, action, environment >::GetFocalListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
|
inline |
Definition at line 101 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::openClosedList.
int ImprovedOptimisticSearch< state, action, environment >::GetMemoryUsage |
Return the amount of memory used by ImprovedOptimisticSearch.
Definition at line 581 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::size().
|
virtual |
Return the name of the algorithm.
Implements GenericSearchAlgorithm< state, action, environment >.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 113 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::nodesExpanded.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 114 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::nodesTouched.
|
inline |
Definition at line 100 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::openClosedList, and AStarOpenClosed< state, CmpKey, dataStructure >::size().
|
inline |
Definition at line 96 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::openClosedList, and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().
|
inline |
Definition at line 97 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::GetOpenItem(), AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and ImprovedOptimisticSearch< state, action, environment >::openClosedList.
bool ImprovedOptimisticSearch< state, action, environment >::GetOpenListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Definition at line 610 of file IOS.h.
References kOpenList, AStarOpenClosed< state, CmpKey, dataStructure >::Lookat(), and AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
|
inline |
Definition at line 124 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::bound.
const state & ImprovedOptimisticSearch< state, action, environment >::GetParent | ( | const state & | s | ) |
Definition at line 552 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().
|
virtual |
|
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 >.
|
inline |
Definition at line 109 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::reopenNodes.
|
inline |
Definition at line 105 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::env, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and ImprovedOptimisticSearch< state, action, environment >::openClosedList.
|
inline |
Definition at line 88 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::uniqueNodesExpanded.
|
inline |
Definition at line 122 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::weight.
|
inline |
Definition at line 103 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::env, kNotFound, AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and ImprovedOptimisticSearch< state, action, environment >::openClosedList.
|
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 230 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode(), and AStarOpenClosed< state, CmpKey, dataStructure >::Reset().
|
inlinevirtual |
|
virtual |
Draw the open/closed list.
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
|
inline |
Definition at line 129 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::greedyPhi.
void ImprovedOptimisticSearch< state, action, environment >::PrintStats |
A function that prints the number of states in the closed list and open queue.
Definition at line 567 of file IOS.h.
References AStarOpenClosed< state, CmpKey, dataStructure >::ClosedSize(), and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().
|
inline |
Definition at line 89 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::nodesExpanded, ImprovedOptimisticSearch< state, action, environment >::nodesTouched, and ImprovedOptimisticSearch< state, action, environment >::uniqueNodesExpanded.
Referenced by ImprovedOptimisticSearch< state, action, environment >::ImprovedOptimisticSearch().
|
inline |
Definition at line 111 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::theHeuristic.
|
inline |
Definition at line 123 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::bound.
|
inline |
Definition at line 125 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::greedyPhi.
|
inline |
Definition at line 108 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::reopenNodes.
|
inline |
Definition at line 121 of file IOS.h.
References ImprovedOptimisticSearch< state, action, environment >::weight.
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 146 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::ExtractPathToStart(), ImprovedOptimisticSearch< state, action, environment >::GetStateLocation(), ImprovedOptimisticSearch< state, action, environment >::HaveExpandedState(), and ImprovedOptimisticSearch< state, action, environment >::ImprovedOptimisticSearch().
state ImprovedOptimisticSearch< state, action, environment >::goal |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 138 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::GetNodesExpanded(), and ImprovedOptimisticSearch< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 138 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::GetNodesTouched(), and ImprovedOptimisticSearch< state, action, environment >::ResetNodeCount().
AStarOpenClosed<state, IOSCompare<state>, IOSOpenClosedData<state> > ImprovedOptimisticSearch< state, action, environment >::openClosedList |
Definition at line 66 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::ExtractPathToStart(), ImprovedOptimisticSearch< state, action, environment >::GetItem(), ImprovedOptimisticSearch< state, action, environment >::GetNumItems(), ImprovedOptimisticSearch< state, action, environment >::GetNumOpenItems(), ImprovedOptimisticSearch< state, action, environment >::GetOpenItem(), ImprovedOptimisticSearch< state, action, environment >::GetStateLocation(), and ImprovedOptimisticSearch< state, action, environment >::HaveExpandedState().
|
private |
Definition at line 147 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::ImprovedOptimisticSearch().
|
private |
Definition at line 152 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::GetReopenNodes(), and ImprovedOptimisticSearch< state, action, environment >::SetReopenNodes().
|
private |
state ImprovedOptimisticSearch< state, action, environment >::start |
|
private |
Definition at line 154 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::ImprovedOptimisticSearch(), and ImprovedOptimisticSearch< state, action, environment >::SetHeuristic().
|
private |
Definition at line 153 of file IOS.h.
Referenced by ImprovedOptimisticSearch< state, action, environment >::GetUniqueNodesExpanded(), and ImprovedOptimisticSearch< state, action, environment >::ResetNodeCount().
|
private |