Alps  2.0.2
AlpsSearchStrategyBase.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Abstract Library for Parallel Search (ALPS). *
3  * *
4  * ALPS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Aykut Bulut, Lehigh University *
11  * Ted Ralphs, Lehigh University *
12  * *
13  * Conceptual Design: *
14  * *
15  * Yan Xu, Lehigh University *
16  * Ted Ralphs, Lehigh University *
17  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
18  * Matthew Saltzman, Clemson University *
19  * *
20  * *
21  * Copyright (C) 2001-2023, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef AlpsSearchStrategyBase_h_
28 #define AlpsSearchStrategyBase_h_
29 
30 #include "Alps.h"
31 
32 class AlpsModel;
33 class AlpsSubTree;
34 class AlpsTreeNode;
35 
36 //#############################################################################
37 
48 template<class T>
49 class AlpsSearchStrategy
50 {
51 protected:
53  double weight_;
54 
56  AlpsSearchType type_;
57 
58 public:
60  AlpsSearchStrategy() : weight_(-1.0), type_(AlpsSearchTypeBestFirst){}
61 
63  virtual ~AlpsSearchStrategy() {}
64 
70  virtual bool compare(T x, T y) = 0;
71 
72  bool operator() (T x, T y) {
73  return compare(x, y);
74  }
75 
80  inline double getWeight() const { return weight_; }
81  inline void setWeight(double nw) { weight_ = nw; }
83 
89  virtual AlpsTreeNode* selectNextNode(AlpsSubTree *subTree)
90  { AlpsTreeNode *temp = 0; return temp; }
91 
93  virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node)
94  { }
96 
98  int getType(){ return type_; }
99 
101  void setType(int t) { type_ = t; }
102 };
103 
104 //#############################################################################
105 
107 template<class T>
108 class AlpsCompare
109 {
110 public:
111  AlpsSearchStrategy<T>* strategy_;
112 
113 public:
115  AlpsCompare () : strategy_(0) {}
116  virtual ~AlpsCompare() {}
117 
118  void setComareBase(AlpsSearchStrategy<T>* c) {
119  strategy_ = c;
120  }
121 
122  bool operator() (T x, T y) {
123  return strategy_->compare(x, y);
124  }
125 };
126 
127 //#############################################################################
128 
129 #endif
AlpsSearchTypeBestFirst
@ AlpsSearchTypeBestFirst
Definition: Alps.h:212
AlpsModel
AlpsModel is a base class for user application problem data.
Definition: AlpsModel.h:132
AlpsSearchType
AlpsSearchType
Search Strategies.
Definition: Alps.h:211
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:52
Alps.h
AlpsSubTree
This class contains the data pertaining to a particular subtree in the search tree.
Definition: AlpsSubTree.h:51