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  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * *
20  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21  *===========================================================================*/
22 
23 #ifndef AlpsSearchStrategyBase_h_
24 #define AlpsSearchStrategyBase_h_
25 
26 #include "Alps.h"
27 
28 class AlpsModel;
29 class AlpsSubTree;
30 class AlpsTreeNode;
31 
32 //#############################################################################
33 
44 template<class T>
45 class AlpsSearchStrategy
46 {
47 protected:
49  double weight_;
50 
52  int type_;
53 
54 public:
56  AlpsSearchStrategy() : weight_(-1.0), type_(AlpsSearchTypeBestFirst){}
57 
59  virtual ~AlpsSearchStrategy() {}
60 
66  virtual bool compare(T x, T y) = 0;
67 
68  bool operator() (T x, T y) {
69  return compare(x, y);
70  }
71 
76  inline double getWeight() const { return weight_; }
77  inline void setWeight(double nw) { weight_ = nw; }
79 
85  virtual AlpsTreeNode* selectNextNode(AlpsSubTree *subTree)
86  { AlpsTreeNode *temp = 0; return temp; }
87 
89  virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node)
90  { }
92 
94  int getType(){ return type_; }
95 
97  void setType(int t) { type_ = t; }
98 };
99 
100 //#############################################################################
101 
103 template<class T>
104 class AlpsCompare
105 {
106 public:
107  AlpsSearchStrategy<T>* strategy_;
108 
109 public:
111  AlpsCompare () : strategy_(0) {}
112  virtual ~AlpsCompare() {}
113 
114  void setComareBase(AlpsSearchStrategy<T>* c) {
115  strategy_ = c;
116  }
117 
118  bool operator() (T x, T y) {
119  return strategy_->compare(x, y);
120  }
121 };
122 
123 //#############################################################################
124 
125 #endif
This class contains the data pertaining to a particular subtree in the search tree.
Definition: AlpsSubTree.h:47
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50