Go to the documentation of this file.
36 namespace Gecode {
namespace Search {
namespace Par {
69 :
b(NULL), reporter(NULL) {}
118 : so(so0), tostop(NULL) {}
126 template<
class Collect>
129 : Support::Runnable(false), master(m), slave(s),
stop(so) {}
130 template<
class Collect>
135 template<
class Collect>
140 template<
class Collect>
145 template<
class Collect>
153 template<
class Collect>
157 : stat(stat0), slaves(
heap.alloc<
Slave<Collect>*>(
n)),
158 n_slaves(
n), n_active(
n),
159 slave_stop(false), tostop(false), n_busy(0) {
161 for (
unsigned int i=0U;
i<n_slaves;
i++) {
163 static_cast<PortfolioStop*>(stops[
i])->share(&tostop);
168 template<
class Collect>
184 while (slaves[
i] != slave)
186 assert(
i < n_active);
187 assert(n_active > 0);
199 template<
class Collect>
205 }
while (!master->report(
this,s));
208 template<
class Collect>
224 for (
unsigned int i=0U;
i<n_active;
i++)
225 Support::Thread::run(slaves[
i]);
245 for (
unsigned int i=0U;
i<n_active;
i++)
247 slaves[
i]->constrain(*s);
254 template<
class Collect>
260 template<
class Collect>
265 for (
unsigned int i=0U;
i<n_slaves;
i++)
266 s += slaves[
i]->statistics();
270 template<
class Collect>
275 throw NoBest(
"PBS::constrain");
278 for (
unsigned int i=0U;
i<n_active;
i++)
279 slaves[
i]->constrain(
b);
283 template<
class Collect>
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
bool add(Space *s, Slave< CollectAll > *r)
Add a solution a reported by r and always return true.
CollectAll(void)
Initialize.
PortfolioStop(Stop *so)
Initialize.
bool empty(void) const
Check whether there is any solution left.
virtual void constrain(const Space &best)
Constrain function for best solution search.
Base-class for Stop-object.
int solutions(TestSpace *c, Gecode::Search::Options &o, int maxNbSol=-1)
Find number of solutions.
bool stopped(void) const
Check whether slave has been stopped.
Runnable slave of a portfolio master.
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
Exception: Best solution search is not supported
bool add(Space *s, Slave< CollectBest > *r)
Add a solution s by r and return whether is was better.
CollectBest(void)
Initialize.
Gecode toplevel namespace
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
Parallel portfolio engine implementation.
Space * get(Slave< CollectAll > *&r)
Return solution reported by r.
Parallel depth-first search engine
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
Space * get(Slave< CollectBest > *&r)
Return solution reported by r (only if a better one was found)
Post propagator for SetVar SetOpType SetVar SetRelType r
~CollectBest(void)
Destructor.
~CollectAll(void)
Destructor.
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Slave(PBS< Collect > *m, Engine *s, Stop *so)
Initialize with master m, slave s, and its stop object so.
Space * b
Currently best solution.
void share(volatile bool *ts)
Set pointer to shared tostop variable.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Heap heap
The single global heap.
Slave< CollectBest > * reporter
Who has reported the best solution (NULL if solution has already been reported)
void free(T *b, long unsigned int n)
Delete n objects starting at b.
bool empty(void) const
Check whether there is any solution left.
bool constrain(const Space &b)
Dummy function.
void constrain(const Space &b)
Constrain with better solution b.
bool constrain(const Space &b)
Check whether b better and update accordingly.
Statistics statistics(void) const
Return statistics of slave.
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})