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

Public Member Functions

 Heuristic ()
 
virtual ~Heuristic ()
 
virtual void prepareToCompute ()
 
double getHValue (const state_t &state)
 
double getLastHValue () const
 
bool isHValueStored () const
 

Protected Member Functions

virtual double computeHValue (const state_t &state) const =0
 

Detailed Description

template<class state_t>
class Heuristic< state_t >

Abstract class for defining a heuristic function.

Descendents should overwrite calculateH. Negative heuristic values should be interpreted as indicating that the problem is unsolvable from the current state. The intended way to calculate a heuristic will then be call prepareToCompute, and then computeHeuristic.

Constructor & Destructor Documentation

template<class state_t >
Heuristic< state_t >::Heuristic ( )

Constructor for the abstract heuristic class. Abstract constructor only initializes the last heuristic value to be 0.0.

template<class state_t >
Heuristic< state_t >::~Heuristic ( )
virtual

Destructor for the abstract heuristic class. Abstract destructor is empty.

Member Function Documentation

template<class state_t>
virtual double Heuristic< state_t >::computeHValue ( const state_t &  state) const
protectedpure virtual

Calculates the heuristic value of the given state. Does not store the heuristic value.

If the heuristic value is negative, the heuristic function is indicating unsolvability.

This is the main function to be overloaded.

Parameters
stateThe state whose heuristic value is to be calculated.
Returns
The heuristic value of the given state.

Implemented in MapOctileDistance, NonGoalHeuristic< state_t >, MapManhattanDistance, and TileManhattanDistance.

template<class state_t>
double Heuristic< state_t >::getHValue ( const state_t &  state)

Gets and returns the heuristic value of the given state.

To get the heuristic value, calls computeHValue. If the heuristic value is negative, the heuristic function is indicating unsolvability.

Parameters
stateThe state whose heuristic value is to be calculated.
Returns
The heuristic value of the given state.
template<class state_t >
double Heuristic< state_t >::getLastHValue ( ) const
inline

Returns the last heuristic value computed.

If the heuristic value is negative, the heuristic function is indicating unsolvability.

Returns
The last heuristic value computed.
template<class state_t >
bool Heuristic< state_t >::isHValueStored ( ) const
inline

Returns if a heuristic value is currently stored for this heuristic function.

Returns
If a valid heuristic value is currently stored.
template<class state_t >
void Heuristic< state_t >::prepareToCompute ( )
virtual

Prepares the heuristic function for computing the next heuristic value.

This function is intended to allow for having multiple heuristics computed simultaneously using the same process.


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