main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:02 for Gecode by
doxygen
1.8.4
gecode
gist.hh
Go to the documentation of this file.
1
/*
2
* Main authors:
3
* Guido Tack <tack@gecode.org>
4
*
5
* Copyright:
6
* Guido Tack, 2006
7
*
8
* Last modified:
9
* $Date: 2012-03-30 05:58:02 +0200 (Fri, 30 Mar 2012) $ by $Author: tack $
10
* $Revision: 12665 $
11
*
12
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
15
*
16
* Permission is hereby granted, free of charge, to any person obtaining
17
* a copy of this software and associated documentation files (the
18
* "Software"), to deal in the Software without restriction, including
19
* without limitation the rights to use, copy, modify, merge, publish,
20
* distribute, sublicense, and/or sell copies of the Software, and to
21
* permit persons to whom the Software is furnished to do so, subject to
22
* the following conditions:
23
*
24
* The above copyright notice and this permission notice shall be
25
* included in all copies or substantial portions of the Software.
26
*
27
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
*
35
*/
36
37
#ifndef __GECODE_GIST_HH__
38
#define __GECODE_GIST_HH__
39
40
#include <
gecode/kernel.hh
>
41
#include <
gecode/search.hh
>
42
#include <
gecode/int.hh
>
43
#ifdef GECODE_HAS_SET_VARS
44
#include <
gecode/set.hh
>
45
#endif
46
#ifdef GECODE_HAS_FLOAT_VARS
47
#include <
gecode/float.hh
>
48
#endif
49
50
/*
51
* Configure linking
52
*
53
*/
54
55
#if !defined(GIST_STATIC_LIBS) && \
56
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
57
58
#ifdef GECODE_BUILD_GIST
59
#define GECODE_GIST_EXPORT __declspec( dllexport )
60
#else
61
#define GECODE_GIST_EXPORT __declspec( dllimport )
62
#endif
63
64
#else
65
66
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
67
#define GECODE_GIST_EXPORT __attribute__ ((visibility("default")))
68
#else
69
#define GECODE_GIST_EXPORT
70
#endif
71
72
#endif
73
74
// Configure auto-linking
75
#ifndef GECODE_BUILD_GIST
76
#define GECODE_LIBRARY_NAME "Gist"
77
#include <
gecode/support/auto-link.hpp
>
78
#endif
79
80
#include <string>
81
#include <sstream>
82
83
namespace
Gecode {
84
93
namespace
Gist {
94
103
class
GECODE_GIST_EXPORT
Inspector
{
104
public
:
106
virtual
void
inspect(
const
Space
& s) = 0;
108
virtual
std::string name(
void
);
110
virtual
void
finalize(
void
);
112
virtual
~
Inspector
(
void
);
113
};
114
123
class
GECODE_GIST_EXPORT
Comparator
{
124
public
:
126
129
virtual
void
compare
(
const
Space
& s0,
const
Space
& s1) = 0;
131
virtual
std::string name(
void
);
133
virtual
void
finalize(
void
);
135
virtual
~
Comparator
(
void
);
136
138
140
143
template
<
class
Var>
144
static
std::string
compare
(std::string x_n,
const
VarArgArray<Var>
&
x
,
145
const
VarArgArray<Var>
& y);
147
static
std::string
compare
(std::string x_n,
IntVar
x,
IntVar
y);
149
static
std::string
compare
(std::string x_n,
BoolVar
x,
BoolVar
y);
150
#ifdef GECODE_HAS_SET_VARS
151
static
std::string
compare
(std::string x_n,
SetVar
x,
SetVar
y);
153
#endif
154
#ifdef GECODE_HAS_FLOAT_VARS
155
static
std::string
compare
(std::string x_n,
FloatVar
x,
FloatVar
y);
157
#endif
158
159
};
160
161
class
TextOutputI
;
162
164
class
GECODE_GIST_EXPORT
TextOutput
{
165
private
:
167
TextOutputI
*
t
;
169
std::string
n
;
170
protected
:
172
void
init(
void
);
174
std::ostream& getStream(
void
);
176
void
flush(
void
);
178
void
addHtml(
const
char
* s);
179
public
:
181
TextOutput
(
const
std::string& name);
183
void
finalize(
void
);
185
virtual
~
TextOutput
(
void
);
187
virtual
std::string name(
void
);
188
};
189
191
template
<
class
S>
192
class
Print
:
public
TextOutput
,
public
Inspector
{
193
public
:
195
Print
(
const
std::string&
name
);
197
virtual
void
inspect
(
const
Space
& node);
199
virtual
std::string
name
(
void
);
201
virtual
void
finalize
(
void
);
202
};
203
214
template
<
class
S>
215
class
VarComparator
:
public
TextOutput
,
public
Comparator
{
216
public
:
218
VarComparator
(std::string
name
);
220
virtual
void
compare
(
const
Space
& s0,
const
Space
& s1);
222
virtual
std::string
name
(
void
);
224
virtual
void
finalize
(
void
);
225
};
226
228
GECODE_GIST_EXPORT
229
void
stopBranch
(
Space
& home);
230
238
class
Options
:
public
Search::Options
{
239
public
:
241
class
_I
{
242
private
:
243
Support::DynamicArray<Inspector*,Heap>
_click;
244
unsigned
int
n_click;
245
Support::DynamicArray<Inspector*,Heap>
_solution;
246
unsigned
int
n_solution;
247
Support::DynamicArray<Inspector*,Heap>
_move;
248
unsigned
int
n_move;
249
Support::DynamicArray<Comparator*,Heap>
_compare;
250
unsigned
int
n_compare;
251
public
:
253
_I
(
void
);
255
void
click
(
Inspector
*
i
);
257
void
solution
(
Inspector
* i);
259
void
move
(
Inspector
* i);
261
void
compare
(
Comparator
*
c
);
262
264
Inspector
*
click
(
unsigned
int
i)
const
;
266
Inspector
*
solution
(
unsigned
int
i)
const
;
268
Inspector
*
move
(
unsigned
int
i)
const
;
270
Comparator
*
compare
(
unsigned
int
i)
const
;
271
}
inspect
;
273
GECODE_GIST_EXPORT
static
const
Options
def
;
275
Options
(
void
);
276
};
277
278
280
GECODE_GIST_EXPORT
int
281
explore
(
Space
* root,
bool
bab
,
const
Options
&
opt
);
282
287
int
288
dfs
(
Space
* root,
const
Gist::Options
&
opt
=
Gist::Options::def
);
289
294
int
295
bab
(
Space
* root,
const
Gist::Options
&
opt
=
Gist::Options::def
);
296
297
}
298
299
}
300
301
#include <
gecode/gist/gist.hpp
>
302
303
#endif
304
305
// STATISTICS: gist-any