118 : so(so0), tostop(NULL) {}
126 template<
class Collect>
130 template<
class Collect>
133 return slave->statistics();
135 template<
class Collect>
138 return slave->stopped();
140 template<
class Collect>
145 template<
class Collect>
153 template<
class Collect>
161 for (
unsigned int i=0U; i<
n_slaves; i++) {
168 template<
class Collect>
184 while (
slaves[i] != slave)
199 template<
class Collect>
205 }
while (!
master->report(
this,s));
208 template<
class Collect>
224 for (
unsigned int i=0U; i<
n_active; i++)
245 for (
unsigned int i=0U; i<
n_active; i++)
254 template<
class Collect>
260 template<
class Collect>
265 for (
unsigned int i=0U; i<
n_slaves; i++)
270 template<
class Collect>
275 throw NoBest(
"PBS::constrain");
278 for (
unsigned int i=0U; i<
n_active; i++)
283 template<
class Collect>
Exception: Best solution search is not supported
Space * get(Slave< CollectAll > *&r)
Return solution reported by r.
bool empty(void) const
Check whether there is any solution left.
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
bool add(Space *s, Slave< CollectAll > *r)
Add a solution a reported by r and always return true.
CollectAll(void)
Initialize.
~CollectAll(void)
Destructor.
bool constrain(const Space &b)
Dummy function.
CollectBest(void)
Initialize.
bool constrain(const Space &b)
Check whether b better and update accordingly.
bool empty(void) const
Check whether there is any solution left.
bool add(Space *s, Slave< CollectBest > *r)
Add a solution s by r and return whether is was better.
Space * get(Slave< CollectBest > *&r)
Return solution reported by r (only if a better one was found)
Slave< CollectBest > * reporter
Who has reported the best solution (NULL if solution has already been reported)
~CollectBest(void)
Destructor.
Space * b
Currently best solution.
Parallel depth-first search engine
Engine(const Options &o)
Initialize with options o.
Parallel portfolio engine implementation.
virtual bool stopped(void) const
Check whether engine has been stopped.
bool slave_stop
Whether a slave has been stopped.
virtual ~PBS(void)
Destructor.
Support::Event idle
Signal that number of busy slaves becomes zero.
bool report(Slave< Collect > *slave, Space *s)
Process report from slave, return false if solution was ignored.
Gecode::Search::Par::CollectBest solutions
friend class Slave< Collect >
Slave< Collect > ** slaves
Slave engines.
unsigned int n_active
Number of active slave engines.
volatile bool tostop
Shared stop flag.
unsigned int n_slaves
Number of slave engines.
Statistics stat
Master statistics.
PBS(Engine **s, Stop **so, unsigned int n, const Statistics &stat)
Initialize.
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped)
virtual Statistics statistics(void) const
Return statistics.
unsigned int n_busy
Number of busy slaves.
Stop object used for controling slaves in a portfolio.
void share(volatile bool *ts)
Set pointer to shared tostop variable.
PortfolioStop(Stop *so)
Initialize.
Runnable slave of a portfolio master.
Engine * slave
The slave engine.
PBS< Collect > * master
The master engine.
virtual void run(void)
Perform one run.
bool stopped(void) const
Check whether slave has been stopped.
virtual ~Slave(void)
Delete slave.
Statistics statistics(void) const
Return statistics of slave.
Slave(PBS< Collect > *m, Engine *s, Stop *so)
Initialize with master m, slave s, and its stop object so.
void constrain(const Space &b)
Constrain with better solution b.
Base-class for Stop-object.
Stop(void)
Default constructor.
Runnable(bool d=true)
Initialize, d defines whether object is deleted when terminated.
static void run(Runnable *r)
Construct a new thread and run r.
Heap heap
The single global heap.
virtual void constrain(const Space &best)
Constrain function for best solution search.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
@ SS_FAILED
Space is failed
Support algorithms and datastructures
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r