Generated on Tue May 22 09:39:52 2018 for Gecode by doxygen 1.6.3

gist.hh

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2006
00007  *
00008  *  This file is part of Gecode, the generic constraint
00009  *  development environment:
00010  *     http://www.gecode.org
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining
00013  * a copy of this software and associated documentation files (the
00014  * "Software"), to deal in the Software without restriction, including
00015  * without limitation the rights to use, copy, modify, merge, publish,
00016  * distribute, sublicense, and/or sell copies of the Software, and to
00017  * permit persons to whom the Software is furnished to do so, subject to
00018  * the following conditions:
00019  *
00020  * The above copyright notice and this permission notice shall be
00021  * included in all copies or substantial portions of the Software.
00022  *
00023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00027  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00028  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00029  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030  *
00031  */
00032 
00033 #ifndef __GECODE_GIST_HH__
00034 #define __GECODE_GIST_HH__
00035 
00036 #include <gecode/kernel.hh>
00037 #include <gecode/search.hh>
00038 #include <gecode/int.hh>
00039 #ifdef GECODE_HAS_SET_VARS
00040 #include <gecode/set.hh>
00041 #endif
00042 #ifdef GECODE_HAS_FLOAT_VARS
00043 #include <gecode/float.hh>
00044 #endif
00045 
00046 /*
00047  * Configure linking
00048  *
00049  */
00050 
00051 #if !defined(GIST_STATIC_LIBS) && \
00052     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00053 
00054 #ifdef GECODE_BUILD_GIST
00055 #define GECODE_GIST_EXPORT __declspec( dllexport )
00056 #else
00057 #define GECODE_GIST_EXPORT __declspec( dllimport )
00058 #endif
00059 
00060 #else
00061 
00062 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00063 #define GECODE_GIST_EXPORT __attribute__ ((visibility("default")))
00064 #else
00065 #define GECODE_GIST_EXPORT
00066 #endif
00067 
00068 #endif
00069 
00070 // Configure auto-linking
00071 #ifndef GECODE_BUILD_GIST
00072 #define GECODE_LIBRARY_NAME "Gist"
00073 #include <gecode/support/auto-link.hpp>
00074 #endif
00075 
00076 #include <string>
00077 #include <sstream>
00078 
00079 namespace Gecode {
00080 
00089   namespace Gist {
00090 
00099     class GECODE_GIST_EXPORT Inspector {
00100     public:
00102       virtual void inspect(const Space& s) = 0;
00104       virtual std::string name(void);
00106       virtual void finalize(void);
00108       virtual ~Inspector(void);
00109     };
00110 
00119     class GECODE_GIST_EXPORT Comparator {
00120     public:
00122 
00123 
00125       virtual void compare(const Space& s0, const Space& s1) = 0;
00127       virtual std::string name(void);
00129       virtual void finalize(void);
00131       virtual ~Comparator(void);
00132 
00134 
00136 
00137 
00139       template<class Var>
00140       static std::string compare(std::string x_n, const VarArgArray<Var>& x,
00141         const VarArgArray<Var>& y);
00143       static std::string compare(std::string x_n, IntVar x, IntVar y);
00145       static std::string compare(std::string x_n, BoolVar x, BoolVar y);
00146 #ifdef GECODE_HAS_SET_VARS
00147 
00148       static std::string compare(std::string x_n, SetVar x, SetVar y);
00149 #endif
00150 #ifdef GECODE_HAS_FLOAT_VARS
00151 
00152       static std::string compare(std::string x_n, FloatVar x, FloatVar y);
00153 #endif
00154 
00155     };
00156 
00157     class TextOutputI;
00158 
00160     class GECODE_GIST_EXPORT TextOutput {
00161     private:
00163       TextOutputI *t;
00165       std::string n;
00166     protected:
00168       void init(void);
00170       std::ostream& getStream(void);
00172       void flush(void);
00174       void addHtml(const char* s);
00175     public:
00177       TextOutput(const std::string& name);
00179       void finalize(void);
00181       virtual ~TextOutput(void);
00183       virtual std::string name(void);
00184     };
00185 
00187     template<class S>
00188     class Print : public TextOutput, public Inspector {
00189     public:
00191       Print(const std::string& name);
00193       virtual void inspect(const Space& node);
00195       virtual std::string name(void);
00197       virtual void finalize(void);
00198     };
00199 
00210     template<class S>
00211     class VarComparator : public TextOutput, public Comparator {
00212     public:
00214       VarComparator(std::string name);
00216       virtual void compare(const Space& s0, const Space& s1);
00218       virtual std::string name(void);
00220       virtual void finalize(void);
00221     };
00222 
00224     GECODE_GIST_EXPORT
00225     void stopBranch(Space& home);
00226 
00234     class Options : public Search::Options {
00235     public:
00237       class _I {
00238       private:
00239         Support::DynamicArray<Inspector*,Heap> _click;
00240         unsigned int n_click;
00241         Support::DynamicArray<Inspector*,Heap> _solution;
00242         unsigned int n_solution;
00243         Support::DynamicArray<Inspector*,Heap> _move;
00244         unsigned int n_move;
00245         Support::DynamicArray<Comparator*,Heap> _compare;
00246         unsigned int n_compare;
00247       public:
00249         _I(void);
00251         void click(Inspector* i);
00253         void solution(Inspector* i);
00255         void move(Inspector* i);
00257         void compare(Comparator* c);
00258 
00260         Inspector* click(unsigned int i) const;
00262         Inspector* solution(unsigned int i) const;
00264         Inspector* move(unsigned int i) const;
00266         Comparator* compare(unsigned int i) const;
00267       } inspect;
00269       GECODE_GIST_EXPORT static const Options def;
00271       Options(void);
00272     };
00273 
00274 
00276     GECODE_GIST_EXPORT int
00277     explore(Space* root, bool bab, const Options& opt);
00278 
00283     int
00284     dfs(Space* root, const Gist::Options& opt = Gist::Options::def);
00285 
00290     int
00291     bab(Space* root, const Gist::Options& opt = Gist::Options::def);
00292 
00293   }
00294 
00295 }
00296 
00297 #include <gecode/gist/gist.hpp>
00298 
00299 #endif
00300 
00301 // STATISTICS: gist-any