Alps  1.5.7
AlpsKnowledgePool.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-2019, Lehigh University, Yan Xu, and Ted Ralphs. *
21  *===========================================================================*/
22 
23 #ifndef AlpsKnowledgePool_h
24 #define AlpsKnowledgePool_h
25 
26 #include <climits>
27 #include <iostream>
28 #include <vector>
29 
30 #include "CoinError.hpp"
31 #include "AlpsKnowledge.h"
32 
33 //#############################################################################
34 //#############################################################################
35 
37  private:
39  AlpsKnowledgePool& operator=(const AlpsKnowledgePool&);
40 
41  public:
42  AlpsKnowledgePool() {} // Need: otherwise
43  virtual ~AlpsKnowledgePool() {} // won't compile.
44 
46  virtual void addKnowledge(AlpsKnowledge * nk, double priority) = 0;
47 
49  virtual int getNumKnowledges() const = 0;
50 
52  virtual std::pair<AlpsKnowledge*, double> getKnowledge() const = 0;
53 
55  virtual void popKnowledge() {
56  throw CoinError("Can not call popKnowledge()",
57  "popKnowledge()", "AlpsKnowledgePool");
58  }
59 
61  virtual bool hasKnowledge() const{
62  throw CoinError("Can not call hasKnowledge()",
63  "hasKnowledge()", "AlpsKnowledgePool");
64  }
65 
67  virtual void setMaxNumKnowledges(int num) {
68  std::cout << "Can not call setMaxNumKnowledges without overriding"
69  << std::endl;
70  throw CoinError("Can not call setMaxNumKnowledges()",
71  "setMaxNumKnowledges()", "AlpsKnowledgePool");
72  }
73 
75  virtual int getMaxNumKnowledges() const {
76  // throw CoinError("Can not call getMaxNumKnowledges()",
77  // "getMaxNumKnowledges()", "AlpsKnowledgePool");
78  return INT_MAX;
79  }
80 
82  virtual std::pair<AlpsKnowledge*, double>
83  getBestKnowledge() const {
84  throw CoinError("Can not call getBestKnowledge()",
85  "getBestKnowledge()", "AlpsKnowledgePool");
86  }
87 
89  virtual void getAllKnowledges (std::vector<std::pair<AlpsKnowledge*,
90  double> >& kls) const {
91  std::cout << "Can not call getAllKnowledge() without overriding"
92  << std::endl;
93  throw CoinError("Can not call getAllKnowledge()",
94  "getAllKnowledge()", "AlpsKnowledgePool");
95  }
96 
97 };
98 
99 #endif
100 
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge() const
Query the best knowledge in the pool.
virtual void setMaxNumKnowledges(int num)
Set the quantity limit of knowledges that can be stored in the pool.
virtual void addKnowledge(AlpsKnowledge *nk, double priority)=0
Add a knowledge to pool.
virtual void getAllKnowledges(std::vector< std::pair< AlpsKnowledge *, double > > &kls) const
Get a reference to all the knowledges in the pool.
virtual void popKnowledge()
Remove the queried knowledge from the pool.
virtual bool hasKnowledge() const
Check whether the pool has knowledge.
virtual ~AlpsKnowledgePool()
virtual int getMaxNumKnowledges() const
Query the quantity limit of knowledges.
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const =0
Query a knowledge, but doesn't remove it from the pool.
virtual int getNumKnowledges() const =0
Query how many knowledges are in the pool.
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51