HOG2
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
OptimisticSearch< state, action, environment > Class Template Reference

A templated version of A*, based on HOG genericAStar. More...

#include <OptimisticSearch.h>

Inheritance diagram for OptimisticSearch< state, action, environment >:
Inheritance graph
[legend]
Collaboration diagram for OptimisticSearch< state, action, environment >:
Collaboration graph
[legend]

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
 

Detailed Description

template<class state, class action, class environment>
class OptimisticSearch< state, action, environment >

A templated version of A*, based on HOG genericAStar.

Definition at line 58 of file OptimisticSearch.h.

Member Typedef Documentation

◆ openList

template<class state , class action , class environment >
typedef AStarOpenClosed<state, OptimisticCompare<state>, OptimisticOpenClosedData<state> > OptimisticSearch< state, action, environment >::openList

Definition at line 65 of file OptimisticSearch.h.

Constructor & Destructor Documentation

◆ OptimisticSearch()

template<class state , class action , class environment >
OptimisticSearch< state, action, environment >::OptimisticSearch ( )
inline

◆ ~OptimisticSearch()

template<class state , class action , class environment >
virtual OptimisticSearch< state, action, environment >::~OptimisticSearch ( )
inlinevirtual

Definition at line 61 of file OptimisticSearch.h.

Member Function Documentation

◆ AddAdditionalStartState() [1/2]

template<class state , class action , class environment >
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.

Author
Nathan Sturtevant
Date
01/06/08

Definition at line 258 of file OptimisticSearch.h.

◆ AddAdditionalStartState() [2/2]

template<class state , class action , class environment >
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

Author
Nathan Sturtevant
Date
09/25/10

Definition at line 270 of file OptimisticSearch.h.

◆ CheckNextFocalNode()

template<class state , class action , class environment >
state OptimisticSearch< state, action, environment >::CheckNextFocalNode ( )
inline

◆ CheckNextNode()

template<class state , class action , class environment >
state OptimisticSearch< state, action, environment >::CheckNextNode

