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 addHtml(const char* s);
00170 public:
00172 TextOutput(const std::string& name);
00174 void finalize(void);
00176 virtual ~TextOutput(void);
00178 virtual std::string name(void);
00179 };
00180
00182 template<class S>
00183 class Print : public TextOutput, public Inspector {
00184 public:
00186 Print(const std::string& name);
00188 virtual void inspect(const Space& node);
00190 virtual std::string name(void);
00192 virtual void finalize(void);
00193 };
00194
00205 template<class S>
00206 class VarComparator : public TextOutput, public Comparator {
00207 public:
00209 VarComparator(std::string name);
00211 virtual void compare(const Space& s0, const Space& s1);
00213 virtual std::string name(void);
00215 virtual void finalize(void);
00216 };
00217
00219 GECODE_GIST_EXPORT
00220 void stopBranch(Space& home);
00221
00229 class Options : public Search::Options {
00230 public:
00232 class _I {
00233 private:
00234 Support::DynamicArray<Inspector*,Heap> _click;
00235 unsigned int n_click;
00236 Support::DynamicArray<Inspector*,Heap> _solution;
00237 unsigned int n_solution;
00238 Support::DynamicArray<Inspector*,Heap> _move;
00239 unsigned int n_move;
00240 Support::DynamicArray<Comparator*,Heap> _compare;
00241 unsigned int n_compare;
00242 public:
00244 _I(void);
00246 void click(Inspector* i);
00248 void solution(Inspector* i);
00250 void move(Inspector* i);
00252 void compare(Comparator* c);
00253
00255 Inspector* click(unsigned int i) const;
00257 Inspector* solution(unsigned int i) const;
00259 Inspector* move(unsigned int i) const;
00261 Comparator* compare(unsigned int i) const;
00262 } inspect;
00264 GECODE_GIST_EXPORT static const Options def;
00266 Options(void);
00267 };
00268
00269
00271 GECODE_GIST_EXPORT int
00272 explore(Space* root, bool bab, const Options& opt);
00273
00278 int
00279 dfs(Space* root, const Gist::Options& opt = Gist::Options::def);
00280
00285 int
00286 bab(Space* root, const Gist::Options& opt = Gist::Options::def);
00287
00288 }
00289
00290 }
00291
00292 #include <gecode/gist/gist.hpp>
00293
00294 #endif
00295
00296