HOG2
|
A generic focal list algorithm. More...
#include <Focal.h>
Classes | |
struct | FocalTreapItem |
struct | OpenTreapItem |
struct | SearchState |
Public Types | |
enum | stateLoc { kClosedList, kOpenList, kOpenFocalList } |
Public Member Functions | |
Focal (double optimalBound=2) | |
virtual | ~Focal () |
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) |
** More... | |
void | ExtractPathToStart (state &node, std::vector< state > &thePath) |
void | ExtractPathToStartFromID (size_t node, std::vector< state > &thePath) |
Returns the next state on the open list (but doesn't pop it off the queue). 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 Focal. More... | |
state | CheckNextOpenNode () |
Get state from the closed list. More... | |
state | CheckNextFocalNode () |
bool | GetOpenListGCost (const state &val, double &gCost) const |
bool | GetFocalListGCost (const state &val, double &gCost) const |
const int | GetNumItems () |
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 | SetOptimalityBound (double w) |
double | GetOptimalityBound () |
unsigned int | GetNumOpenItems () |
unsigned int | GetNumFocalItems () |
const Focal< state, action, environment >::SearchState & | GetOpenItem (unsigned int which) |
const Focal< state, action, environment >::SearchState & | GetFocalItem (unsigned int which) |
Public Member Functions inherited from GenericSearchAlgorithm< state, action, environment > | |
GenericSearchAlgorithm () | |
virtual | ~GenericSearchAlgorithm () |
virtual void | OpenGLDraw (const environment *env) const |
Public Attributes | |
state | goal |
state | start |
Private Member Functions | |
SearchState & | PeekOpen () |
SearchState & | PeekFocal () |
void | Add (state &s, double g, double h, size_t parent) |
void | DrawOpen (Graphics::Display &d) const |
void | DrawFocal (Graphics::Display &d) const |
void | ExpandOpen () |
Expands a single state from the given open list. More... | |
void | ExpandFocal () |
Private Attributes | |
Treap< FocalTreapItem > | focal |
Treap< OpenTreapItem > | open |
std::unordered_map< state, size_t > | hash |
std::vector< SearchState > | states |
std::function< double(double, double)> | phi_focal |
std::function< double(double, double)> | phi_open |
uint64_t | nodesTouched |
uint64_t | nodesExpanded |
std::vector< state > | neighbors |
std::vector< uint64_t > | neighborID |
std::vector< double > | edgeCosts |
std::vector< dataLocation > | neighborLoc |
std::vector< state > | solution |
environment * | env |
double | bestSolution |
double | bound |
uint64_t | uniqueNodesExpanded |
double | minF |
Heuristic< state > * | theHeuristic |
A generic focal list algorithm.
Open is sorted by f; provide a function for sorting focal Provide a weight w Given minimum f in open, anything up to w*minf goes into focal Expand from focal until empty; otherwise expand from open
enum Focal::stateLoc |
|
inline |
Definition at line 46 of file Focal.h.
References Focal< state, action, environment >::bound, Focal< state, action, environment >::env, Focal< state, action, environment >::phi_focal, Focal< state, action, environment >::phi_open, Focal< state, action, environment >::ResetNodeCount(), and Focal< state, action, environment >::theHeuristic.
|
private |
state Focal< state, action, environment >::CheckNextFocalNode |
state Focal< state, action, environment >::CheckNextOpenNode |
|
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 369 of file Focal.h.
References fless(), flesseq(), kOpenList, and Focal< state, action, environment >::FocalTreapItem::location.
void Focal< state, action, environment >::Draw | ( | Graphics::Display & | d | ) | const |
Definition at line 961 of file Focal.h.
References d, kClosedList, and kOpenList.
|
private |
|
private |
|
private |
|
private |
Expands a single state from the given open list.
Definition at line 492 of file Focal.h.
References kClosedList.
|
inline |
Definition at line 65 of file Focal.h.
References Focal< state, action, environment >::env, Focal< state, action, environment >::ExtractPathToStartFromID(), and Focal< state, action, environment >::focal.
void Focal< state, action, environment >::ExtractPathToStartFromID | ( | size_t | node, |
std::vector< state > & | thePath | ||
) |
Returns the next state on the open list (but doesn't pop it off the queue).
goalNode | the goal state |
thePath | will contain the path from goalNode to the start state |
Definition at line 701 of file Focal.h.
Referenced by Focal< state, action, environment >::ExtractPathToStart().
|
inline |
Definition at line 125 of file Focal.h.
References Focal< state, action, environment >::focal, and Focal< state, action, environment >::states.
bool Focal< state, action, environment >::GetFocalListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
int Focal< state, action, environment >::GetMemoryUsage |
|
virtual |
Return the name of the algorithm.
Implements GenericSearchAlgorithm< state, action, environment >.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 93 of file Focal.h.
References Focal< state, action, environment >::nodesExpanded.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 94 of file Focal.h.
References Focal< state, action, environment >::nodesTouched.
|
inline |
Definition at line 119 of file Focal.h.
References Focal< state, action, environment >::focal.
|
inline |
Definition at line 84 of file Focal.h.
References Focal< state, action, environment >::states.
|
inline |
Definition at line 118 of file Focal.h.
References Focal< state, action, environment >::open.
|
inline |
Definition at line 120 of file Focal.h.
References Focal< state, action, environment >::open, and Focal< state, action, environment >::states.
bool Focal< state, action, environment >::GetOpenListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Definition at line 785 of file Focal.h.
References kClosedList.
|
inline |
Definition at line 102 of file Focal.h.
References Focal< state, action, environment >::bound.
const state & Focal< state, action, environment >::GetParent | ( | const state & | s | ) |
|
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 72 of file Focal.h.
References Focal< state, action, environment >::uniqueNodesExpanded.
|
virtual |
Initialize the A* search.
_env | The search environment |
from | The start state |
to | The goal state |
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
|
inlinevirtual |
|
virtual |
Draw the open/closed list.
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
|
inlineprivate |
Definition at line 198 of file Focal.h.
References Focal< state, action, environment >::focal.
|
inlineprivate |
Definition at line 193 of file Focal.h.
References Focal< state, action, environment >::open.
void Focal< state, action, environment >::PrintStats |
|
inline |
Definition at line 73 of file Focal.h.
References Focal< state, action, environment >::nodesExpanded, Focal< state, action, environment >::nodesTouched, and Focal< state, action, environment >::uniqueNodesExpanded.
Referenced by Focal< state, action, environment >::Focal().
|
inline |
Definition at line 91 of file Focal.h.
References Focal< state, action, environment >::theHeuristic.
|
inline |
Definition at line 101 of file Focal.h.
References Focal< state, action, environment >::bound, and Focal< state, action, environment >::phi_focal.
|
private |
|
private |
Definition at line 225 of file Focal.h.
Referenced by Focal< state, action, environment >::Focal(), Focal< state, action, environment >::GetOptimalityBound(), and Focal< state, action, environment >::SetOptimalityBound().
|
private |
|
private |
Definition at line 223 of file Focal.h.
Referenced by Focal< state, action, environment >::ExtractPathToStart(), and Focal< state, action, environment >::Focal().
|
private |
state Focal< state, action, environment >::goal |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 215 of file Focal.h.
Referenced by Focal< state, action, environment >::GetNodesExpanded(), and Focal< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 215 of file Focal.h.
Referenced by Focal< state, action, environment >::GetNodesTouched(), and Focal< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 205 of file Focal.h.
Referenced by Focal< state, action, environment >::GetNumOpenItems(), Focal< state, action, environment >::GetOpenItem(), and Focal< state, action, environment >::PeekOpen().
|
private |
Definition at line 208 of file Focal.h.
Referenced by Focal< state, action, environment >::Focal(), and Focal< state, action, environment >::SetOptimalityBound().
|
private |
Definition at line 209 of file Focal.h.
Referenced by Focal< state, action, environment >::Focal().
|
private |
state Focal< state, action, environment >::start |
|
private |
Definition at line 207 of file Focal.h.
Referenced by Focal< state, action, environment >::GetFocalItem(), Focal< state, action, environment >::GetNumItems(), and Focal< state, action, environment >::GetOpenItem().
|
private |
Definition at line 228 of file Focal.h.
Referenced by Focal< state, action, environment >::Focal(), and Focal< state, action, environment >::SetHeuristic().
|
private |
Definition at line 226 of file Focal.h.
Referenced by Focal< state, action, environment >::GetUniqueNodesExpanded(), and Focal< state, action, environment >::ResetNodeCount().