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
00047
00048
00049
00050
00051
00052 #if !defined(GIST_STATIC_LIBS) && \
00053 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00054
00055 #ifdef GECODE_BUILD_GIST
00056 #define GECODE_GIST_EXPORT __declspec( dllexport )
00057 #else
00058 #define GECODE_GIST_EXPORT __declspec( dllimport )
00059 #endif
00060
00061 #else
00062
00063 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00064 #define GECODE_GIST_EXPORT __attribute__ ((visibility("default")))
00065 #else
00066 #define GECODE_GIST_EXPORT
00067 #endif
00068
00069 #endif
00070
00071
00072 #ifndef GECODE_BUILD_GIST
00073 #define GECODE_LIBRARY_NAME "Gist"
00074 #include <gecode/support/auto-link.hpp>
00075 #endif
00076
00077 #include <string>
00078 #include <sstream>
00079
00080 namespace Gecode {
00081
00090 namespace Gist {
00091
00100 class GECODE_GIST_EXPORT Inspector {
00101 public:
00103 virtual void inspect(const Space& s) = 0;
00105 virtual std::string name(void);
00107 virtual void finalize(void);
00109 virtual ~Inspector(void);
00110 };
00111
00120 class GECODE_GIST_EXPORT Comparator {
00121 public:
00123
00124
00126 virtual void compare(const Space& s0, const Space& s1) = 0;
00128 virtual std::string name(void);
00130 virtual void finalize(void);
00132 virtual ~Comparator(void);
00133
00135
00137
00138
00140 template<class Var>
00141 static std::string compare(std::string x_n, const VarArgArray<Var>& x,
00142 const VarArgArray<Var>& y);
00144 static std::string compare(std::string x_n, IntVar x, IntVar y);
00146 static std::string compare(std::string x_n, BoolVar x, BoolVar y);
00147 #ifdef GECODE_HAS_SET_VARS
00148
00149 static std::string compare(std::string x_n, SetVar x, SetVar y);
00150 #endif
00151
00152 };
00153
00154 class TextOutputI;
00155
00157 class GECODE_GIST_EXPORT TextOutput {
00158 private:
00160 TextOutputI *t;
00162 std::string n;
00163 protected:
00165 void init(void);
00167 std::ostream& getStream(void);
00169 void flush(void);
00171 void addHtml(const char* s);
00172 public:
00174 TextOutput(const std::string& name);
00176 void finalize(void);
00178 virtual ~TextOutput(void);
00180 virtual std::string name(void);
00181 };
00182
00184 template<class S>
00185 class Print : public TextOutput, public Inspector {
00186 public:
00188 Print(const std::string& name);
00190 virtual void inspect(const Space& node);
00192 virtual std::string name(void);
00194 virtual void finalize(void);
00195 };
00196
00207 template<class S>
00208 class VarComparator : public TextOutput, public Comparator {
00209 public:
00211 VarComparator(std::string name);
00213 virtual void compare(const Space& s0, const Space& s1);
00215 virtual std::string name(void);
00217 virtual void finalize(void);
00218 };
00219
00221 GECODE_GIST_EXPORT
00222 void stopBranch(Space& home);
00223
00231 class Options : public Search::Options {
00232 public:
00234 class _I {
00235 private:
00236 Support::DynamicArray<Inspector*,Heap> _click;
00237 unsigned int n_click;
00238 Support::DynamicArray<Inspector*,Heap> _solution;
00239 unsigned int n_solution;
00240 Support::DynamicArray<Inspector*,Heap> _move;
00241 unsigned int n_move;
00242 Support::DynamicArray<Comparator*,Heap> _compare;
00243 unsigned int n_compare;
00244 public:
00246 _I(void);
00248 void click(Inspector* i);
00250 void solution(Inspector* i);
00252 void move(Inspector* i);
00254 void compare(Comparator* c);
00255
00257 Inspector* click(unsigned int i) const;
00259 Inspector* solution(unsigned int i) const;
00261 Inspector* move(unsigned int i) const;
00263 Comparator* compare(unsigned int i) const;
00264 } inspect;
00266 GECODE_GIST_EXPORT static const Options def;
00268 Options(void);
00269 };
00270
00271
00273 GECODE_GIST_EXPORT int
00274 explore(Space* root, bool bab, const Options& opt);
00275
00280 int
00281 dfs(Space* root, const Gist::Options& opt = Gist::Options::def);
00282
00287 int
00288 bab(Space* root, const Gist::Options& opt = Gist::Options::def);
00289
00290 }
00291
00292 }
00293
00294 #include <gecode/gist/gist.hpp>
00295
00296 #endif
00297
00298