main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Aug 24 2012 04:52:06 for Gecode by
doxygen
1.8.1.2
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: 2011-08-25 18:43:31 +1000 (Thu, 25 Aug 2011) $ by $Author: tack $
10
* $Revision: 12352 $
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
47
/*
48
* Configure linking
49
*
50
*/
51
52
#if !defined(GIST_STATIC_LIBS) && \
53
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
54
55
#ifdef GECODE_BUILD_GIST
56
#define GECODE_GIST_EXPORT __declspec( dllexport )
57
#else
58
#define GECODE_GIST_EXPORT __declspec( dllimport )
59
#endif
60
61
#else
62
63
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
64
#define GECODE_GIST_EXPORT __attribute__ ((visibility("default")))
65
#else
66
#define GECODE_GIST_EXPORT
67
#endif
68
69
#endif
70
71
// Configure auto-linking
72
#ifndef GECODE_BUILD_GIST
73
#define GECODE_LIBRARY_NAME "Gist"
74
#include <
gecode/support/auto-link.hpp
>
75
#endif
76
77
#include <string>
78
#include <sstream>
79
80
namespace
Gecode {
81
90
namespace
Gist {
91
100
class
GECODE_GIST_EXPORT
Inspector
{
101
public
:
103
virtual
void
inspect(
const
Space
& s) = 0;
105
virtual
std::string name(
void
);
107
virtual
void
finalize(
void
);
109
virtual
~
Inspector
(
void
);
110
};
111
120
class
GECODE_GIST_EXPORT
Comparator
{
121
public
:
123
124
126
virtual
void
compare
(
const
Space
& s0,
const
Space
& s1) = 0;
128
virtual
std::string name(
void
);
130
virtual
void
finalize(
void
);
132
virtual
~
Comparator
(
void
);
133
135
137
138
140
template
<
class
Var>
141
static
std::string
compare
(std::string x_n,
const
VarArgArray<Var>
& x,
142
const
VarArgArray<Var>
& y);
144
static
std::string
compare
(std::string x_n,
IntVar
x,
IntVar
y);
146
static
std::string
compare
(std::string x_n,
BoolVar
x,
BoolVar
y);
147
#ifdef GECODE_HAS_SET_VARS
148
149
static
std::string
compare
(std::string x_n,
SetVar
x,
SetVar
y);
150
#endif
151
152
};
153
154
class
TextOutputI
;
155
157
class
GECODE_GIST_EXPORT
TextOutput
{
158
private
:
160
TextOutputI
*t;
162
std::string n;
163
protected
:
165
void
init(
void
);
167
std::ostream& getStream(
void
);
169
void
flush(
void
);
171
void
addHtml(
const
char
* s);
172
public
:
174
TextOutput
(
const
std::string& name);
176
void
finalize(
void
);
178
virtual
~
TextOutput
(
void
);
180
virtual
std::string name(
void
);
181
};
182
184
template
<
class
S>
185
class
Print
:
public
TextOutput
,
public
Inspector
{
186
public
:
188
Print
(
const
std::string&
name
);
190
virtual
void
inspect
(
const
Space
& node);
192
virtual
std::string
name
(
void
);
194
virtual
void
finalize
(
void
);
195
};
196
207
template
<
class
S>
208
class
VarComparator
:
public
TextOutput
,
public
Comparator
{
209
public
:
211
VarComparator
(std::string
name
);
213
virtual
void
compare
(
const
Space
& s0,
const
Space
& s1);
215
virtual
std::string
name
(
void
);
217
virtual
void
finalize
(
void
);
218
};
219
221
GECODE_GIST_EXPORT
222
void
stopBranch
(
Space
& home);
223
231
class
Options
:
public
Search::Options
{
232
public
:
234
class
_I
{
235
private
:
236
Support::DynamicArray<Inspector*,Heap>
_click;
237
unsigned
int
n_click;
238
Support::DynamicArray<Inspector*,Heap>
_solution;
239
unsigned
int
n_solution;
240
Support::DynamicArray<Inspector*,Heap>
_move;
241
unsigned
int
n_move;
242
Support::DynamicArray<Comparator*,Heap>
_compare;
243
unsigned
int
n_compare;
244
public
:
246
_I
(
void
);
248
void
click
(
Inspector
*
i
);
250
void
solution
(
Inspector
* i);
252
void
move
(
Inspector
* i);
254
void
compare
(
Comparator
*
c
);
255
257
Inspector
*
click
(
unsigned
int
i)
const
;
259
Inspector
*
solution
(
unsigned
int
i)
const
;
261
Inspector
*
move
(
unsigned
int
i)
const
;
263
Comparator
*
compare
(
unsigned
int
i)
const
;
264
}
inspect
;
266
GECODE_GIST_EXPORT
static
const
Options
def
;
268
Options
(
void
);
269
};
270
271
273
GECODE_GIST_EXPORT
int
274
explore
(
Space
* root,
bool
bab
,
const
Options
&
opt
);
275
280
int
281
dfs
(
Space
* root,
const
Gist::Options
&
opt
=
Gist::Options::def
);
282
287
int
288
bab
(
Space
* root,
const
Gist::Options
&
opt
=
Gist::Options::def
);
289
290
}
291
292
}
293
294
#include <
gecode/gist/gist.hpp
>
295
296
#endif
297
298
// STATISTICS: gist-any