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

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

#include <IOS.h>

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

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< dataLocationneighborLoc
 
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
 

Detailed Description

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

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

Definition at line 53 of file IOS.h.

Member Typedef Documentation

◆ openList

template<class state , class action , class environment >
typedef AStarOpenClosed<state, IOSCompare<state>, IOSOpenClosedData<state> > ImprovedOptimisticSearch< state, action, environment >::openList

Definition at line 64 of file IOS.h.

Constructor & Destructor Documentation

◆ ImprovedOptimisticSearch()

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

◆ ~ImprovedOptimisticSearch()

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

Definition at line 60 of file IOS.h.

Member Function Documentation

◆ AddAdditionalStartState() [1/2]

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

Author
Nathan Sturtevant
Date
01/06/08

Definition at line 265 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode().

◆ AddAdditionalStartState() [2/2]

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

Author
Nathan Sturtevant
Date
09/25/10

Definition at line 277 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode().

◆ CheckNextNode()

template<class state , class action , class environment >
state ImprovedOptimisticSearch< 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 526 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::Lookup(), and AStarOpenClosed< state, CmpKey, dataStructure >::Peek().

◆ DoGreedyStep()

template<class state , class action , class environment >
void ImprovedOptimisticSearch< state, action, environment >::DoGreedyStep ( std::vector< state > &  thePath)
private

◆ DoOptimalStep()

template<class state , class action , class environment >
void ImprovedOptimisticSearch< state, action, environment >::DoOptimalStep ( std::vector< state > &  thePath)
private

◆ DoSingleSearchStep()

template<class state , class action , class environment >
bool ImprovedOptimisticSearch< 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 294 of file IOS.h.

References flesseq(), and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().

◆ Draw()

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

◆ ExtractPathToStart()

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

◆ ExtractPathToStartFromID()

template<class state , class action , class environment >
void ImprovedOptimisticSearch< 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
nodethe state from which to extract the goal
thePathwill 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().

◆ GetClosedItem()

template<class state , class action , class environment >
bool ImprovedOptimisticSearch< state, action, environment >::GetClosedItem ( const state &  s,
IOSOpenClosedData< state > &   
)

◆ GetClosedListGCost()

template<class state , class action , class environment >
bool ImprovedOptimisticSearch< 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 597 of file IOS.h.

References kClosedList, AStarOpenClosed< state, CmpKey, dataStructure >::Lookat(), and AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().

◆ GetFocalListGCost()

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

◆ GetItem()

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

◆ GetMemoryUsage()

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

Return the amount of memory used by ImprovedOptimisticSearch.

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

Definition at line 581 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::size().

◆ GetName()

template<class state , class action , class environment >
const char * ImprovedOptimisticSearch< 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 170 of file IOS.h.

◆ GetNodesExpanded()

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

◆ GetNodesTouched()

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

◆ GetNumItems()

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

◆ GetNumOpenItems()

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

◆ GetOpenItem()

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

◆ GetOpenListGCost()

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

◆ GetOptimalityBound()

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

◆ GetParent()

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

Definition at line 552 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::Lookup().

◆ GetPath() [1/2]

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

Implements GenericSearchAlgorithm< state, action, environment >.

Definition at line 201 of file IOS.h.

◆ GetPath() [2/2]

template<class state , class action , class environment >
void ImprovedOptimisticSearch< 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 189 of file IOS.h.

◆ GetReopenNodes()

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

◆ GetStateLocation()

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

◆ GetUniqueNodesExpanded()

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

◆ GetWeight()

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

◆ HaveExpandedState()

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

◆ InitializeSearch()

template<class state , class action , class environment >
bool ImprovedOptimisticSearch< 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 230 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::AddOpenNode(), and AStarOpenClosed< state, CmpKey, dataStructure >::Reset().

◆ LogFinalStats()

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

Implements GenericSearchAlgorithm< state, action, environment >.

Definition at line 116 of file IOS.h.

◆ OpenGLDraw()

template<class state , class action , class environment >
void ImprovedOptimisticSearch< 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 629 of file IOS.h.

◆ Phi()

template<class state , class action , class environment >
double ImprovedOptimisticSearch< state, action, environment >::Phi ( double  h,
double  g 
)
inline

◆ PrintStats()

template<class state , class action , class environment >
void ImprovedOptimisticSearch< 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 567 of file IOS.h.

References AStarOpenClosed< state, CmpKey, dataStructure >::ClosedSize(), and AStarOpenClosed< state, CmpKey, dataStructure >::OpenSize().

◆ ResetNodeCount()

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

◆ SetHeuristic()

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

◆ SetOptimalityBound()

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

◆ SetPhi()

template<class state , class action , class environment >
void ImprovedOptimisticSearch< state, action, environment >::SetPhi ( std::function< double(double, double)>  p)
inline

◆ SetReopenNodes()

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

◆ SetWeight()

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

Member Data Documentation

◆ bestSolution

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

Definition at line 149 of file IOS.h.

◆ bound

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

◆ doneGreedy

template<class state , class action , class environment >
bool ImprovedOptimisticSearch< state, action, environment >::doneGreedy
private

Definition at line 155 of file IOS.h.

◆ edgeCosts

template<class state , class action , class environment >
std::vector<double> ImprovedOptimisticSearch< state, action, environment >::edgeCosts
private

Definition at line 143 of file IOS.h.

◆ env

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

◆ goal

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

Definition at line 68 of file IOS.h.

◆ greedyPhi

template<class state , class action , class environment >
std::function<double(double, double)> ImprovedOptimisticSearch< state, action, environment >::greedyPhi
private

◆ internalPath

template<class state , class action , class environment >
std::vector<state> ImprovedOptimisticSearch< state, action, environment >::internalPath
private

Definition at line 140 of file IOS.h.

◆ maxPriority

template<class state , class action , class environment >
double ImprovedOptimisticSearch< state, action, environment >::maxPriority
private

Definition at line 156 of file IOS.h.

◆ neighborID

template<class state , class action , class environment >
std::vector<uint64_t> ImprovedOptimisticSearch< state, action, environment >::neighborID
private

Definition at line 142 of file IOS.h.

◆ neighborLoc

template<class state , class action , class environment >
std::vector<dataLocation> ImprovedOptimisticSearch< state, action, environment >::neighborLoc
private

Definition at line 144 of file IOS.h.

◆ neighbors

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

Definition at line 141 of file IOS.h.

◆ nodesExpanded

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

◆ nodesTouched

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

◆ openClosedList

template<class state , class action , class environment >
AStarOpenClosed<state, IOSCompare<state>, IOSOpenClosedData<state> > ImprovedOptimisticSearch< state, action, environment >::openClosedList

◆ phi

template<class state , class action , class environment >
std::function<double(double, double)> ImprovedOptimisticSearch< state, action, environment >::phi
private

◆ reopenNodes

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

◆ solutionReduction

template<class state , class action , class environment >
double ImprovedOptimisticSearch< state, action, environment >::solutionReduction
private

Definition at line 149 of file IOS.h.

◆ start

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

Definition at line 68 of file IOS.h.

◆ theHeuristic

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

◆ uniqueNodesExpanded

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

◆ weight

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

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