00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef AlpsSearchStrategyBase_h_
00024 #define AlpsSearchStrategyBase_h_
00025
00026 #include "Alps.h"
00027
00028 class AlpsModel;
00029 class AlpsSubTree;
00030 class AlpsTreeNode;
00031
00032
00033
00044 template<class T>
00045 class AlpsSearchStrategy
00046 {
00047 protected:
00049 double weight_;
00050
00052 int type_;
00053
00054 public:
00056 AlpsSearchStrategy() : weight_(-1.0), type_(AlpsSearchTypeBestFirst){}
00057
00059 virtual ~AlpsSearchStrategy() {}
00060
00066 virtual bool compare(T x, T y) = 0;
00067
00068 bool operator() (T x, T y) {
00069 return compare(x, y);
00070 }
00071
00076 inline double getWeight() const { return weight_; }
00077 inline void setWeight(double nw) { weight_ = nw; }
00079
00085 virtual AlpsTreeNode* selectNextNode(AlpsSubTree *subTree)
00086 { AlpsTreeNode *temp = 0; return temp; }
00087
00089 virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node)
00090 { }
00092
00094 int getType(){ return type_; }
00095
00097 void setType(int t) { type_ = t; }
00098 };
00099
00100
00101
00103 template<class T>
00104 class AlpsCompare
00105 {
00106 public:
00107 AlpsSearchStrategy<T>* strategy_;
00108
00109 public:
00111 AlpsCompare () : strategy_(0) {}
00112 virtual ~AlpsCompare() {}
00113
00114 void setComareBase(AlpsSearchStrategy<T>* c) {
00115 strategy_ = c;
00116 }
00117
00118 bool operator() (T x, T y) {
00119 return strategy_->compare(x, y);
00120 }
00121 };
00122
00123
00124
00125 #endif