23 #ifndef AlpsSolutionPool_h_
24 #define AlpsSolutionPool_h_
81 return std::make_pair(static_cast<AlpsKnowledge *>
88 throw CoinError(
"Can not call popKnowledge()",
89 "popKnowledge()",
"AlpsSolutionPool");
105 std::pair<const double, AlpsSolution*> ps(priority, dynamic_cast<AlpsSolution*>(sol));
111 std::multimap< double, AlpsSolution* >::iterator si =
138 if (static_cast<int>(
solutions_.size()) > maxsols) {
139 std::multimap<double, AlpsSolution*>::
141 for (
int i = 0; i < maxsols; ++i)
156 return std::make_pair(static_cast<AlpsKnowledge *>
173 (std::vector<std::pair<AlpsKnowledge*, double> >& sols)
const {
174 sols.reserve(sols.size() +
solutions_.size());
175 std::multimap<double, AlpsSolution*>::const_iterator si;
177 sols.push_back(std::make_pair(static_cast<AlpsKnowledge *>
178 (si->second), si->first));
185 std::multimap< double, AlpsSolution* >::iterator 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); \
void setMaxNumKnowledges(int maxsols)
reset the maximum number of solutions
int getNumKnowledges() const
query the current number of solutions
AlpsSolutionPool & operator=(const AlpsSolutionPool &)
void addKnowledge(AlpsKnowledge *sol, double priority)
Append the solution to the end of the vector of solutions.
virtual ~AlpsSolutionPool()
std::pair< AlpsKnowledge *, double > getBestKnowledge() const
Return the best solution.
std::multimap< double, AlpsSolution * > solutions_
int getMaxNumKnowledges() const
query the maximum number of solutions
In the solution pool we assume that the lower the priority value the more desirable the solution is...
void popKnowledge()
Remove a solution from the pool.
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Error Class thrown by an exception.
std::pair< AlpsKnowledge *, double > getKnowledge() const
Get a solution from solution pool, doesn't remove it from the pool.
bool hasKnowledge() const
return true if there are any solution stored in the solution pool
void clean()
Delete all the solutions in pool.
void getAllKnowledges(std::vector< std::pair< AlpsKnowledge *, double > > &sols) const
Return all the solutions of the solution pool in the provided argument vector.
AlpsSolutionPool(int maxsols=1)
AlpsSolutionPool(const AlpsSolutionPool &)