38 namespace Gecode {
namespace Search {
namespace Par {
43 template<
class Tracer>
48 template<
class Tracer>
58 template<
class Tracer>
62 template<
class Tracer>
87 template<
class Tracer>
92 path.reset((s != NULL) ? ngdl : 0);
108 template<
class Tracer>
124 template<
class Tracer>
128 for (
unsigned int i=0;
i<engine().workers();
i++) {
129 unsigned long int r_d = 0ul;
151 template<
class Tracer>
164 template<
class Tracer>
179 if (
this != engine().
worker(0))
183 switch (engine().
cmd()) {
190 engine().ack_terminate();
192 engine().wait_terminate();
197 engine().ack_reset_start();
199 engine().wait_reset();
201 engine().ack_reset_stop();
211 }
else if (cur != NULL) {
221 if (
path.entries() > 0) {
225 }
else if (*tracer.ei()) {
230 unsigned int nid = tracer.nid();
231 switch (cur->status(*
this)) {
235 tracer.wid(), nid, *cur);
248 tracer.wid(), nid, *cur);
258 engine().solution(s);
264 if ((
d == 0) || (
d >= engine().
opt().
c_d)) {
271 const Choice* ch =
path.push(*
this,cur,c,nid);
274 tracer.wid(), nid, *cur, ch);
285 }
else if (!
path.empty()) {
286 cur =
path.recompute(
d,engine().
opt().
a_d,*
this,tracer);
310 template<
class Tracer>
338 template<
class Tracer>
362 template<
class Tracer>
Statistics statistics(void)
Return statistics.
Support::Event e_reset_ack_stop
Event for reset acknowledgment stopped.
void solution(Space *s)
Report solution s.
void stop(void)
Report that worker has been stopped.
void reset(Space *s, unsigned int ngdl)
Reset worker to restart at space s.
Space must be branched (at least one brancher left)
unsigned int workers(void) const
Return number of workers.
Support::Event e_reset_ack_start
Event for reset acknowledgment started.
DFS & engine(void) const
Provide access to engine.
virtual Statistics statistics(void) const
Return statistics.
void terminate(void)
For engine to peform thread termination.
Node representing a branch.
void rfree(void *p)
Free memory block starting at p.
bool signal(void) const
Whether search state changed such that signal is needed.
const unsigned int initial_delay
Initial delay in milliseconds for all but first worker thread.
const Choice & choice(void) const
Return corresponding choice.
static void run(Runnable *r)
Construct a new thread and run r.
Engine & _engine
Reference to engine.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntPropLevel ipl)
Post propagator such that x forms a Hamiltonian path.
void acquire(void)
Acquire the mutex and possibly block.
void * ralloc(size_t s)
Allocate s bytes from heap.
Node representing failure.
Support::Mutex m_search
Mutex for search.
Search tree edge for recomputation
Parallel depth-first search engine
void signal(void)
Signal the event.
unsigned int nid(void) const
Return node identifier.
void release(void)
Release the mutex.
Gecode::FloatVal c(-8, 8)
void init(unsigned int wid, unsigned int nid, unsigned int a)
Initialize.
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual NoGoods & nogoods(void)
Return no-goods.
Cmd cmd(void) const
Return current command.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Node representing a solution.
Support::Mutex m_wait_reset
Mutex for waiting for reset.
static void sleep(unsigned int ms)
Put current thread to sleep for ms milliseconds.
void release(Cmd c)
Release all workers.
const Choice * choice(void) const
Return choice.
Space * steal(unsigned long int &d, Tracer &myt, Tracer &ot)
Hand over some work (NULL if no work available)
Parallel depth-first search worker
SearchTracer * tracer
Tracer object for tracing search.
Parallel depth-first search engine
Worker ** _worker
Array of worker references.
const Options & opt(void) const
Provide access to search options.
static void engine(SearchTracer *tracer, SearchTracer::EngineType t, unsigned int n)
Register engine.
Support::Event e_search
Event for search (solution found, no more solutions, search stopped)
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
virtual void run(void)
Start execution of worker.
Choice for performing commit
virtual ~DFS(void)
Destructor.
No-goods recorded from restarts.
Heap heap
The single global heap.
void find(void)
Try to find some work.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
void idle(void)
Report that worker is idle.
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
virtual void reset(Space *s)
Reset engine to restart at space s.
NoGoods & nogoods(void)
Return no-goods.
Gecode toplevel namespace
const unsigned int nogoods_limit
Depth limit for no-good generation during search.
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization)
volatile unsigned int n_busy
Number of busy workers.
void invalidate(void)
Invalidate edge information (for stealing)
void block(void)
Block all workers.
Tracer tracer
Search tracer.
#define GECODE_NEVER
Assert that this command is never executed.
void wait(void)
Wait until the event becomes signalled.
Parallel depth-first search worker
DFS(Space *s, const Options &o)
Initialize for space s with options o.
Worker * worker(unsigned int i) const
Provide access to worker i.
Space is solved (no brancher left)