Generated on Thu Jul 21 2022 00:00:00 for Gecode by doxygen 1.9.4
bab.hh
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Christian Schulte <schulte@gecode.org>
5 *
6 * Copyright:
7 * Christian Schulte, 2009
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#ifndef __GECODE_SEARCH_PAR_BAB_HH__
35#define __GECODE_SEARCH_PAR_BAB_HH__
36
38
39namespace Gecode { namespace Search { namespace Par {
40
42 template<class Tracer>
43 class BAB : public Engine<Tracer> {
44 protected:
45 using Engine<Tracer>::idle;
46 using Engine<Tracer>::busy;
47 using Engine<Tracer>::stop;
48 using Engine<Tracer>::block;
55 using Engine<Tracer>::opt;
66 class Worker : public Engine<Tracer>::Worker {
67 protected:
68 using Engine<Tracer>::Worker::_engine;
69 using Engine<Tracer>::Worker::m;
71 using Engine<Tracer>::Worker::cur;
73 using Engine<Tracer>::Worker::idle;
74 using Engine<Tracer>::Worker::node;
75 using Engine<Tracer>::Worker::fail;
76 using Engine<Tracer>::Worker::start;
77 using Engine<Tracer>::Worker::tracer;
80 int mark;
83 public:
85 Worker(Space* s, BAB& e);
87 BAB& engine(void) const;
89 virtual void run(void);
91 void better(Space* b);
93 void find(void);
95 void reset(Space* s, unsigned int ngdl);
97 virtual ~Worker(void);
98 };
103 public:
105 Worker* worker(unsigned int i) const;
106
108
109
110 void solution(Space* s);
112
114
115
116 BAB(Space* s, const Options& o);
118 virtual Statistics statistics(void) const;
120 virtual void reset(Space* s);
122 virtual void constrain(const Space& b);
125 virtual NoGoods& nogoods(void);
127 virtual ~BAB(void);
129 };
130
131}}}
132
134
135#endif
136
137// STATISTICS: search-par
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
No-goods recorded from restarts.
Definition: core.hpp:1588
Search engine options
Definition: search.hh:746
Parallel branch-and-bound search worker
Definition: bab.hh:66
void find(void)
Try to find some work.
Definition: bab.hpp:148
Space * best
Best solution found so far.
Definition: bab.hh:82
int mark
Number of entries not yet constrained to be better.
Definition: bab.hh:80
void better(Space *b)
Accept better solution b.
Definition: bab.hpp:106
BAB & engine(void) const
Provide access to engine.
Definition: bab.hpp:41
virtual ~Worker(void)
Destructor.
Definition: bab.hpp:411
virtual void run(void)
Start execution of worker.
Definition: bab.hpp:209
Parallel branch-and-bound engine
Definition: bab.hh:43
Worker ** _worker
Array of worker references.
Definition: bab.hh:100
void solution(Space *s)
Report solution s.
Definition: bab.hpp:117
Worker * worker(unsigned int i) const
Provide access to worker i.
Definition: bab.hpp:46
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Definition: bab.hpp:187
virtual void reset(Space *s)
Reset engine to restart at space s.
Definition: bab.hpp:360
virtual ~BAB(void)
Destructor.
Definition: bab.hpp:416
Space * best
Best solution so far.
Definition: bab.hh:102
BAB(Space *s, const Options &o)
Initialize for space s with options o.
Definition: bab.hpp:81
virtual Statistics statistics(void) const
Return statistics.
Definition: bab.hpp:178
virtual NoGoods & nogoods(void)
Constrain Return no-goods.
Definition: bab.hpp:389
Parallel depth-first search engine
Definition: engine.hh:46
void idle(void)
Report that worker is idle.
Definition: engine.hpp:152
const Options & opt(void) const
Provide access to search options.
Definition: engine.hpp:47
Support::Event e_reset_ack_stop
Event for reset acknowledgment stopped.
Definition: engine.hh:151
Support::Event e_search
Event for search (solution found, no more solutions, search stopped)
Definition: engine.hh:169
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
Definition: engine.hh:171
void stop(void)
Report that worker has been stopped.
Definition: engine.hpp:172
void block(void)
Block all workers.
Definition: engine.hpp:73
Support::Mutex m_wait_reset
Mutex for waiting for reset.
Definition: engine.hh:153
Support::Mutex m_search
Mutex for search.
Definition: engine.hh:167
Support::Event e_reset_ack_start
Event for reset acknowledgment started.
Definition: engine.hh:149
void busy(void)
Report that worker is busy.
Definition: engine.hpp:163
void release(Cmd c)
Release all workers.
Definition: engine.hpp:79
bool signal(void) const
Whether search state changed such that signal is needed.
Definition: engine.hpp:147
void terminate(void)
For engine to peform thread termination.
Definition: engine.hpp:216
volatile unsigned int n_busy
Number of busy workers.
Definition: engine.hh:173
unsigned int workers(void) const
Return number of workers.
Definition: engine.hpp:52
@ C_WORK
Perform work.
Definition: engine.hh:94
@ C_RESET
Perform reset operation.
Definition: engine.hh:96
@ C_WAIT
Run into wait lock.
Definition: engine.hh:95
@ C_TERMINATE
Terminate.
Definition: engine.hh:97
Search engine statistics
Definition: search.hh:147
void reset(void)
Reset.
Definition: statistics.hpp:39
Worker(void)
Initialize.
Definition: worker.hh:70
Computation spaces.
Definition: core.hpp:1742
Tracer.
Definition: tracer.hpp:149
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
Definition: script.cpp:42
Gecode toplevel namespace
void path(Home home, const IntVarArgs &x, IntVar s, IntVar e, IntPropLevel ipl=IPL_DEF)
Post propagator such that x forms a Hamiltonian path.
Definition: circuit.cpp:169
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::IntSet d(v, 7)