36namespace Gecode {
namespace Search {
namespace Seq {
50 : slave(nullptr), stop(nullptr) {}
83 : stat(stat0), slice(opt.slice),
84 slaves(
heap.alloc<
Slave>(n)), n_slaves(n), cur(0),
89 for (
unsigned int i=0U; i<n; i++) {
99 unsigned int n_exhausted = 0;
100 while (n_slaves > 0) {
101 if (
Space* s = slaves[cur].next()) {
104 for (
unsigned int i=0U; i<cur; i++)
105 slaves[i].constrain(*s);
106 for (
unsigned int i=cur+1; i<n_slaves; i++)
107 slaves[i].constrain(*s);
111 if (slaves[cur].stopped()) {
113 cur++; n_exhausted++;
120 stat += slaves[cur].statistics();
121 slaves[cur].~Slave();
122 slaves[cur] = slaves[--n_slaves];
127 if (n_exhausted == n_slaves) {
148 for (
unsigned int i=0U; i<n_slaves; i++)
149 s += slaves[i].statistics();
157 throw NoBest(
"PBS::constrain");
158 for (
unsigned int i=0U; i<n_slaves; i++)
159 slaves[i].constrain(b);
164 for (
unsigned int i=0U; i<n_slaves; i++)
void rfree(void *p)
Free memory block starting at p.
Search engine implementation interface
virtual void constrain(const Space &b)
Constrain future solutions to be better than b (raises exception)
virtual Statistics statistics(void) const =0
Return statistics.
virtual Space * next(void)=0
Return next solution (NULL, if none exists or search has been stopped)
virtual bool stopped(void) const =0
Check whether engine has been stopped.
Exception: Best solution search is not supported
SharedStopInfo ssi
Shared slave information.
virtual ~PBS(void)
Destructor.
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped)
virtual bool stopped(void) const
Check whether engine has been stopped.
virtual Statistics statistics(void) const
Return statistics.
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
PBS(Engine **slaves, Stop **stops, unsigned int n, const Statistics &stat, const Search::Options &opt)
Initialize.
Stop object used for controling slaves in a portfolio.
void share(SharedStopInfo *ssi)
Intialize shared stop information.
PortfolioStop(Stop *so)
Initialize.
unsigned long int l
The current failure limit, incremented for each slice.
bool done
Whether search stopped because the slice is done.
Runnable slave of a portfolio master.
bool stopped(void) const
Check whether slave has been stopped.
Space * next(void)
Return next solution.
Engine * slave
The slave engine.
Slave(void)
Default constructor.
void constrain(const Space &b)
Constrain with better solution b.
void init(Engine *s, Stop *so)
Initialize with slave s and its stop object so.
Statistics statistics(void) const
Return statistics of slave.
~Slave(void)
Delete slave.
Base-class for Stop-object.
Heap heap
The single global heap.
Gecode toplevel namespace