- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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-2013, 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
36 class AlpsKnowledgePool {
37 private:
38 AlpsKnowledgePool(const AlpsKnowledgePool&);
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
AlpsKnowledgePool::AlpsKnowledgePool
AlpsKnowledgePool()
Definition: AlpsKnowledgePool.h:42
AlpsKnowledgePool::getBestKnowledge
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge() const
Query the best knowledge in the pool.
Definition: AlpsKnowledgePool.h:83
AlpsKnowledgePool::~AlpsKnowledgePool
virtual ~AlpsKnowledgePool()
Definition: AlpsKnowledgePool.h:43
CoinError.hpp
AlpsKnowledgePool::getMaxNumKnowledges
virtual int getMaxNumKnowledges() const
Query the quantity limit of knowledges.
Definition: AlpsKnowledgePool.h:75
AlpsKnowledgePool::addKnowledge
virtual void addKnowledge(AlpsKnowledge *nk, double priority)=0
Add a knowledge to pool.
AlpsKnowledgePool::popKnowledge
virtual void popKnowledge()
Remove the queried knowledge from the pool.
Definition: AlpsKnowledgePool.h:55
AlpsKnowledgePool::getNumKnowledges
virtual int getNumKnowledges() const =0
Query how many knowledges are in the pool.
AlpsKnowledgePool::setMaxNumKnowledges
virtual void setMaxNumKnowledges(int num)
Set the quantity limit of knowledges that can be stored in the pool.
Definition: AlpsKnowledgePool.h:67
AlpsKnowledge.h
AlpsKnowledgePool
Definition: AlpsKnowledgePool.h:36
AlpsKnowledge
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
CoinError
Error Class thrown by an exception.
Definition: CoinError.hpp:42
AlpsKnowledgePool::getKnowledge
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const =0
Query a knowledge, but doesn&#39;t remove it from the pool.
AlpsKnowledgePool::getAllKnowledges
virtual void getAllKnowledges(std::vector< std::pair< AlpsKnowledge *, double > > &kls) const
Get a reference to all the knowledges in the pool.
Definition: AlpsKnowledgePool.h:89
AlpsKnowledgePool::hasKnowledge
virtual bool hasKnowledge() const
Check whether the pool has knowledge.
Definition: AlpsKnowledgePool.h:61
AlpsKnowledgePool::operator=
AlpsKnowledgePool & operator=(const AlpsKnowledgePool &)