34#ifndef __GECODE_SEARCH_PAR_PBS_HH__
35#define __GECODE_SEARCH_PAR_PBS_HH__
47 volatile bool* tostop;
52 void share(
volatile bool* ts);
62 template<
class Collect>
66 template<
class Collect>
85 virtual void run(
void);
97 static const bool best =
false;
105 bool empty(
void)
const;
129 bool empty(
void)
const;
137 template<
class Collect>
139 friend class Slave<Collect>;
179 virtual bool stopped(
void)
const;
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.
static const bool best
Whether it collects best solutions.
bool constrain(const Space &b)
Dummy function.
CollectBest(void)
Initialize.
static const bool best
Whether it collects best solutions.
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.
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.
Collect solutions
Collect solutions in this.
Support::Mutex m
Mutex for synchronization.
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.
void share(volatile bool *ts)
Set pointer to shared tostop variable.
virtual bool stop(const Statistics &s, const Options &o)
Return true if portfolio engine must be stopped.
void stop(bool s)
Signal whether search must be stopped.
PortfolioStop(Stop *so)
Initialize.
bool stop(void) const
Whether search must be stopped.
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.
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.
Queue with arbitrary number of elements.
An event for synchronization.
A mutex for mutual exclausion among several threads.
An interface for objects that can be run by a thread.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
#define GECODE_SEARCH_EXPORT