40 template<
class T,
template<
class>
class E>
50 template<
class T,
template<
class>
class E>
55 template<
class T,
template<
class>
class E>
65namespace 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);
87 const Statistics& stat,
bool best);
93 template<
class T,
template<
class>
class E>
101 static_cast<double>(opt.
assets)),1.0);
103 unsigned int n_slaves = opt.
assets;
110 for (
unsigned int i=0U; i<n_slaves; i++) {
112 Space* slave = (i == n_slaves-1) ?
113 master : master->clone();
114 (void) slave->
slave(i);
121 template<
class T,
template<
class>
class E>
127 int n_slaves = sebs.
size();
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();
141 (void) slave->
slave(i);
142 slaves[i] = (*sebs[i])(slave);
149#ifdef GECODE_HAS_THREADS
151 template<
class T,
template<
class>
class E>
158 unsigned int n_slaves = std::min(
static_cast<unsigned int>(opt.
threads),
169 for (
unsigned int i=0U; i<n_slaves; i++) {
171 Space* slave = (i == n_slaves-1) ?
172 master : master->clone();
173 (void) slave->
slave(i);
180 template<
class T,
template<
class>
class E>
187 int n_slaves = std::min(
static_cast<int>(opt.
threads),
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();
203 (void) slave->
slave(i);
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);
252#ifdef GECODE_HAS_THREADS
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()))
286 T* master = opt.clone ?
287 dynamic_cast<T*
>(s->clone()) : s;
291 (void) master->master(0);
293#ifdef GECODE_HAS_THREADS
301 template<
class T,
template<
class>
class E>
307 template<
class T,
template<
class>
class E>
314 template<
class T,
template<
class>
class E>
int size(void) const
Return size of array (number of elements)
void assets(unsigned int n)
Set default number of assets in a portfolio.
void threads(double n)
Set number of parallel threads.
Meta engine using a portfolio of search engines.
void build(T *s, SEBs &sebs, const Search::Options &o)
The actual build function.
PBS(T *s, const Search::Options &o=Search::Options::def)
Initialize with engines running copies of s with options o.
static const bool best
Whether engine does best solution search.
Passing search engine builder arguments.
@ PBS
Engine is a PBS engine.
Engine * e
The actual search engine.
Options opt
Stored and already expanded options.
Builder(const Options &opt, bool best)
Initialize with options opt and best solution search support.
bool best(void) const
Whether engine is a best solution search engine.
Search engine implementation interface
Exception: Mixed non-best and best solution search requested
Exception: No assets requested for portfolio-based search
Options expand(void) const
Expand with real number of threads.
Stop * stop
Stop object for stopping search.
SearchTracer * tracer
Tracer object for tracing search.
unsigned int assets
Number of assets (engines) in a portfolio.
double threads
Number of threads to use.
Parallel depth-first search engine
PbsBuilder(const Options &opt)
The constructor.
virtual Engine * operator()(Space *s) const
The actual build function.
unsigned long int fail
Number of failed nodes in search tree.
Base-class for Stop-object.
static void engine(SearchTracer *tracer, SearchTracer::EngineType t, unsigned int n)
Register engine.
virtual bool slave(const MetaInfo &mi)
Slave configuration function for meta search engines.
T * pbs(T *s, const Search::Options &o=Search::Options::def)
Run a portfolio of search engines.
@ SS_FAILED
Space is failed
Engine * pbsengine(Engine **slaves, Stop **stops, unsigned int n_slaves, const Statistics &stat, bool best)
Create parallel portfolio engine.
Stop * pbsstop(Stop *so)
Create stop object.
Engine * dead(const Options &o, const Statistics &stat)
Stop * pbsstop(Stop *so)
Create stop object.
Engine * pbsengine(Engine **slaves, Stop **stops, unsigned int n_slaves, const Statistics &stat, const Search::Options &opt, bool best)
Create sequential portfolio engine.
Engine * build(Space *s, const Options &opt)
Build an engine of type E for a script T.
Engine * pbspar(T *master, const Search::Statistics &stat, Options &opt)
Engine * pbsseq(T *master, const Search::Statistics &stat, Options &opt)
Gecode toplevel namespace
Search::Builder * SEB
Type for a search engine builder.
Post propagator for SetVar SetOpType SetVar SetRelType r
#define GECODE_SEARCH_EXPORT