Go to the documentation of this file.
34 namespace Gecode {
namespace Search {
namespace Par {
39 template<
class Tracer>
44 template<
class Tracer>
54 template<
class Tracer>
58 template<
class Tracer>
83 template<
class Tracer>
88 path.reset((s != NULL) ? ngdl : 0);
104 template<
class Tracer>
120 template<
class Tracer>
124 for (
unsigned int i=0U;
i<engine().workers();
i++) {
125 unsigned long int r_d = 0ul;
147 template<
class Tracer>
160 template<
class Tracer>
175 if (
this != engine().
worker(0))
179 switch (engine().
cmd()) {
186 engine().ack_terminate();
188 engine().wait_terminate();
193 engine().ack_reset_start();
195 engine().wait_reset();
197 engine().ack_reset_stop();
207 }
else if (cur != NULL) {
217 if (
path.entries() > 0) {
221 }
else if (*tracer.ei()) {
226 unsigned int nid = tracer.nid();
227 switch (cur->status(*
this)) {
231 tracer.wid(), nid, *cur);
244 tracer.wid(), nid, *cur);
254 engine().solution(s);
260 if ((
d == 0) || (
d >= engine().
opt().
c_d)) {
270 tracer.wid(), nid, *cur, ch);
281 }
else if (!
path.empty()) {
282 cur =
path.recompute(
d,engine().
opt().
a_d,*
this,tracer);
306 template<
class Tracer>
334 template<
class Tracer>
358 template<
class Tracer>
void release(Cmd c)
Release all workers.
unsigned int nid(void) const
Return node identifier.
void terminate(void)
For engine to peform thread termination.
Space is solved (no brancher left)
Parallel depth-first search worker
virtual void run(void)
Start execution of worker.
NoGoods & nogoods(void)
Return no-goods.
Support::Mutex m_search
Mutex for search.
void acquire(void)
Acquire the mutex and possibly block.
void find(void)
Try to find some work.
Statistics statistics(void)
Return statistics.
Worker * worker(unsigned int i) const
Provide access to worker i.
Space must be branched (at least one brancher left)
void * ralloc(size_t s)
Allocate s bytes from heap.
Search tree edge for recomputation
Parallel depth-first search engine
void invalidate(void)
Invalidate edge information (for stealing)
Support::Event e_reset_ack_start
Event for reset acknowledgment started.
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization)
virtual void reset(Space *s)
Reset engine to restart at space s.
void stop(void)
Report that worker has been stopped.
Support::Event e_search
Event for search (solution found, no more solutions, search stopped)
Gecode toplevel namespace
const Choice * choice(void) const
Return choice.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
No-goods recorded from restarts.
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
Engine & _engine
Reference to engine.
Parallel depth-first search engine
const Choice & choice(void) const
Return corresponding choice.
void idle(void)
Report that worker is idle.
void solution(Space *s)
Report solution s.
virtual ~DFS(void)
Destructor.
const unsigned int nogoods_limit
Depth limit for no-good generation during search.
DFS(Space *s, const Options &o)
Initialize for space s with options o.
Support::Event e_reset_ack_stop
Event for reset acknowledgment stopped.
static void run(Runnable *r)
Construct a new thread and run r.
Worker ** _worker
Array of worker references.
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.
Space * cur
Current space being explored.
virtual Statistics statistics(void) const
Return statistics.
unsigned int d
Distance until next clone.
Node representing a branch.
#define GECODE_NEVER
Assert that this command is never executed.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Support::Mutex m_wait_reset
Mutex for waiting for reset.
DFS & engine(void) const
Provide access to engine.
Heap heap
The single global heap.
void reset(Space *s, unsigned int ngdl)
Reset worker to restart at space s.
const Options & opt(void) const
Provide access to search options.
void signal(void)
Signal the event.
void init(unsigned int wid, unsigned int nid, unsigned int a)
Initialize.
volatile unsigned int n_busy
Number of busy workers.
Parallel depth-first search worker
static void sleep(unsigned int ms)
Put current thread to sleep for ms milliseconds.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntPropLevel ipl)
Post propagator such that x forms a Hamiltonian path.
virtual NoGoods & nogoods(void)
Return no-goods.
void block(void)
Block all workers.
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Space * steal(unsigned long int &d, Tracer &myt, Tracer &ot)
Hand over some work (NULL if no work available)
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance)
Gecode::FloatVal c(-8, 8)
void release(void)
Release the mutex.
Choice for performing commit
Path< Tracer > path
Current path ins search tree.
void rfree(void *p)
Free memory block starting at p.
void wait(void)
Wait until the event becomes signalled.
unsigned int workers(void) const
Return number of workers.
Cmd cmd(void) const
Return current command.
Node representing failure.
Gecode::IntArgs i({1, 2, 3, 4})
Tracer tracer
Search tracer.
static void engine(SearchTracer *tracer, SearchTracer::EngineType t, unsigned int n)
Register engine.
bool idle
Whether the worker is idle.
Node representing a solution.
SearchTracer * tracer
Tracer object for tracing search.