23 #ifndef AlpsSolutionPool_h_
24 #define AlpsSolutionPool_h_
42 std::multimap< double, AlpsSolution* > solutions_;
59 if (! solutions_.empty()) {
67 return static_cast<int> (solutions_.size());
72 {
return solutions_.empty() ? false :
true; }
82 (solutions_.begin()->second),
83 solutions_.begin()->first);
88 throw CoinError(
"Can not call popKnowledge()",
89 "popKnowledge()",
"AlpsSolutionPool");
105 std::pair<const double, AlpsSolution*> ps(priority,
dynamic_cast<AlpsSolution*
>(sol));
106 solutions_.insert(ps);
109 if ((maxNumSolutions_ > 0) &&
110 (
static_cast<int>(solutions_.size()) > maxNumSolutions_)) {
111 std::multimap< double, AlpsSolution* >::iterator si =
115 solutions_.erase(si);
138 if (
static_cast<int>(solutions_.size()) > maxsols) {
139 std::multimap<double, AlpsSolution*>::
140 iterator si = solutions_.begin();
141 for (
int i = 0; i < maxsols; ++i)
143 solutions_.erase(si, solutions_.end());
146 maxNumSolutions_ = maxsols;
157 (solutions_.begin()->second),
158 solutions_.begin()->first);
173 (std::vector<std::pair<AlpsKnowledge*, double> >& sols)
const {
174 sols.reserve(sols.size() + solutions_.size());
175 std::multimap<double, AlpsSolution*>::const_iterator si;
176 for (si = solutions_.begin(); si != solutions_.end(); ++si) {
178 (si->second), si->first));
184 while (!solutions_.empty()) {
185 std::multimap< double, AlpsSolution* >::iterator si =
189 solutions_.erase(si);
200 #define AlpsSolutionInterface(ref) \
201 int getNumSolutions() const { \
202 (ref).getNumSolutions(); \
204 int getMaxNumSolutions() const { \
205 return (ref).getMaxNumSolutions(); \
207 void setMaxNumSolutions(int num) { \
208 (ref).setMaxNumSolutions(num); \
210 bool hasSolution() const { \
211 return (ref).hasSolution(); \
213 std::pair<const AlpsSolution*, double> getBestSolution() const { \
214 return (ref).getBestSolution(); \
216 void getAllSolutions \
217 (std::vector<std::pair<const AlpsSolution*, double> >& sols) { \
218 return (ref).getAllSolutions(sols); \
220 void addSolution(const AlpsSolution* sol, double priority) { \
221 (ref).addSolution(sol, priority); \