Assignment Search Framework
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
BestFirstSearch< state_t, action_t > Class Template Referenceabstract
Inheritance diagram for BestFirstSearch< state_t, action_t >:

Public Member Functions

 BestFirstSearch ()
 
virtual ~BestFirstSearch ()
 
void setHashFunction (const StateHashFunction< state_t > *hash)
 
void setHeuristic (Heuristic< state_t > *heur)
 
uint64_t getUniqueGoalTests () const
 
- Public Member Functions inherited from SearchEngine< state_t, action_t >
 SearchEngine ()
 
virtual ~SearchEngine ()
 
void setGoalTest (const GoalTestFunction< state_t > *g)
 
void setTransitionSystem (const TransitionSystem< state_t, action_t > *o)
 
SearchStatus getStatus () const
 
SearchTermType getPlan (const state_t &init_state, std::vector< action_t > &sol_plan)
 
bool foundSolution () const
 
std::vector< action_t > getLastPlan ()
 
double getLastPlanCost ()
 
void setStorageLimit (uint64_t limit)
 
bool hitStorageLimit ()
 
void setHComputeLimit (uint64_t limit)
 
bool hitHCompLimit ()
 
void setSuccCallLimit (uint64_t limit)
 
bool hitSuccFuncLimit ()
 
void setGoalTestLimit (uint64_t limit)
 
bool hitGoalTestLimit ()
 
uint64_t getStorageCount () const
 
uint64_t getHCompCount () const
 
uint64_t getSuccFuncCount () const
 
uint64_t getStateGenCount () const
 
uint64_t getActionGenCount () const
 
uint64_t getGoalTestCount () const
 

Protected Member Functions

virtual SearchTermType searchForPlan (const state_t &init_state)
 
virtual void resetStatistics ()
 
virtual bool isConfigured () const
 
virtual void resetEngine ()
 
virtual double nodeEval (const state_t &state, double g_cost, double h_cost)=0
 
virtual BfsExpansionResult nodeExpansion ()
 
void extractSolutionPath (NodeID path_end_id)
 
- Protected Member Functions inherited from SearchEngine< state_t, action_t >
virtual void incrementGoalTestCount ()
 
virtual void incrementHCompCount ()
 
virtual void incrementSuccFuccCalls ()
 
virtual void incrementStateGenCount ()
 
virtual void increaseActionGenCount (double new_gens)
 

Protected Attributes

Heuristic< state_t > * heur_func
 The heuristic function. More...
 
const StateHashFunction
< state_t > * 
hash_func
 The hash function. More...
 
OpenClosedList< state_t, action_t > open_closed_list
 The open and closed list. More...
 
uint64_t unique_goal_tests
 The number of unique goal tests performed. More...
 
std::vector< action_t > app_actions
 A vector to store the set of applicable actions. More...
 
- Protected Attributes inherited from SearchEngine< state_t, action_t >
const GoalTestFunction< state_t > * goal_test
 The goal test function. More...
 
const TransitionSystem
< state_t, action_t > * 
op_system
 The transition system. More...
 
SearchStatus alg_status
 The current search status. More...
 
bool have_incumbent
 If an incumbent solution is stored or not. More...
 
std::vector< action_t > incumbent_plan
 The last solution found. More...
 
double incumbent_cost
 The cost of the last solution. More...
 
uint64_t storage_limit
 The limit on how many states are stored. 0 for no limit. More...
 
uint64_t storage_count
 The number of states currently being stored. More...
 
uint64_t h_comp_limit
 The limit on how many heuristic computations can be performed. 0 for no limit. More...
 
uint64_t h_comp_count
 The number of heuristic computations during the current search. More...
 
uint64_t succ_func_limit
 The limit on how many successor function calls can be performed. 0 for no limit. More...
 
uint64_t succ_func_count
 The number of heuristic computations made during the current search. More...
 
uint64_t goal_test_limit
 The limit on the number of goal tests. 0 for no limit. More...
 
uint64_t goal_test_count
 The number of goal tests performed during the current search. More...
 
uint64_t state_gen_count
 The number of state generations during the current search. More...
 
uint64_t action_gen_count
 The number of state generations during the current search. More...
 

