HOG2
|
A generic focal list algorithm that returns linearly bounded solutions 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. More...
#include <FocalAdd.h>
Classes | |
struct | FocalTreapItem |
struct | OpenTreapItem |
struct | SearchState |
Public Types | |
enum | stateLoc { kClosedList, kOpenList, kOpenFocalList } |
Public Member Functions | |
FocalAdd (double optimalBound=2) | |
virtual | ~FocalAdd () |
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 FocalAdd< state, action, environment >::SearchState & | GetOpenItem (unsigned int which) |
const FocalAdd< 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 that returns linearly bounded solutions 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.
Definition at line 46 of file FocalAdd.h.
enum FocalAdd::stateLoc |
Enumerator | |
---|---|
kClosedList | |
kOpenList | |
kOpenFocalList |
Definition at line 105 of file FocalAdd.h.
|
inline |
Definition at line 48 of file FocalAdd.h.
References FocalAdd< state, action, environment >::bound, FocalAdd< state, action, environment >::env, FocalAdd< state, action, environment >::phi_open, FocalAdd< state, action, environment >::ResetNodeCount(), and FocalAdd< state, action, environment >::theHeuristic.
|
inlinevirtual |
Definition at line 54 of file FocalAdd.h.
|
private |
Definition at line 832 of file FocalAdd.h.
References fless(), flesseq(), kClosedList, and kOpenList.
state FocalAdd< state, action, environment >::CheckNextFocalNode |
Definition at line 782 of file FocalAdd.h.
state FocalAdd< state, action, environment >::CheckNextOpenNode |
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 776 of file FocalAdd.h.
|
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 373 of file FocalAdd.h.
References fless(), flesseq(), kOpenList, and FocalAdd< state, action, environment >::FocalTreapItem::location.
void FocalAdd< state, action, environment >::Draw | ( | Graphics::Display & | d | ) | const |
Definition at line 965 of file FocalAdd.h.
References d, kClosedList, and kOpenList.
|
private |
|
private |
|
private |
Definition at line 582 of file FocalAdd.h.
References kOpenList.
|
private |
Expands a single state from the given open list.
Definition at line 496 of file FocalAdd.h.
References kClosedList.
|
inline |
Definition at line 67 of file FocalAdd.h.
References FocalAdd< state, action, environment >::env, FocalAdd< state, action, environment >::ExtractPathToStartFromID(), and FocalAdd< state, action, environment >::focal.
void FocalAdd< 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 705 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::ExtractPathToStart().
|
inline |
Definition at line 127 of file FocalAdd.h.
References FocalAdd< state, action, environment >::focal, and FocalAdd< state, action, environment >::states.
bool FocalAdd< state, action, environment >::GetFocalListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Definition at line 803 of file FocalAdd.h.
int FocalAdd< state, action, environment >::GetMemoryUsage |
Return the amount of memory used by Focal.
Definition at line 747 of file FocalAdd.h.
|
virtual |
Return the name of the algorithm.
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 244 of file FocalAdd.h.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 95 of file FocalAdd.h.
References FocalAdd< state, action, environment >::nodesExpanded.
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 96 of file FocalAdd.h.
References FocalAdd< state, action, environment >::nodesTouched.
|
inline |
Definition at line 121 of file FocalAdd.h.
References FocalAdd< state, action, environment >::focal.
|
inline |
Definition at line 86 of file FocalAdd.h.
References FocalAdd< state, action, environment >::states.
|
inline |
Definition at line 120 of file FocalAdd.h.
References FocalAdd< state, action, environment >::open.
|
inline |
Definition at line 122 of file FocalAdd.h.
References FocalAdd< state, action, environment >::open, and FocalAdd< state, action, environment >::states.
bool FocalAdd< state, action, environment >::GetOpenListGCost | ( | const state & | val, |
double & | gCost | ||
) | const |
Definition at line 789 of file FocalAdd.h.
References kClosedList.
|
inline |
Definition at line 104 of file FocalAdd.h.
References FocalAdd< state, action, environment >::bound.
const state & FocalAdd< state, action, environment >::GetParent | ( | const state & | s | ) |
Definition at line 716 of file FocalAdd.h.
|
virtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 278 of file FocalAdd.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 263 of file FocalAdd.h.
|
inline |
Definition at line 74 of file FocalAdd.h.
References FocalAdd< 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 >.
Definition at line 307 of file FocalAdd.h.
References min().
|
inlinevirtual |
Implements GenericSearchAlgorithm< state, action, environment >.
Definition at line 98 of file FocalAdd.h.
|
virtual |
Draw the open/closed list.
Reimplemented from GenericSearchAlgorithm< state, action, environment >.
Definition at line 960 of file FocalAdd.h.
|
inlineprivate |
Definition at line 200 of file FocalAdd.h.
References FocalAdd< state, action, environment >::focal.
|
inlineprivate |
Definition at line 195 of file FocalAdd.h.
References FocalAdd< state, action, environment >::open.
void FocalAdd< state, action, environment >::PrintStats |
A function that prints the number of states in the closed list and open queue.
Definition at line 733 of file FocalAdd.h.
|
inline |
Definition at line 75 of file FocalAdd.h.
References FocalAdd< state, action, environment >::nodesExpanded, FocalAdd< state, action, environment >::nodesTouched, and FocalAdd< state, action, environment >::uniqueNodesExpanded.
Referenced by FocalAdd< state, action, environment >::FocalAdd().
|
inline |
Definition at line 93 of file FocalAdd.h.
References FocalAdd< state, action, environment >::theHeuristic.
|
inline |
Definition at line 103 of file FocalAdd.h.
References FocalAdd< state, action, environment >::bound.
|
private |
Definition at line 226 of file FocalAdd.h.
|
private |
Definition at line 227 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::FocalAdd(), FocalAdd< state, action, environment >::GetOptimalityBound(), and FocalAdd< state, action, environment >::SetOptimalityBound().
|
private |
Definition at line 221 of file FocalAdd.h.
|
private |
Definition at line 225 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::ExtractPathToStart(), and FocalAdd< state, action, environment >::FocalAdd().
|
private |
state FocalAdd< state, action, environment >::goal |
Definition at line 62 of file FocalAdd.h.
|
private |
Definition at line 208 of file FocalAdd.h.
|
private |
Definition at line 229 of file FocalAdd.h.
|
private |
Definition at line 220 of file FocalAdd.h.
|
private |
Definition at line 222 of file FocalAdd.h.
|
private |
Definition at line 219 of file FocalAdd.h.
|
private |
Definition at line 217 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::GetNodesExpanded(), and FocalAdd< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 217 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::GetNodesTouched(), and FocalAdd< state, action, environment >::ResetNodeCount().
|
private |
Definition at line 207 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::GetNumOpenItems(), FocalAdd< state, action, environment >::GetOpenItem(), and FocalAdd< state, action, environment >::PeekOpen().
|
private |
Definition at line 210 of file FocalAdd.h.
|
private |
Definition at line 211 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::FocalAdd().
|
private |
Definition at line 224 of file FocalAdd.h.
state FocalAdd< state, action, environment >::start |
Definition at line 62 of file FocalAdd.h.
|
private |
Definition at line 209 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::GetFocalItem(), FocalAdd< state, action, environment >::GetNumItems(), and FocalAdd< state, action, environment >::GetOpenItem().
|
private |
Definition at line 230 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::FocalAdd(), and FocalAdd< state, action, environment >::SetHeuristic().
|
private |
Definition at line 228 of file FocalAdd.h.
Referenced by FocalAdd< state, action, environment >::GetUniqueNodesExpanded(), and FocalAdd< state, action, environment >::ResetNodeCount().