Assignment Search Framework
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
heuristic.h
Go to the documentation of this file.
1 /*
2  * heuristic.h
3  *
4  * LICENSE HERE
5  *
6  * Created on: 2016-08-23
7  * Author: Rick Valenzano
8  */
9 
10 #ifndef HEURISTIC_H_
11 #define HEURISTIC_H_
12 
22 template<class state_t>
23 class Heuristic
24 {
25 public:
29  Heuristic();
30 
34  virtual ~Heuristic();
35 
42  virtual void prepareToCompute();
43 
53  double getHValue(const state_t &state);
54 
62  double getLastHValue() const;
63 
69  bool isHValueStored() const;
70 
71 protected:
82  virtual double computeHValue(const state_t &state) const = 0;
83 
84 private:
85  double last_h;
86 
87  bool h_stored;
88 };
89 
90 template<class state_t>
92  : last_h(0.0), h_stored(false)
93 {
94 }
95 
96 template<class state_t>
98 {
99 }
100 
101 template<class state_t>
102 double Heuristic<state_t>::getHValue(const state_t& state)
103 {
104  last_h = computeHValue(state);
105 
106  h_stored = true;
107  return last_h;
108 }
109 
110 template<class state_t>
112 {
113  return last_h;
114 }
115 
116 template<class state_t>
118 {
119  last_h = -1.0;
120  h_stored = false;
121 }
122 
123 template<class state_t>
125 {
126  return h_stored;
127 }
128 
129 #endif /* HEURISTIC_H_ */
virtual ~Heuristic()
Definition: heuristic.h:97
double getLastHValue() const
Definition: heuristic.h:111
double getHValue(const state_t &state)
Definition: heuristic.h:102
virtual double computeHValue(const state_t &state) const =0
bool isHValueStored() const
Definition: heuristic.h:124
Heuristic()
Definition: heuristic.h:91
Definition: heuristic.h:23
virtual void prepareToCompute()
Definition: heuristic.h:117