Detailed Description

template<class state_t, class action_t>
class BestFirstSearch< state_t, action_t >

An abstract template for best-first search.

Todo:

Add branch and bound option

Add pathmax

Make it a bit more general

Are these the return types that we want for BfsExpansionResult

Constructor & Destructor Documentation

template<class state_t , class action_t >
BestFirstSearch< state_t, action_t >::BestFirstSearch ( )
template<class state_t , class action_t >
BestFirstSearch< state_t, action_t >::~BestFirstSearch ( )
virtual

Member Function Documentation

template<class state_t , class action_t >
void BestFirstSearch< state_t, action_t >::extractSolutionPath ( NodeID  path_end_id)
protected

Extracts the path that ends at the node for the given id and stores it as the incumbent plan.

Parameters
path_end_idThe node at the end of the path.
template<class state_t , class action_t >
uint64_t BestFirstSearch< state_t, action_t >::getUniqueGoalTests ( ) const
inline

Returns the number of unique goal tests.

Returns
The number of unique goal tests.
template<class state_t , class action_t >
bool BestFirstSearch< state_t, action_t >::isConfigured ( ) const
protectedvirtual

Checks if the engine has all elements necessary for search.

Returns
If the engine has all elements it needs for search.

Reimplemented from SearchEngine< state_t, action_t >.

template<class state_t , class action_t >
virtual double BestFirstSearch< state_t, action_t >::nodeEval ( const state_t &  state,
double  g_cost,
double  h_cost 
)
protectedpure virtual

Calculates the evaluation of the given node.

Parameters
stateThe state to evaluate.
g_costThe g-cost of the current node.
h_costThe h-cost of the current node.
Returns
The evaluation of the current node.

Implemented in AStar< state_t, action_t >.

template<class state_t , class action_t >
BfsExpansionResult BestFirstSearch< state_t, action_t >::nodeExpansion ( )
protectedvirtual

Expands a single node and returns the result of the expansion (regarding if a solution as found or not).

Returns
The result of the node expansion.
template<class state_t , class action_t >
void BestFirstSearch< state_t, action_t >::resetEngine ( )
protectedvirtual

Resets the search engine by resetting the statistics and checking if the engine is ready for the next search.

Reimplemented from SearchEngine< state_t, action_t >.

template<class state_t , class action_t >
void BestFirstSearch< state_t, action_t >::resetStatistics ( )
protectedvirtual

Resets the statistics counters.

Reimplemented from SearchEngine< state_t, action_t >.

template<class state_t , class action_t >
SearchTermType BestFirstSearch< state_t, action_t >::searchForPlan ( const state_t &  init_state)
protectedvirtual

Searches for a plan. Assumes search engine is ready and properly configured.

Parameters
init_stateThe initial state to search from.
Returns
The reason for the termination of the algorithm.

Implements SearchEngine< state_t, action_t >.

template<class state_t , class action_t >
void BestFirstSearch< state_t, action_t >::setHashFunction ( const StateHashFunction< state_t > *  hash)
inline

Sets the hash function used by the search.

Parameters
hashA pointer to the hash function.
template<class state_t , class action_t >
void BestFirstSearch< state_t, action_t >::setHeuristic ( Heuristic< state_t > *  heur)
inline

Sets the heuristic function used by the search.

Parameters
heurA pointer to the heuristic function to use.

Member Data Documentation

template<class state_t , class action_t >
std::vector<action_t> BestFirstSearch< state_t, action_t >::app_actions
protected

A vector to store the set of applicable actions.

template<class state_t , class action_t >
const StateHashFunction<state_t>* BestFirstSearch< state_t, action_t >::hash_func
protected

The hash function.

template<class state_t , class action_t >
Heuristic<state_t>* BestFirstSearch< state_t, action_t >::heur_func
protected

The heuristic function.

template<class state_t , class action_t >
OpenClosedList<state_t, action_t> BestFirstSearch< state_t, action_t >::open_closed_list
protected

The open and closed list.

template<class state_t , class action_t >
uint64_t BestFirstSearch< state_t, action_t >::unique_goal_tests
protected

The number of unique goal tests performed.


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