Returns the next state on the open list (but doesn't pop it off the queue).

Author
Nathan Sturtevant
Date
03/22/06
Returns
The first state in the open list.

Definition at line 466 of file OptimisticSearch.h.

◆ CheckNextOpenNode()

template<class state , class action , class environment >
state OptimisticSearch< state, action, environment >::CheckNextOpenNode ( )
inline

◆ DoSingleSearchStep()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::DoSingleSearchStep ( std::vector< state > &  thePath)
virtual

Expand a single node.

Author
Nathan Sturtevant
Date
03/22/06
Parameters
thePathwill contain an optimal path from start to goal if the function returns TRUE
Returns
TRUE if there is no path or if we have found the goal, FALSE otherwise

Reimplemented from GenericSearchAlgorithm< state, action, environment >.

Definition at line 287 of file OptimisticSearch.h.

References d, fequal(), fless(), kClosedList, kNotFound, and kOpenList.

◆ Draw()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::Draw ( Graphics::Display d) const

Definition at line 664 of file OptimisticSearch.h.

References d, kClosedList, and kOpenList.

◆ ExtractPathToStart()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::ExtractPathToStart ( state &  node,
std::vector< state > &  thePath 
)
inline

◆ ExtractPathToStartFromID()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::ExtractPathToStartFromID ( uint64_t  node,
std::vector< state > &  thePath 
)

Get the path from a goal state to the start state.

Author
Nathan Sturtevant
Date
03/22/06
Parameters
goalNodethe goal state
thePathwill contain the path from goalNode to the start state

Definition at line 484 of file OptimisticSearch.h.

Referenced by OptimisticSearch< state, action, environment >::ExtractPathToStart().

◆ GetClosedItem()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::GetClosedItem ( const state &  s,
OptimisticOpenClosedData< state > &  result 
)

Definition at line 579 of file OptimisticSearch.h.

References kClosedList.

◆ GetClosedListGCost()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::GetClosedListGCost ( const state &  val,
double &  gCost 
) const

Get state from the closed list.

Author
Nathan Sturtevant
Date
10/09/07
Parameters
valThe state to lookup in the closed list @gCost The g-cost of the node in the closed list
Returns
success Whether we found the value or not the states

Definition at line 540 of file OptimisticSearch.h.

References kClosedList.

◆ GetFocalItem()

template<class state , class action , class environment >
const OptimisticOpenClosedData<state>& OptimisticSearch< state, action, environment >::GetFocalItem ( unsigned int  which)
inline

◆ GetFocalListGCost()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::GetFocalListGCost ( const state &  val,
double &  gCost 
) const

Definition at line 566 of file OptimisticSearch.h.

References kOpenList.

◆ GetItem()

template<class state , class action , class environment >
const OptimisticOpenClosedData<state>& OptimisticSearch< state, action, environment >::GetItem ( unsigned int  which)
inline

◆ GetMemoryUsage()

template<class state , class action , class environment >
int OptimisticSearch< state, action, environment >::GetMemoryUsage

Return the amount of memory used by OptimisticSearch.

Author
Nathan Sturtevant
Date
03/22/06
Returns
The combined number of elements in the closed list and open queue

Definition at line 524 of file OptimisticSearch.h.

◆ GetName()

template<class state , class action , class environment >
const char * OptimisticSearch< state, action, environment >::GetName
virtual

Return the name of the algorithm.

Author
Nathan Sturtevant
Date
03/22/06
Returns
The name of the algorithm

Implements GenericSearchAlgorithm< state, action, environment >.

Definition at line 161 of file OptimisticSearch.h.

◆ GetNodesExpanded()

template<class state , class action , class environment >
uint64_t OptimisticSearch< state, action, environment >::GetNodesExpanded ( ) const
inlinevirtual

◆ GetNodesTouched()

template<class state , class action , class environment >
uint64_t OptimisticSearch< state, action, environment >::GetNodesTouched ( ) const
inlinevirtual

◆ GetNumFocalItems()

template<class state , class action , class environment >
unsigned int OptimisticSearch< state, action, environment >::GetNumFocalItems ( )
inline

◆ GetNumItems()

template<class state , class action , class environment >
const int OptimisticSearch< state, action, environment >::GetNumItems ( )
inline

◆ GetNumOpenItems()

template<class state , class action , class environment >
unsigned int OptimisticSearch< state, action, environment >::GetNumOpenItems ( )
inline

◆ GetOpenItem()

template<class state , class action , class environment >
const OptimisticOpenClosedData<state>& OptimisticSearch< state, action, environment >::GetOpenItem ( unsigned int  which)
inline

◆ GetOpenListGCost()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::GetOpenListGCost ( const state &  val,
double &  gCost 
) const

Definition at line 553 of file OptimisticSearch.h.

References kOpenList.

◆ GetOptimalityBound()

template<class state , class action , class environment >
double OptimisticSearch< state, action, environment >::GetOptimalityBound ( )
inline

◆ GetParent()

template<class state , class action , class environment >
const state & OptimisticSearch< state, action, environment >::GetParent ( const state &  s)

Definition at line 495 of file OptimisticSearch.h.

◆ GetPath() [1/2]

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::GetPath ( environment *  _env,
const state &  from,
const state &  to,
std::vector< action > &  path 
)
virtual

◆ GetPath() [2/2]

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::GetPath ( environment *  _env,
const state &  from,
const state &  to,
std::vector< state > &  thePath 
)
virtual

Perform an A* search between two states.

Author
Nathan Sturtevant
Date
03/22/06
Parameters
_envThe search environment
fromThe start state
toThe goal state
thePathA 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.

◆ GetReopenNodes()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::GetReopenNodes ( )
inline

◆ GetStateLocation()

template<class state , class action , class environment >
dataLocation OptimisticSearch< state, action, environment >::GetStateLocation ( const state &  val)
inline

◆ GetUniqueNodesExpanded()

template<class state , class action , class environment >
uint64_t OptimisticSearch< state, action, environment >::GetUniqueNodesExpanded ( )
inline

◆ GetWeight()

template<class state , class action , class environment >
double OptimisticSearch< state, action, environment >::GetWeight ( )
inline

◆ HaveExpandedState()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::HaveExpandedState ( const state &  val)
inline

◆ InitializeSearch()

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::InitializeSearch ( environment *  _env,
const state &  from,
const state &  to,
std::vector< state > &  thePath 
)
virtual

Initialize the A* search.

Author
Nathan Sturtevant
Date
03/22/06
Parameters
_envThe search environment
fromThe start state
toThe goal state
Returns
TRUE if initialization was successful, FALSE otherwise

Reimplemented from GenericSearchAlgorithm< state, action, environment >.

Definition at line 224 of file OptimisticSearch.h.

◆ LogFinalStats()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::LogFinalStats ( StatCollection )
inlinevirtual

◆ OpenGLDraw()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::OpenGLDraw
virtual

Draw the open/closed list.

Author
Nathan Sturtevant
Date
03/12/09

Reimplemented from GenericSearchAlgorithm< state, action, environment >.

Definition at line 600 of file OptimisticSearch.h.

References fgreater(), kClosedList, and kOpenList.

◆ PrintStats()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::PrintStats

A function that prints the number of states in the closed list and open queue.

Author
Nathan Sturtevant
Date
03/22/06

Definition at line 510 of file OptimisticSearch.h.

◆ ResetNodeCount()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::ResetNodeCount ( )
inline

◆ SetHeuristic()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::SetHeuristic ( Heuristic< state > *  h)
inline

◆ SetOptimalityBound()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::SetOptimalityBound ( double  w)
inline

◆ SetReopenNodes()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::SetReopenNodes ( bool  re)
inline

◆ SetWeight()

template<class state , class action , class environment >
void OptimisticSearch< state, action, environment >::SetWeight ( double  w)
inline

Member Data Documentation

◆ bestSolution

template<class state , class action , class environment >
double OptimisticSearch< state, action, environment >::bestSolution
private

Definition at line 142 of file OptimisticSearch.h.

◆ bound

template<class state , class action , class environment >
double OptimisticSearch< state, action, environment >::bound
private

◆ env

template<class state , class action , class environment >
environment* OptimisticSearch< state, action, environment >::env
private

◆ f

template<class state , class action , class environment >
openList OptimisticSearch< state, action, environment >::f

◆ fhat

template<class state , class action , class environment >
openList OptimisticSearch< state, action, environment >::fhat

◆ goal

template<class state , class action , class environment >
state OptimisticSearch< state, action, environment >::goal

Definition at line 70 of file OptimisticSearch.h.

◆ neighbors

template<class state , class action , class environment >
std::vector<state> OptimisticSearch< state, action, environment >::neighbors
private

Definition at line 137 of file OptimisticSearch.h.

◆ nodesExpanded

template<class state , class action , class environment >
uint64_t OptimisticSearch< state, action, environment >::nodesExpanded
private

◆ nodesTouched

template<class state , class action , class environment >
uint64_t OptimisticSearch< state, action, environment >::nodesTouched
private

◆ reopenNodes

template<class state , class action , class environment >
bool OptimisticSearch< state, action, environment >::reopenNodes
private

◆ start

template<class state , class action , class environment >
state OptimisticSearch< state, action, environment >::start

Definition at line 70 of file OptimisticSearch.h.

◆ theHeuristic

template<class state , class action , class environment >
Heuristic<state>* OptimisticSearch< state, action, environment >::theHeuristic
private

◆ uniqueNodesExpanded

template<class state , class action , class environment >
uint64_t OptimisticSearch< state, action, environment >::uniqueNodesExpanded
private

◆ weight

template<class state , class action , class environment >
double OptimisticSearch< state, action, environment >::weight
private

The documentation for this class was generated from the following file: