gist.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __GECODE_GIST_HH__
00038 #define __GECODE_GIST_HH__
00039
00040 #include <gecode/kernel.hh>
00041 #include <gecode/search.hh>
00042 #include <gecode/int.hh>
00043 #ifdef GECODE_HAS_SET_VARS
00044 #include <gecode/set.hh>
00045 #endif
00046 #ifdef GECODE_HAS_FLOAT_VARS
00047 #include <gecode/float.hh>
00048 #endif
00049
00050
00051
00052
00053
00054
00055 #if !defined(GIST_STATIC_LIBS) && \
00056 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00057
00058 #ifdef GECODE_BUILD_GIST
00059 #define GECODE_GIST_EXPORT __declspec( dllexport )
00060 #else
00061 #define GECODE_GIST_EXPORT __declspec( dllimport )
00062 #endif
00063
00064 #else
00065
00066 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00067 #define GECODE_GIST_EXPORT __attribute__ ((visibility("default")))
00068 #else
00069 #define GECODE_GIST_EXPORT
00070 #endif
00071
00072 #endif
00073
00074
00075 #ifndef GECODE_BUILD_GIST
00076 #define GECODE_LIBRARY_NAME "Gist"
00077 #include <gecode/support/auto-link.hpp>
00078 #endif
00079
00080 #include <string>
00081 #include <sstream>
00082
00083 namespace Gecode {
00084
00093 namespace Gist {
00094
00103 class GECODE_GIST_EXPORT Inspector {
00104 public:
00106 virtual void inspect(const Space& s) = 0;
00108 virtual std::string name(void);
00110 virtual void finalize(void);
00112 virtual ~Inspector(void);
00113 };
00114
00123 class GECODE_GIST_EXPORT Comparator {
00124 public:
00126
00127
00129 virtual void compare(const Space& s0, const Space& s1) = 0;
00131 virtual std::string name(void);
00133 virtual void finalize(void);
00135 virtual ~Comparator(void);
00136
00138
00140
00141
00143 template<class Var>
00144 static std::string compare(std::string x_n, const VarArgArray<Var>& x,
00145 const VarArgArray<Var>& y);
00147 static std::string compare(std::string x_n, IntVar x, IntVar y);
00149 static std::string compare(std::string x_n, BoolVar x, BoolVar y);
00150 #ifdef GECODE_HAS_SET_VARS
00151
00152 static std::string compare(std::string x_n, SetVar x, SetVar y);
00153 #endif
00154 #ifdef GECODE_HAS_FLOAT_VARS
00155
00156 static std::string compare(std::string x_n, FloatVar x, FloatVar y);
00157 #endif
00158
00159 };
00160
00161 class TextOutputI;
00162
00164 class GECODE_GIST_EXPORT TextOutput {
00165 private:
00167 TextOutputI *t;
00169 std::string n;
00170 protected:
00172 void init(void);
00174 std::ostream& getStream(void);
00176 void flush(void);
00178 void addHtml(const char* s);
00179 public:
00181 TextOutput(const std::string& name);
00183 void finalize(void);
00185 virtual ~TextOutput(void);
00187 virtual std::string name(void);
00188 };
00189
00191 template<class S>
00192 class Print : public TextOutput, public Inspector {
00193 public:
00195 Print(const std::string& name);
00197 virtual void inspect(const Space& node);
00199 virtual std::string name(void);
00201 virtual void finalize(void);
00202 };
00203
00214 template<class S>
00215 class VarComparator : public TextOutput, public Comparator {
00216 public:
00218 VarComparator(std::string name);
00220 virtual void compare(const Space& s0, const Space& s1);
00222 virtual std::string name(void);
00224 virtual void finalize(void);
00225 };
00226
00228 GECODE_GIST_EXPORT
00229 void stopBranch(Space& home);
00230
00238 class Options : public Search::Options {
00239 public:
00241 class _I {
00242 private:
00243 Support::DynamicArray<Inspector*,Heap> _click;
00244 unsigned int n_click;
00245 Support::DynamicArray<Inspector*,Heap> _solution;
00246 unsigned int n_solution;
00247 Support::DynamicArray<Inspector*,Heap> _move;
00248 unsigned int n_move;
00249 Support::DynamicArray<Comparator*,Heap> _compare;
00250 unsigned int n_compare;
00251 public:
00253 _I(void);
00255 void click(Inspector* i);
00257 void solution(Inspector* i);
00259 void move(Inspector* i);
00261 void compare(Comparator* c);
00262
00264 Inspector* click(unsigned int i) const;
00266 Inspector* solution(unsigned int i) const;
00268 Inspector* move(unsigned int i) const;
00270 Comparator* compare(unsigned int i) const;
00271 } inspect;
00273 GECODE_GIST_EXPORT static const Options def;
00275 Options(void);
00276 };
00277
00278
00280 GECODE_GIST_EXPORT int
00281 explore(Space* root, bool bab, const Options& opt);
00282
00287 int
00288 dfs(Space* root, const Gist::Options& opt = Gist::Options::def);
00289
00294 int
00295 bab(Space* root, const Gist::Options& opt = Gist::Options::def);
00296
00297 }
00298
00299 }
00300
00301 #include <gecode/gist/gist.hpp>
00302
00303 #endif
00304
00305