Alps  2.0.2
AlpsSearchStrategy.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 AlpsSearchStrategy_h_
28 #define AlpsSearchStrategy_h_
29 
30 #include "AlpsSearchStrategyBase.h"
31 #include "AlpsSubTree.h"
32 #include "AlpsTreeNode.h"
33 
34 //#############################################################################
35 //#############################################################################
36 
37 class AlpsTreeSelection : public AlpsSearchStrategy<AlpsSubTree*>
38 {
39 public:
42 
44  virtual ~AlpsTreeSelection() {}
45 
48  virtual bool compare(AlpsSubTree * x, AlpsSubTree * y) = 0;
49 };
50 
51 //#############################################################################
52 
53 class AlpsNodeSelection : public AlpsSearchStrategy<AlpsTreeNode*>
54 {
55 public:
58 
60  virtual ~AlpsNodeSelection() {}
61 
64  virtual bool compare(AlpsTreeNode * x, AlpsTreeNode * y) = 0;
65 
66  /* Select the next node to be processed. */
67  virtual AlpsTreeNode* selectNextNode(AlpsSubTree *subTree);
68 
69  /* Create new nodes from pregnant node and store them in node pool. */
70  virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node);
71 };
72 
73 //#############################################################################
74 // SUBTREE SELECTION RULES
75 //#############################################################################
76 
78 {
79 public:
82 
85 
88  virtual bool compare(AlpsSubTree * x, AlpsSubTree * y);
89 };
90 
91 //#############################################################################
92 
94 {
95 public:
98 
101 
104  virtual bool compare(AlpsSubTree * x, AlpsSubTree * y);
105 };
106 
107 //#############################################################################
108 
110 {
111 public:
114 
117 
120  virtual bool compare(AlpsSubTree * x, AlpsSubTree * y);
121 };
122 
123 //#############################################################################
124 
126 {
127 public:
130 
133 
136  virtual bool compare(AlpsSubTree * x, AlpsSubTree * y);
137 };
138 
139 //#############################################################################
140 // NODE SELECTION RULES
141 //#############################################################################
142 
144 {
145 public:
148 
151 
154  virtual bool compare(AlpsTreeNode * x, AlpsTreeNode * y) {
155  return (x->getQuality() > y->getQuality());
156  }
157 };
158 
159 //#############################################################################
160 
162 {
163 public:
166 
169 
172  virtual bool compare(AlpsTreeNode * x, AlpsTreeNode * y) {
173  return x->getDepth() > y->getDepth();
174  }
175 };
176 
177 //#############################################################################
178 
180 {
181  public:
184 
187 
190  virtual bool compare(AlpsTreeNode * x, AlpsTreeNode * y) {
191  return (x->getDepth() < y->getDepth());
192  }
193 };
194 
195 //#############################################################################
196 
198 {
199  public:
202 
205 
208  virtual bool compare (AlpsTreeNode * x, AlpsTreeNode * y) {
209  return (x->getSolEstimate() > y->getSolEstimate());
210  }
211 };
212 
213 //#############################################################################
214 
216 {
217 public:
220 
223 
226  virtual bool compare(AlpsTreeNode * x, AlpsTreeNode * y) {
227  // best first
228  return (x->getQuality() > y->getQuality());
229  }
230 
231  /* Select the next node to be processed. */
232  virtual AlpsTreeNode* selectNextNode(AlpsSubTree *subTree);
233 
234  /* Create new nodes from pregnant node and store them in node pool. */
235  virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node);
236 };
237 
238 //#############################################################################
239 #endif
AlpsSearchTypeBreadthFirst
@ AlpsSearchTypeBreadthFirst
Definition: Alps.h:213
AlpsSubTree.h
AlpsSearchTypeBestFirst
@ AlpsSearchTypeBestFirst
Definition: Alps.h:212
AlpsTreeSelection::AlpsTreeSelection
AlpsTreeSelection()
Default Constructor.
Definition: AlpsSearchStrategy.h:41
AlpsNodeSelectionDepth
Definition: AlpsSearchStrategy.h:179
AlpsNodeSelectionEstimate::~AlpsNodeSelectionEstimate
virtual ~AlpsNodeSelectionEstimate()
Default Destructor.
Definition: AlpsSearchStrategy.h:204
AlpsNodeSelectionBest::compare
virtual bool compare(AlpsTreeNode *x, AlpsTreeNode *y)
This returns true if quality of node y is better (the less the better) than that of node x.
Definition: AlpsSearchStrategy.h:154
AlpsNodeSelection::~AlpsNodeSelection
virtual ~AlpsNodeSelection()
Default Destructor.
Definition: AlpsSearchStrategy.h:60
AlpsTreeSelectionEstimate::~AlpsTreeSelectionEstimate
virtual ~AlpsTreeSelectionEstimate()
Default Destructor.
Definition: AlpsSearchStrategy.h:132
AlpsNodeSelectionBest::~AlpsNodeSelectionBest
virtual ~AlpsNodeSelectionBest()
Default Destructor.
Definition: AlpsSearchStrategy.h:150
AlpsTreeSelectionBreadth::AlpsTreeSelectionBreadth
AlpsTreeSelectionBreadth()
Default Constructor.
Definition: AlpsSearchStrategy.h:97
AlpsTreeSelectionBest::compare
virtual bool compare(AlpsSubTree *x, AlpsSubTree *y)
This returns true if the quality of the subtree y is better (the less the better) than that the subtr...
AlpsTreeSelectionBest::AlpsTreeSelectionBest
AlpsTreeSelectionBest()
Default Constructor.
Definition: AlpsSearchStrategy.h:81
AlpsSearchStrategyBase.h
AlpsTreeSelectionEstimate::AlpsTreeSelectionEstimate
AlpsTreeSelectionEstimate()
Default Constructor.
Definition: AlpsSearchStrategy.h:129
AlpsTreeSelectionDepth
Definition: AlpsSearchStrategy.h:109
AlpsNodeSelectionHybrid::~AlpsNodeSelectionHybrid
virtual ~AlpsNodeSelectionHybrid()
Default Destructor.
Definition: AlpsSearchStrategy.h:222
AlpsNodeSelectionBreadth::~AlpsNodeSelectionBreadth
virtual ~AlpsNodeSelectionBreadth()
Default Destructor.
Definition: AlpsSearchStrategy.h:168
AlpsTreeSelectionBreadth
Definition: AlpsSearchStrategy.h:93
AlpsNodeSelectionBreadth::compare
virtual bool compare(AlpsTreeNode *x, AlpsTreeNode *y)
This returns true if the depth of node y is lesser than that of node x.
Definition: AlpsSearchStrategy.h:172
AlpsNodeSelectionHybrid::selectNextNode
virtual AlpsTreeNode * selectNextNode(AlpsSubTree *subTree)
AlpsNodeSelectionEstimate::AlpsNodeSelectionEstimate
AlpsNodeSelectionEstimate()
Default Constructor.
Definition: AlpsSearchStrategy.h:201
AlpsTreeSelectionBreadth::compare
virtual bool compare(AlpsSubTree *x, AlpsSubTree *y)
This returns true if the depth of the root node in subtree y is smaller than that of the root node in...
AlpsTreeSelection::compare
virtual bool compare(AlpsSubTree *x, AlpsSubTree *y)=0
This returns true if the quality of the subtree y is better (the less the better) than that the subtr...
AlpsNodeSelectionHybrid::createNewNodes
virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node)
AlpsNodeSelectionBest
Definition: AlpsSearchStrategy.h:143
AlpsTreeNode.h
AlpsSearchTypeBestEstimate
@ AlpsSearchTypeBestEstimate
Definition: Alps.h:215
AlpsTreeSelection
Definition: AlpsSearchStrategy.h:37
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:52
AlpsNodeSelectionEstimate::compare
virtual bool compare(AlpsTreeNode *x, AlpsTreeNode *y)
This returns true if the estimate quality of node y is better (the lesser the better) than that of no...
Definition: AlpsSearchStrategy.h:208
AlpsNodeSelectionBreadth
Definition: AlpsSearchStrategy.h:161
AlpsTreeNode::getQuality
double getQuality() const
Query/set the quality of the node.
Definition: AlpsTreeNode.h:207
AlpsNodeSelectionDepth::AlpsNodeSelectionDepth
AlpsNodeSelectionDepth()
Default Constructor.
Definition: AlpsSearchStrategy.h:183
AlpsTreeSelectionBreadth::~AlpsTreeSelectionBreadth
virtual ~AlpsTreeSelectionBreadth()
Default Destructor.
Definition: AlpsSearchStrategy.h:100
AlpsNodeSelection::createNewNodes
virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node)
AlpsTreeSelectionEstimate::compare
virtual bool compare(AlpsSubTree *x, AlpsSubTree *y)
This returns true if the estimated quality of the subtree y is better (the less the better) than that...
AlpsNodeSelectionHybrid::compare
virtual bool compare(AlpsTreeNode *x, AlpsTreeNode *y)
This returns true if the quality of node y is better (the lesser the better) than that of node x.
Definition: AlpsSearchStrategy.h:226
AlpsNodeSelection::selectNextNode
virtual AlpsTreeNode * selectNextNode(AlpsSubTree *subTree)
AlpsNodeSelection
Definition: AlpsSearchStrategy.h:53
AlpsTreeSelectionEstimate
Definition: AlpsSearchStrategy.h:125
AlpsNodeSelection::compare
virtual bool compare(AlpsTreeNode *x, AlpsTreeNode *y)=0
This returns true if the depth of node y is lesser than that of node x.
AlpsNodeSelectionBreadth::AlpsNodeSelectionBreadth
AlpsNodeSelectionBreadth()
Default Constructor.
Definition: AlpsSearchStrategy.h:165
AlpsTreeSelectionBest
Definition: AlpsSearchStrategy.h:77
AlpsTreeNode::getDepth
int getDepth() const
Query/set what depth the search tree node is at.
Definition: AlpsTreeNode.h:195
AlpsTreeSelectionDepth::AlpsTreeSelectionDepth
AlpsTreeSelectionDepth()
Default Constructor.
Definition: AlpsSearchStrategy.h:113
AlpsNodeSelectionHybrid
Definition: AlpsSearchStrategy.h:215
AlpsTreeNode::getSolEstimate
double getSolEstimate() const
Query/set the solution estimate of the node.
Definition: AlpsTreeNode.h:201
AlpsNodeSelectionDepth::~AlpsNodeSelectionDepth
virtual ~AlpsNodeSelectionDepth()
Default Destructor.
Definition: AlpsSearchStrategy.h:186
AlpsTreeSelectionDepth::compare
virtual bool compare(AlpsSubTree *x, AlpsSubTree *y)
This returns true if the depth of the root node in subtree y is greater than that of the root node in...
AlpsNodeSelectionHybrid::AlpsNodeSelectionHybrid
AlpsNodeSelectionHybrid()
Default Constructor.
Definition: AlpsSearchStrategy.h:219
AlpsNodeSelection::AlpsNodeSelection
AlpsNodeSelection()
Default Constructor.
Definition: AlpsSearchStrategy.h:57
AlpsTreeSelectionDepth::~AlpsTreeSelectionDepth
virtual ~AlpsTreeSelectionDepth()
Default Destructor.
Definition: AlpsSearchStrategy.h:116
AlpsTreeSelectionBest::~AlpsTreeSelectionBest
virtual ~AlpsTreeSelectionBest()
Default Destructor.
Definition: AlpsSearchStrategy.h:84
AlpsSubTree
This class contains the data pertaining to a particular subtree in the search tree.
Definition: AlpsSubTree.h:51
AlpsNodeSelectionDepth::compare
virtual bool compare(AlpsTreeNode *x, AlpsTreeNode *y)
This returns true if the depth of node y is greater than that of node x.
Definition: AlpsSearchStrategy.h:190
AlpsSearchTypeDepthFirst
@ AlpsSearchTypeDepthFirst
Definition: Alps.h:214
AlpsNodeSelectionEstimate
Definition: AlpsSearchStrategy.h:197
AlpsNodeSelectionBest::AlpsNodeSelectionBest
AlpsNodeSelectionBest()
Default Constructor.
Definition: AlpsSearchStrategy.h:147
AlpsSearchTypeHybrid
@ AlpsSearchTypeHybrid
Definition: Alps.h:216
AlpsTreeSelection::~AlpsTreeSelection
virtual ~AlpsTreeSelection()
Default Destructor.
Definition: AlpsSearchStrategy.h:44