Go to the documentation of this file.
37 namespace Gecode {
namespace Search {
40 template<
class T,
template<
class>
class E>
50 template<
class T,
template<
class>
class E>
55 template<
class T,
template<
class>
class E>
58 return build<T,PBS<T,E> >(s,
opt);
65 namespace Gecode {
namespace Search {
namespace Seq {
73 pbsengine(Engine** slaves, Stop** stops,
unsigned int n_slaves,
74 const Statistics& stat,
const Search::Options&
opt,
bool best);
78 namespace Gecode {
namespace Search {
namespace Par {
86 pbsengine(Engine** slaves, Stop** stops,
unsigned int n_slaves,
87 const Statistics& stat,
bool best);
91 namespace Gecode {
namespace Search {
93 template<
class T,
template<
class>
class E>
108 SearchTracer::EngineType::PBS, n_slaves);
110 for (
unsigned int i=0U;
i<n_slaves;
i++) {
112 Space* slave = (
i == n_slaves-1) ?
113 master : master->
clone();
115 slaves[
i] = build<T,E>(slave,
opt);
121 template<
class T,
template<
class>
class E>
127 int n_slaves = sebs.size();
132 SearchTracer::EngineType::PBS, n_slaves);
134 for (
int i=0;
i<n_slaves;
i++) {
137 sebs[
i]->options().stop = stops[
i];
138 sebs[
i]->options().clone =
false;
139 Space* slave = (
i == n_slaves-1) ?
140 master : master->
clone();
142 slaves[
i] = (*sebs[
i])(slave);
149 #ifdef GECODE_HAS_THREADS
151 template<
class T,
template<
class>
class E>
164 SearchTracer::EngineType::PBS, n_slaves);
169 for (
unsigned int i=0U;
i<n_slaves;
i++) {
171 Space* slave = (
i == n_slaves-1) ?
172 master : master->
clone();
174 slaves[
i] = build<T,E>(slave,
opt);
180 template<
class T,
template<
class>
class E>
191 SearchTracer::EngineType::PBS, n_slaves);
196 for (
int i=0;
i<n_slaves;
i++) {
199 sebs[
i]->options().stop = stops[
i];
200 sebs[
i]->options().clone =
false;
201 Space* slave = (
i == n_slaves-1) ?
202 master : master->
clone();
204 slaves[
i] = (*sebs[
i])(slave);
208 for (
int i=n_slaves;
i<sebs.size();
i++)
220 template<
class T,
template<
class>
class E>
238 T* master =
opt.clone ?
239 dynamic_cast<T*
>(s->clone()) : s;
243 (void) master->master(0);
247 (void) master->slave(0);
248 e = Search::build<T,E>(master,
opt);
252 #ifdef GECODE_HAS_THREADS
254 e = Search::pbspar<T,E>(master,stat,
opt);
257 e = Search::pbsseq<T,E>(master,stat,
opt);
260 template<
class T,
template<
class>
class E>
267 for (
int i=0;
i<sebs.size();
i++)
268 b += sebs[
i]->best() ? 1 : 0;
269 if ((
b > 0) && (
b < sebs.size()))
271 best = (
b == sebs.size());
286 T* master =
opt.clone ?
287 dynamic_cast<T*
>(s->clone()) : s;
291 (void) master->master(0);
293 #ifdef GECODE_HAS_THREADS
295 e = Search::pbspar<T,E>(master,sebs,stat,
opt,best);
298 e = Search::pbsseq<T,E>(master,sebs,stat,
opt,best);
301 template<
class T,
template<
class>
class E>
307 template<
class T,
template<
class>
class E>
314 template<
class T,
template<
class>
class E>
#define GECODE_SEARCH_EXPORT
Exception: Mixed non-best and best solution search requested
A class for building search engines.
Engine * dead(const Options &o, const Statistics &stat)
Base-class for Stop-object.
unsigned long int fail
Number of failed nodes in search tree.
Engine * build(Space *s, const Options &opt)
Build an engine of type E for a script T.
const FloatNum min
Smallest allowed float value.
T * pbs(T *s, const Search::Options &o)
Run a portfolio of search engines.
Gecode toplevel namespace
Search::Builder * SEB
Type for a search engine builder.
Passing search engine builder arguments.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
PBS(T *s, const Search::Options &o=Search::Options::def)
Initialize with engines running copies of s with options o.
Stop * pbsstop(Stop *so)
Create stop object.
Meta engine using a portfolio of search engines.
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
Stop * stop
Stop object for stopping search.
Search engine implementation interface
Post propagator for SetVar SetOpType SetVar SetRelType r
PbsBuilder(const Options &opt)
The constructor.
Engine * pbsengine(Engine **slaves, Stop **stops, unsigned int n_slaves, const Statistics &stat, const Search::Options &opt, bool best)
Create sequential portfolio engine.
void build(T *s, SEBs &sebs, const Search::Options &o)
The actual build function.
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Stop * pbsstop(Stop *so)
Create stop object.
void assets(unsigned int n)
Set default number of assets in a portfolio.
Exception: No assets requested for portfolio-based search
Options expand(void) const
Expand with real number of threads.
unsigned int assets
Number of assets (engines) in a portfolio.
Engine * pbsengine(Engine **slaves, Stop **stops, unsigned int n_slaves, const Statistics &stat, bool best)
Create parallel portfolio engine.
void threads(double n)
Set number of parallel threads.
virtual bool slave(const MetaInfo &mi)
Slave configuration function for meta search engines.
Engine * pbsseq(T *master, const Search::Statistics &stat, Options &opt)
Options opt
Stored and already expanded options.
Engine * pbspar(T *master, const Search::Statistics &stat, Options &opt)
Gecode::IntArgs i({1, 2, 3, 4})
virtual Engine * operator()(Space *s) const
The actual build function.
@ SS_FAILED
Space is failed
static void engine(SearchTracer *tracer, SearchTracer::EngineType t, unsigned int n)
Register engine.
const FloatNum max
Largest allowed float value.
double threads
Number of threads to use.
SearchTracer * tracer
Tracer object for tracing search.