gist.hh
Go to the documentation of this file.
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Guido Tack, 2006
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __GECODE_GIST_HH__
#define __GECODE_GIST_HH__
#include <gecode/kernel.hh>
#include <gecode/search.hh>
#include <gecode/int.hh>
#ifdef GECODE_HAS_SET_VARS
#include <gecode/set.hh>
#endif
#ifdef GECODE_HAS_FLOAT_VARS
#include <gecode/float.hh>
#endif
/*
* Configure linking
*
*/
#if !defined(GIST_STATIC_LIBS) && \
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
#ifdef GECODE_BUILD_GIST
#define GECODE_GIST_EXPORT __declspec( dllexport )
#else
#define GECODE_GIST_EXPORT __declspec( dllimport )
#endif
#else
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
#define GECODE_GIST_EXPORT __attribute__ ((visibility("default")))
#else
#define GECODE_GIST_EXPORT
#endif
#endif
// Configure auto-linking
#ifndef GECODE_BUILD_GIST
#define GECODE_LIBRARY_NAME "Gist"
#include <gecode/support/auto-link.hpp>
#endif
#include <string>
#include <sstream>
namespace Gecode {
namespace Gist {
class GECODE_GIST_EXPORT Inspector {
public:
virtual void inspect(const Space& s) = 0;
virtual std::string name(void);
virtual void finalize(void);
virtual ~Inspector(void);
};
class GECODE_GIST_EXPORT Comparator {
public:
virtual void compare(const Space& s0, const Space& s1) = 0;
virtual std::string name(void);
virtual void finalize(void);
virtual ~Comparator(void);
template<class Var>
static std::string compare(std::string x_n, const VarArgArray<Var>& x,
const VarArgArray<Var>& y);
static std::string compare(std::string x_n, IntVar x, IntVar y);
static std::string compare(std::string x_n, BoolVar x, BoolVar y);
#ifdef GECODE_HAS_SET_VARS
static std::string compare(std::string x_n, SetVar x, SetVar y);
#endif
#ifdef GECODE_HAS_FLOAT_VARS
static std::string compare(std::string x_n, FloatVar x, FloatVar y);
#endif
};
class TextOutputI;
class GECODE_GIST_EXPORT TextOutput {
private:
TextOutputI *t;
std::string n;
protected:
void init(void);
std::ostream& getStream(void);
void flush(void);
void addHtml(const char* s);
public:
TextOutput(const std::string& name);
void finalize(void);
virtual ~TextOutput(void);
virtual std::string name(void);
};
template<class S>
class Print : public TextOutput, public Inspector {
public:
Print(const std::string& name);
virtual void inspect(const Space& node);
virtual std::string name(void);
virtual void finalize(void);
};
template<class S>
class VarComparator : public TextOutput, public Comparator {
public:
VarComparator(std::string name);
virtual void compare(const Space& s0, const Space& s1);
virtual std::string name(void);
virtual void finalize(void);
};
GECODE_GIST_EXPORT
void stopBranch(Space& home);
class Options : public Search::Options {
public:
class _I {
private:
Support::DynamicArray<Inspector*,Heap> _click;
unsigned int n_click;
Support::DynamicArray<Inspector*,Heap> _solution;
unsigned int n_solution;
Support::DynamicArray<Inspector*,Heap> _move;
unsigned int n_move;
Support::DynamicArray<Comparator*,Heap> _compare;
unsigned int n_compare;
public:
_I(void);
void click(Inspector* i);
void solution(Inspector* i);
void move(Inspector* i);
void compare(Comparator* c);
Inspector* click(unsigned int i) const;
Inspector* solution(unsigned int i) const;
Inspector* move(unsigned int i) const;
Comparator* compare(unsigned int i) const;
} inspect;
GECODE_GIST_EXPORT static const Options def;
Options(void);
};
GECODE_GIST_EXPORT int
explore(Space* root, bool bab, const Options& opt);
int
dfs(Space* root, const Gist::Options& opt = Gist::Options::def);
int
bab(Space* root, const Gist::Options& opt = Gist::Options::def);
}
}
#include <gecode/gist/gist.hpp>
#endif
// STATISTICS: gist-any
auto-link.hpp
Gecode::BoolVar
Boolean integer variables.
Definition int.hh:512
Gecode::FloatVar
Float variables.
Definition float.hh:870
Gecode::Gist::Comparator
Abstract base class for comparators.
Definition gist.hh:119
Gecode::Gist::Comparator::name
virtual std::string name(void)
Name of the comparator.
Definition gist.cpp:53
Gecode::Gist::Comparator::compare
virtual void compare(const Space &s0, const Space &s1)=0
Call-back function.
Gecode::Gist::Comparator::finalize
virtual void finalize(void)
Clean up when Gist exits.
Definition gist.cpp:56
Gecode::Gist::Gist
Gecode Interactive Search Tool
Definition qtgist.hh:81
Gecode::Gist::Inspector
Abstract base class for inspectors.
Definition gist.hh:99
Gecode::Gist::Inspector::inspect
virtual void inspect(const Space &s)=0
Call-back function.
Gecode::Gist::Inspector::finalize
virtual void finalize(void)
Clean up when Gist exits.
Definition gist.cpp:48
Gecode::Gist::Inspector::name
virtual std::string name(void)
Name of the inspector.
Definition gist.cpp:45
Gecode::Gist::Options::_I::click
void click(Inspector *i)
Add inspector that reacts on node double clicks.
Definition gist.hpp:170
Gecode::Gist::Options::_I::move
void move(Inspector *i)
Add inspector that reacts on each move of the cursor.
Definition gist.hpp:178
Gecode::Gist::Options::_I::compare
void compare(Comparator *c)
Add comparator.
Definition gist.hpp:182
Gecode::Gist::Options::_I::_I
_I(void)
Constructor.
Definition gist.hpp:165
Gecode::Gist::Options::_I::solution
void solution(Inspector *i)
Add inspector that reacts on each new solution that is found.
Definition gist.hpp:174
Gecode::Gist::Options
Options for Gist
Definition gist.hh:234
Gecode::Gist::Options::Options
Options(void)
Initialize with default values.
Definition gist.hpp:162
Gecode::Gist::Options::def
static const Options def
Default options.
Definition gist.hh:269
Gecode::Gist::Print::inspect
virtual void inspect(const Space &node)
Use the print method of the template class S to print a space.
Definition gist.hpp:141
Gecode::Gist::Print::name
virtual std::string name(void)
Return name.
Definition gist.hpp:151
Gecode::Gist::Print::finalize
virtual void finalize(void)
Clean up when Gist exits.
Definition gist.hpp:157
Gecode::Gist::Print::Print
Print(const std::string &name)
Constructor.
Definition gist.hpp:136
Gecode::Gist::TextOutputI
Window with associated ostream, used for inspecting Gist nodes.
Definition textoutput.hh:42
Gecode::Gist::TextOutput::finalize
void finalize(void)
Clean up when Gist exits.
Definition gist.cpp:64
Gecode::Gist::TextOutput::flush
void flush(void)
Flush stream.
Definition gist.cpp:90
Gecode::Gist::TextOutput::TextOutput
TextOutput(const std::string &name)
Constructor.
Definition gist.cpp:60
Gecode::Gist::TextOutput::getStream
std::ostream & getStream(void)
Get the stream that is used to output text.
Definition gist.cpp:85
Gecode::Gist::TextOutput::name
virtual std::string name(void)
Name of the inspector.
Definition gist.cpp:74
Gecode::Gist::TextOutput::init
void init(void)
Initialize the implementation object.
Definition gist.cpp:77
Gecode::Gist::TextOutput::addHtml
void addHtml(const char *s)
Add html text s to the output.
Definition gist.cpp:95
Gecode::Gist::VarComparator::VarComparator
VarComparator(std::string name)
Constructor.
Definition gist.hpp:37
Gecode::Gist::VarComparator::compare
virtual void compare(const Space &s0, const Space &s1)
Compare s0 to s1.
Definition gist.hpp:42
Gecode::Gist::VarComparator::name
virtual std::string name(void)
Return name.
Definition gist.hpp:55
Gecode::Gist::VarComparator::finalize
virtual void finalize(void)
Finalize when Gist exits.
Definition gist.hpp:61
Gecode::IntVar
Integer variables.
Definition int.hh:371
Gecode::Search::Options
Search engine options
Definition search.hh:746
Gecode::SetVar
Set variables
Definition set.hh:127
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Support::DynamicArray
Array with arbitrary number of elements.
Definition dynamic-array.hpp:44
Gecode::VarArgArray
Argument array for variables.
Definition array.hpp:774
float.hh
int.hh
set.hh
GECODE_GIST_EXPORT
#define GECODE_GIST_EXPORT
Definition gist.hh:65
gist.hpp
Gecode::Gist::bab
int bab(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for branch-and-bound search of root.
Definition gist.hpp:208
Gecode::Gist::dfs
int dfs(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for root.
Definition gist.hpp:203
kernel.hh
Gecode::Gist::explore
int explore(Space *root, bool bab, const Options &opt)
Create a new stand-alone Gist for root using bab.
Definition gist.cpp:102
Gecode::Gist::stopBranch
void stopBranch(Space &home)
A branching that stops exploration.
Definition gist.cpp:127
Gecode
Gecode toplevel namespace
search.hh