42 #ifndef __GECODE_SEARCH_HH__ 43 #define __GECODE_SEARCH_HH__ 51 #if !defined(GECODE_STATIC_LIBS) && \ 52 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER)) 54 #ifdef GECODE_BUILD_SEARCH 55 #define GECODE_SEARCH_EXPORT __declspec( dllexport ) 57 #define GECODE_SEARCH_EXPORT __declspec( dllimport ) 62 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY 63 #define GECODE_SEARCH_EXPORT __attribute__ ((visibility("default"))) 65 #define GECODE_SEARCH_EXPORT 71 #ifndef GECODE_BUILD_SEARCH 72 #define GECODE_LIBRARY_NAME "Search" 77 namespace Gecode {
namespace Search {
80 namespace Sequential {}
91 namespace Sequential {}
111 const unsigned int c_d = 8;
113 const unsigned int a_d = 2;
121 const unsigned int d_l = 5;
139 namespace Gecode {
namespace Search {
171 namespace Gecode {
namespace Search {
218 bool meta(
void)
const;
222 unsigned int wfst(
void)
const;
225 unsigned int wlst(
void)
const;
227 unsigned int workers(
void)
const;
231 unsigned int efst(
void)
const;
234 unsigned int elst(
void)
const;
236 unsigned int engines(
void)
const;
252 void init(
unsigned int wid,
unsigned int nid,
unsigned int a);
254 void init(
unsigned int wid,
unsigned int nid,
unsigned int a,
257 void invalidate(
void);
261 EdgeInfo(
unsigned int wid,
unsigned int nid,
unsigned int a);
263 operator bool(
void)
const;
265 unsigned int wid(
void)
const;
267 unsigned int nid(
void)
const;
269 unsigned int alternative(
void)
const;
271 std::string string(
void)
const;
295 unsigned int wid,
unsigned int nid,
300 unsigned int wid(
void)
const;
302 unsigned int nid(
void)
const;
304 const Space& space(
void)
const;
306 const Choice& choice(
void)
const;
312 unsigned int pending;
318 unsigned int n_active;
326 void worker(
unsigned int& wid,
unsigned int& eid);
332 void _round(
unsigned int eid);
343 unsigned int workers(
void)
const;
346 unsigned int engines(
void)
const;
348 const EngineInfo& engine(
unsigned int eid)
const;
350 unsigned int eid(
unsigned int wid)
const;
354 virtual void init(
void) = 0;
357 virtual void round(
unsigned int eid) = 0;
359 virtual void skip(
const EdgeInfo& ei) = 0;
363 virtual void done(
void) = 0;
374 static const char* t2s[EngineType::AOE + 1];
379 virtual void init(
void);
381 virtual void round(
unsigned int eid);
383 virtual void skip(
const EdgeInfo& ei);
387 virtual void done(
void);
399 #ifdef GECODE_HAS_CPPROFILER 404 namespace CPProfiler {}
408 namespace Gecode {
namespace CPProfiler {
426 virtual std::string getInfo(
const Space& home)
const = 0;
447 virtual void init(
void);
449 virtual void round(
unsigned int eid);
451 virtual void skip(
const EdgeInfo& ei);
455 virtual void done(
void);
464 namespace Gecode {
namespace Search {
477 virtual unsigned long int operator ()(
void)
const = 0;
479 virtual unsigned long int operator ++(
void) = 0;
504 rnd(
unsigned int seed,
505 unsigned long int min,
unsigned long int max,
506 unsigned long int n);
515 repeat(
Cutoff*
c,
unsigned long int n);
531 virtual unsigned long int operator ()(
void)
const;
533 virtual unsigned long int operator ++(
void);
550 virtual unsigned long int operator ()(
void)
const;
552 virtual unsigned long int operator ++(
void);
566 static const unsigned long int n_start = 63U;
568 static unsigned long int start[n_start];
570 static unsigned long int log(
unsigned long int i);
572 static unsigned long int luby(
unsigned long int i);
577 virtual unsigned long int operator ()(
void)
const;
579 virtual unsigned long int operator ++(
void);
598 virtual unsigned long int operator ()(
void)
const;
600 virtual unsigned long int operator ++(
void);
622 unsigned long int min,
unsigned long int max,
623 unsigned long int n);
625 virtual unsigned long int operator ()(
void)
const;
627 virtual unsigned long int operator ++(
void);
646 virtual unsigned long int operator ()(
void)
const;
648 virtual unsigned long int operator ++(
void);
667 virtual unsigned long int operator ()(
void)
const;
669 virtual unsigned long int operator ++(
void);
692 virtual unsigned long int operator ()(
void)
const;
694 virtual unsigned long int operator ++(
void);
703 namespace Gecode {
namespace Search {
781 namespace Gecode {
namespace Search {
810 static Stop* node(
unsigned long int l);
813 static Stop* fail(
unsigned long int l);
815 static Stop* time(
unsigned long int l);
835 unsigned long int limit(
void)
const;
837 void limit(
unsigned long int l);
858 unsigned long int limit(
void)
const;
860 void limit(
unsigned long int l);
879 unsigned long int limit(
void)
const;
881 void limit(
unsigned long int l);
892 namespace Gecode {
namespace Search {
900 virtual Space* next(
void) = 0;
902 virtual Statistics statistics(
void)
const = 0;
904 virtual bool stopped(
void)
const = 0;
906 virtual void constrain(
const Space&
b);
908 virtual void reset(
Space* s);
910 virtual NoGoods& nogoods(
void);
919 namespace Gecode {
namespace Search {
924 template<
class,
class>
926 template<
class,
template<
class>
class>
935 virtual T* next(
void);
939 virtual bool stopped(
void)
const;
953 namespace Gecode {
namespace Search {
956 template<
class T,
class E>
959 template<
class T,
template<
class>
class E>
975 const Options& options(
void)
const;
977 bool best(
void)
const;
1007 explicit SEBs(
int n);
1009 SEBs(
const std::vector<SEB>&
x);
1011 template<
class InputIterator>
1012 SEBs(InputIterator first, InputIterator last);
1040 static const bool best =
false;
1074 static const bool best =
true;
1112 static const bool best =
false;
1150 template<
class T,
template<
class>
class E =
DFS>
1157 static const bool best = E<T>::best;
1178 template<
class T,
template<
class>
class E>
1182 template<
class T,
template<
class>
class E>
1189 namespace Gecode {
namespace Search {
namespace Meta {
1192 template<
class T,
template<
class>
class E>
1196 template<
class T,
template<
class>
class E>
1200 #ifdef GECODE_HAS_THREADS 1203 template<
class T,
template<
class>
class E>
1207 template<
class T,
template<
class>
class E>
1234 template<
class T,
template<
class>
class E =
DFS>
1255 static const bool best = E<T>::best;
1275 template<
class T,
template<
class>
class E>
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
double scale
Scale factor.
const Space & _s
The corresponding space.
const Choice * _c
The corresponding choice (nullptr if type is not BRANCH)
Search engine implementation interface
unsigned int nogoods_limit
Depth limit for extraction of no-goods.
Limited discrepancy search engine.
unsigned long int scale
Scale factor.
Class to send solution information to CPProfiler.
Stop-object based on number of nodes
void log(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Meta-engine performing restart-based search.
Meta engine using a portfolio of search engines.
#define GECODE_SEARCH_EXPORT
Node representing a branch.
Cutoff * c1
First cutoff generator.
Argument array for primtive types.
unsigned int c_d
Create a clone after every c_d commits (commit distance)
Cutoff generator appending two cutoff generators.
unsigned int _nid
The parent node id.
A class for building search engines.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Options opt
Stored and already expanded options.
unsigned long int l
Current limit in milliseconds.
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
unsigned long int step
Step size.
Engine * build(Space *s, const Options &opt)
Build an engine of type E for a script T.
std::string _s
String corresponding to alternative.
const unsigned int initial_delay
Initial delay in milliseconds for all but first worker thread.
unsigned int slice
Size of a slice in a portfolio (in number of failures)
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
unsigned long int scale
Scale factor.
unsigned long int fail
Number of failed nodes in search tree.
unsigned long int nogood
Number of no-goods posted.
Support::Timer t
Time when execution should stop.
Node representing failure.
unsigned long int depth
Maximum depth of search stack.
Array with arbitrary number of elements.
Cutoff generator for the Luby sequence.
Base class for cutoff generators for restart-based meta engine.
unsigned long int min
Minimum cutoff value.
Class to record search trace info for CPProfiler.
EngineType
Which type of engine.
unsigned long int c
Constant.
unsigned int d_l
Discrepancy limit (for LDS)
unsigned long int n
Random values.
Statistics for execution of status
A mutex for mutual exclausion among several threads.
std::string expand(Gecode::IntRelType irt)
Expand relation to abbreviation.
Gecode::FloatVal c(-8, 8)
Cutoff generator merging two cutoff generators.
Cutoff * cutoff
Cutoff for restart-based search.
double threads
Number of threads to use.
const bool b
Whether engine to be built is a best solution search engine.
const unsigned int cpprofiler_port
Default port for CPProfiler.
Cutoff generator for the random sequence.
int n
Number of negative literals for node type.
Recorder for a search tracer with edge information.
Base-class for search engines.
Depth-first branch-and-bound search engine.
FloatVal operator+(const FloatVal &x)
Simple recorder for a search tracer.
static const Options def
Default options.
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Node representing a solution.
unsigned long int n
How many number to take from the first.
unsigned long int cur
Current value.
Support::RandomGenerator rnd
Random number generator.
EngineType _type
The engine type.
unsigned long int i
Iteration number.
double n
Current cutoff value.
bool clone
Whether engines create a clone when being initialized.
Template for linear congruential generators.
Search::Builder * SEB
Type for a search engine builder.
const unsigned int d_l
Default discrepancy limit for LDS.
unsigned int _a
Number of alternative.
Cutoff * c2
Second cutoff generators.
unsigned int _lst
Last worker or engine.
SearchTracer * tracer
Tracer object for tracing search.
T * lds(T *s, const Search::Options &o)
Invoke limited-discrepancy search for s as root node and optionso.
Cutoff * c1
First cutoff generators.
Cutoff generator for linear sequence.
const double threads
Number of threads to use.
T * dfs(T *s, const Search::Options &o)
Invoke depth-first search engine for subclass T of space s with options o.
Support for tracing search.
unsigned int assets
Number of assets (engines) in a portfolio.
Cutoff generator for the geometric sequence.
T * bab(T *s, const Search::Options &o)
Perform depth-first branch-and-bound search for subclass T of space s and options o...
T * pbs(T *s, const Search::Options &o)
Run a portfolio of search engines.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Cutoff * c
Actual cutoff generator.
Cutoff generator for constant sequence.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
const double base
Base for geometric restart sequence.
unsigned long int n
Next number in sequence.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Choice for performing commit
No-goods recorded from restarts.
unsigned long int l
Node limit.
Engine * e
The actual search engine.
unsigned int _wid
The worker id.
unsigned long int l
Failure limit.
std::ostream & os
Output stream to use.
Cutoff generator that repeats a cutoff from another cutoff generator.
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Post propagator for SetVar x
Recorder for engine events (for access control)
unsigned long int restart
Number of restarts.
Passing search engine builder arguments.
unsigned int _nid
The node id.
Stop * stop
Stop object for stopping search.
Gecode toplevel namespace
unsigned long int node
Number of nodes expanded.
const unsigned int nogoods_limit
Depth limit for no-good generation during search.
Information about an engine.
unsigned int _wid
The parent worker id (edge does not exist if UINT_MAX)
Stop-object based on time
Base-class for Stop-object.
Cutoff * c2
Second cutoff generator.
NodeType _nt
The node type.
Base class for heap allocated objects.
static StdSearchTracer def
Default tracer (printing to std::cerr)
const unsigned int steal_limit
Minimal number of open nodes for stealing.
T * rbs(T *s, const Search::Options &o)
Perform restart-based search.
const unsigned int slice
Size of a slice in a portfolio and scale factor for restarts(in number of failures) ...
Depth-first search engine.
unsigned int _fst
First worker or engine.
Stop-object based on number of failures
const bool clone
Whether engines create a clone when being initialized.