main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:02 for Gecode by
doxygen
1.8.4
test
int.hh
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
* Mikael Lagerkvist <lagerkvist@gecode.org>
6
*
7
* Copyright:
8
* Christian Schulte, 2005
9
* Mikael Lagerkvist, 2006
10
*
11
* Last modified:
12
* $Date: 2013-02-06 15:10:02 +0100 (Wed, 06 Feb 2013) $ by $Author: schulte $
13
* $Revision: 13270 $
14
*
15
* This file is part of Gecode, the generic constraint
16
* development environment:
17
* http://www.gecode.org
18
*
19
* Permission is hereby granted, free of charge, to any person obtaining
20
* a copy of this software and associated documentation files (the
21
* "Software"), to deal in the Software without restriction, including
22
* without limitation the rights to use, copy, modify, merge, publish,
23
* distribute, sublicense, and/or sell copies of the Software, and to
24
* permit persons to whom the Software is furnished to do so, subject to
25
* the following conditions:
26
*
27
* The above copyright notice and this permission notice shall be
28
* included in all copies or substantial portions of the Software.
29
*
30
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
*
38
*/
39
40
#ifndef __GECODE_TEST_INT_HH__
41
#define __GECODE_TEST_INT_HH__
42
43
#include "
test/test.hh
"
44
45
#include <
gecode/int.hh
>
46
47
namespace
Test {
48
50
namespace
Int {
51
62
class
Assignment {
64
protected
:
65
int
n
;
66
Gecode::IntSet
d
;
67
public
:
69
Assignment
(
int
n0,
const
Gecode::IntSet
& d0);
71
virtual
bool
operator()
(
void
)
const
= 0;
73
virtual
void
operator++
(
void
) = 0;
75
virtual
int
operator[]
(
int
i
)
const
= 0;
77
int
size
(
void
)
const
;
79
virtual
~Assignment
(
void
);
80
};
81
83
class
CpltAssignment
:
public
Assignment
{
84
protected
:
85
Gecode::IntSetValues
*
dsv
;
86
public
:
88
CpltAssignment
(
int
n
,
const
Gecode::IntSet
&
d
);
90
virtual
bool
operator()
(
void
)
const
;
92
virtual
void
operator++
(
void
);
94
virtual
int
operator[]
(
int
i
)
const
;
96
virtual
~CpltAssignment
(
void
);
97
};
98
100
class
RandomAssignment
:
public
Assignment
{
101
protected
:
102
int
*
vals
;
103
int
a
;
104
int
randval
(
void
);
106
public
:
108
RandomAssignment
(
int
n
,
const
Gecode::IntSet
&
d
,
int
a
);
110
virtual
bool
operator()
(
void
)
const
;
112
virtual
void
operator++
(
void
);
114
virtual
int
operator[]
(
int
i
)
const
;
116
virtual
~RandomAssignment
(
void
);
117
};
118
120
class
RandomMixAssignment
:
public
Assignment
{
121
protected
:
122
int
*
vals
;
123
int
a
;
124
int
_n1
;
125
Gecode::IntSet
_d1
;
126
int
randval
(
const
Gecode::IntSet
&
d
);
128
public
:
130
RandomMixAssignment
(
int
n0,
const
Gecode::IntSet
& d0,
131
int
n1,
const
Gecode::IntSet
&
d1
,
int
a0);
133
virtual
bool
operator()
(
void
)
const
;
135
virtual
void
operator++
(
void
);
137
virtual
int
operator[]
(
int
i
)
const
;
139
virtual
~RandomMixAssignment
(
void
);
140
};
141
143
enum
ConTestLevel
{
144
CTL_NONE
,
145
CTL_DOMAIN
,
146
CTL_BOUNDS_D
,
147
CTL_BOUNDS_Z
,
148
};
149
150
class
Test;
151
153
class
TestSpace
:
public
Gecode::Space
{
154
public
:
156
Gecode::IntSet
d
;
158
Gecode::IntVarArray
x
;
160
Gecode::Reify
r
;
162
Test
*
test
;
164
bool
reified
;
165
172
TestSpace
(
int
n
,
Gecode::IntSet
&
d
,
Test
*
t
);
180
TestSpace
(
int
n
,
Gecode::IntSet
&
d
,
Test
*
t
,
Gecode::ReifyMode
rm);
182
TestSpace
(
bool
share,
TestSpace
& s);
184
virtual
Gecode::Space
*
copy
(
bool
share);
186
bool
assigned
(
void
)
const
;
188
void
post
(
void
);
190
bool
failed
(
void
);
192
void
rel
(
int
i
,
Gecode::IntRelType
irt,
int
n
);
194
void
rel
(
bool
sol);
196
void
assign
(
const
Assignment
&
a
,
bool
skip=
false
);
198
void
bound
(
void
);
204
void
prune
(
int
i
,
bool
bounds_only);
206
void
prune
(
void
);
208
bool
prune
(
const
Assignment
&
a
,
bool
testfix);
209
};
210
215
class
Test
:
public
Base
{
216
protected
:
218
int
arity
;
220
Gecode::IntSet
dom
;
222
bool
reified
;
224
int
rms
;
226
Gecode::IntConLevel
icl
;
228
ConTestLevel
contest
;
230
bool
testsearch
;
232
bool
testfix
;
234
235
bool
eqv
(
void
)
const
;
238
bool
imp
(
void
)
const
;
240
bool
pmi
(
void
)
const
;
242
public
:
251
Test
(
const
std::string&
p
,
const
std::string& s,
252
int
a
,
const
Gecode::IntSet
&
d
,
bool
r
=
false
,
253
Gecode::IntConLevel
i
=
Gecode::ICL_DEF
);
262
Test
(
const
std::string& s,
263
int
a
,
const
Gecode::IntSet
&
d
,
bool
r
=
false
,
264
Gecode::IntConLevel
i
=
Gecode::ICL_DEF
);
273
Test
(
const
std::string&
p
,
const
std::string& s,
274
int
a
,
int
min
,
int
max
,
bool
r
=
false
,
275
Gecode::IntConLevel
i
=
Gecode::ICL_DEF
);
284
Test
(
const
std::string& s,
285
int
a
,
int
min
,
int
max
,
bool
r
=
false
,
286
Gecode::IntConLevel
i
=
Gecode::ICL_DEF
);
288
virtual
Assignment
*
assignment
(
void
)
const
;
290
virtual
bool
solution
(
const
Assignment
&)
const
= 0;
292
virtual
bool
ignore
(
const
Assignment
&)
const
;
294
virtual
void
post
(
Gecode::Space
& home,
Gecode::IntVarArray
&
x
) = 0;
296
virtual
void
post
(
Gecode::Space
& home,
Gecode::IntVarArray
&
x
,
297
Gecode::Reify
r
);
299
virtual
bool
run
(
void
);
301
302
static
std::string
str
(
Gecode::ExtensionalPropKind
epk);
305
static
std::string
str
(
Gecode::IntConLevel
icl
);
307
static
std::string
str
(
Gecode::IntRelType
irl);
309
static
std::string
str
(
Gecode::BoolOpType
bot);
311
static
std::string
str
(
int
i
);
313
static
std::string
str
(
const
Gecode::IntArgs
&
i
);
315
317
template
<
class
T>
static
bool
cmp
(T
x
,
Gecode::IntRelType
r
, T y);
320
};
322
324
class
IntConLevels
{
325
private
:
327
static
const
Gecode::IntConLevel
icls[3];
329
int
i;
330
public
:
332
IntConLevels
(
void
);
334
bool
operator()
(
void
)
const
;
336
void
operator++
(
void
);
338
Gecode::IntConLevel
icl
(
void
)
const
;
339
};
340
342
class
IntRelTypes
{
343
private
:
345
static
const
Gecode::IntRelType
irts[6];
347
int
i;
348
public
:
350
IntRelTypes
(
void
);
352
void
reset
(
void
);
354
bool
operator()
(
void
)
const
;
356
void
operator++
(
void
);
358
Gecode::IntRelType
irt
(
void
)
const
;
359
};
360
362
class
BoolOpTypes
{
363
private
:
365
static
const
Gecode::BoolOpType
bots[5];
367
int
i;
368
public
:
370
BoolOpTypes
(
void
);
372
bool
operator()
(
void
)
const
;
374
void
operator++
(
void
);
376
Gecode::BoolOpType
bot
(
void
)
const
;
377
};
378
379
}
380
}
381
386
std::ostream&
operator<<
(std::ostream& os,
const
Test::Int::Assignment
&
a
);
387
388
#include "
test/int.hpp
"
389
390
#endif
391
392
// STATISTICS: test-int
393