Alps  2.0.2
AlpsNodePool.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 AlpsNodePool_h_
28 #define AlpsNodePool_h_
29 
30 #include <vector>
31 
32 #include "AlpsHelperFunctions.h"
33 #include "AlpsPriorityQueue.h"
34 #include "AlpsTreeNode.h"
35 #include "AlpsKnowledgePool.h"
36 
46 
48 
49 public:
51 
52  AlpsNodePool();
57  virtual ~AlpsNodePool();
59 
61 
62  virtual int getNumKnowledges() const;
65  virtual std::pair<AlpsKnowledge*, double> getKnowledge() const;
67  virtual bool hasKnowledge() const { return !(candidateList_.empty()); }
69  virtual int getMaxNumKnowledges() const { return INT_MAX; };
71  virtual std::pair<AlpsKnowledge*, double> getBestKnowledge() const;
73  virtual void getAllKnowledges (std::vector<std::pair<AlpsKnowledge*,
74  double> >& kls) const;
76 
78 
79  virtual void addKnowledge(AlpsKnowledge* node, double priority);
82  virtual void popKnowledge() { candidateList_.pop(); }
84 
86 
87  virtual void setMaxNumKnowledges(int num);
90  double getBestKnowledgeValue() const;
92  //Sahar: changed the following line
93  AlpsTreeNode * getBestNode() const;
97  void setNodeSelection(AlpsSearchStrategy<AlpsTreeNode*> & compare);
99  void deleteGuts();
101  void clear() { candidateList_.clear(); }
103 
104 private:
106  AlpsNodePool(AlpsNodePool const &);
109 };
110 
111 #endif
AlpsHelperFunctions.h
AlpsNodePool::searchStrategy_
AlpsSearchType searchStrategy_
Definition: AlpsNodePool.h:47
AlpsNodePool::getNumKnowledges
virtual int getNumKnowledges() const
Query the number of nodes in the node pool.
AlpsNodePool::popKnowledge
virtual void popKnowledge()
Remove the node with highest priority from the pool.
Definition: AlpsNodePool.h:82
AlpsNodePool::clear
void clear()
Remove all the nodes in the pool (does not free memory).
Definition: AlpsNodePool.h:101
AlpsSearchType
AlpsSearchType
Search Strategies.
Definition: Alps.h:211
AlpsPriorityQueue::pop
void pop()
Remove the top element from the heap.
Definition: AlpsPriorityQueue.h:72
AlpsTreeNode.h
AlpsNodePool::getKnowledge
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const
Get the node with highest priority. Doesn't remove it from the pool.
AlpsNodePool::operator=
AlpsNodePool & operator=(AlpsNodePool const &)
Disable copy assignment operator.
AlpsNodePool::getBestKnowledgeValue
double getBestKnowledgeValue() const
Get the "best value" of the nodes in node pool.
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:52
AlpsKnowledgePool
This is an abstract base class, fixing an API for pool types of Alps, AlpsNodePool,...
Definition: AlpsKnowledgePool.h:47
AlpsNodePool::candidateList_
AlpsPriorityQueue< AlpsTreeNode * > candidateList_
Candidate list.
Definition: AlpsNodePool.h:45
AlpsNodePool::AlpsNodePool
AlpsNodePool()
Default constructor.
AlpsNodePool::~AlpsNodePool
virtual ~AlpsNodePool()
Destructor.
AlpsNodePool::getBestKnowledge
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge() const
Query the best knowledge in the pool.
AlpsNodePool::setMaxNumKnowledges
virtual void setMaxNumKnowledges(int num)
Set the quantity limit of knowledges that can be stored in the pool.
AlpsNodePool::getCandidateList
const AlpsPriorityQueue< AlpsTreeNode * > & getCandidateList() const
Get a constant reference to the priority queue that stores nodes.
AlpsKnowledge
The abstract base class of Alps knowledges generated during the search.
Definition: AlpsKnowledge.h:63
AlpsPriorityQueue::clear
void clear()
Remove all elements from the vector.
Definition: AlpsPriorityQueue.h:88
AlpsNodePool::setNodeSelection
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > &compare)
Set strategy and resort heap.
AlpsPriorityQueue.h
AlpsKnowledgePool.h
AlpsNodePool
AlpsNodePool is used to store the nodes to be processed.
Definition: AlpsNodePool.h:43
AlpsNodePool::deleteGuts
void deleteGuts()
Delete all the nodes in the pool and free memory.
AlpsNodePool::getMaxNumKnowledges
virtual int getMaxNumKnowledges() const
Query the quantity limit of knowledges.
Definition: AlpsNodePool.h:69
AlpsNodePool::hasKnowledge
virtual bool hasKnowledge() const
Check whether there are still nodes in the node pool.
Definition: AlpsNodePool.h:67
AlpsNodePool::addKnowledge
virtual void addKnowledge(AlpsKnowledge *node, double priority)
Add a node to node pool.
AlpsNodePool::getBestNode
AlpsTreeNode * getBestNode() const
Get the "best" nodes in node pool.
AlpsPriorityQueue::empty
bool empty() const
Return true for an empty vector.
Definition: AlpsPriorityQueue.h:78
AlpsNodePool::getAllKnowledges
virtual void getAllKnowledges(std::vector< std::pair< AlpsKnowledge *, double > > &kls) const
Get a reference to all the knowledges in the pool.*‍/.
AlpsPriorityQueue< AlpsTreeNode * >