40 namespace Gecode {
namespace Search {
namespace Par {
73 :
b(NULL), reporter(NULL) {}
122 : so(so0), tostop(NULL) {}
130 template<
class Collect>
133 : Support::Runnable(false), master(m), slave(s),
stop(so) {}
134 template<
class Collect>
139 template<
class Collect>
144 template<
class Collect>
149 template<
class Collect>
157 template<
class Collect>
161 : stat(stat0), slaves(
heap.alloc<
Slave<Collect>*>(n)),
162 n_slaves(n), n_active(n),
163 slave_stop(false), tostop(false), n_busy(0) {
165 for (
unsigned int i=n_slaves;
i--; ) {
172 template<
class Collect>
188 while (slaves[i] != slave)
190 assert(i < n_active);
191 assert(n_active > 0);
203 template<
class Collect>
209 }
while (!master->report(
this,s));
212 template<
class Collect>
228 for (
unsigned int i=n_active;
i--; )
229 Support::Thread::run(slaves[
i]);
249 for (
unsigned int i=n_active;
i--; )
251 slaves[
i]->constrain(*s);
258 template<
class Collect>
264 template<
class Collect>
269 for (
unsigned int i=n_slaves;
i--; )
270 s += slaves[
i]->statistics();
274 template<
class Collect>
279 throw NoBest(
"PBS::constrain");
282 for (
unsigned int i=n_active;
i--; )
283 slaves[
i]->constrain(b);
287 template<
class Collect>
bool stopped(void) const
Check whether slave has been stopped.
bool empty(void) const
Check whether there is any solution left.
Space * b
Currently best solution.
CollectBest(void)
Initialize.
void constrain(const Space &b)
Constrain with better solution b.
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
bool add(Space *s, Slave< CollectBest > *r)
Add a solution s by r and return whether is was better.
bool empty(void) const
Check whether there is any solution left.
~CollectBest(void)
Destructor.
Parallel depth-first search engine
Slave(PBS< Collect > *m, Engine *s, Stop *so)
Initialize with master m, slave s, and its stop object so.
PortfolioStop(Stop *so)
Initialize.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Slave< CollectBest > * reporter
Who has reported the best solution (NULL if solution has already been reported)
~CollectAll(void)
Destructor.
Space * get(Slave< CollectBest > *&r)
Return solution reported by r (only if a better one was found)
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
bool stop(void) const
Whether search must be stopped.
void share(volatile bool *ts)
Set pointer to shared tostop variable.
bool constrain(const Space &b)
Dummy function.
virtual void constrain(const Space &best)
Constrain function for best solution search.
Space * get(Slave< CollectAll > *&r)
Return solution reported by r.
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
Post propagator for SetVar SetOpType SetVar SetRelType r
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Stop object used for controling slaves in a portfolio.
Statistics statistics(void) const
Return statistics of slave.
Heap heap
The single global heap.
Parallel portfolio engine implementation.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Runnable slave of a portfolio master.
Exception: Best solution search is not supported
bool constrain(const Space &b)
Check whether b better and update accordingly.
Gecode toplevel namespace
Base-class for Stop-object.
bool add(Space *s, Slave< CollectAll > *r)
Add a solution a reported by r and always return true.
int solutions(TestSpace *c, Gecode::Search::Options &o, int maxNbSol=-1)
Find number of solutions.
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
CollectAll(void)
Initialize.