main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Sep 17 2012 22:20:34 for Gecode by
doxygen
1.8.1.1
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: 2010-06-03 21:11:11 +1000 (Thu, 03 Jun 2010) $ by $Author: tack $
13
* $Revision: 11013 $
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
63
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
105
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
127
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::BoolVar
b
;
162
bool
reified
;
164
Test
*
test
;
165
174
TestSpace
(
int
n,
Gecode::IntSet
& d0,
bool
r
,
Test
* t,
bool
log=
true
);
176
TestSpace
(
bool
share,
TestSpace
& s);
178
virtual
Gecode::Space
*
copy
(
bool
share);
180
bool
assigned
(
void
)
const
;
182
void
post
(
void
);
184
bool
failed
(
void
);
186
void
rel
(
int
i
,
Gecode::IntRelType
irt,
int
n);
188
void
rel
(
bool
sol);
190
void
assign
(
const
Assignment
&
a
,
bool
skip=
false
);
192
void
bound
(
void
);
198
void
prune
(
int
i
,
bool
bounds_only);
200
void
prune
(
void
);
202
bool
prune
(
const
Assignment
&
a
,
bool
testfix);
203
};
204
209
class
Test
:
public
Base
{
210
protected
:
212
int
arity
;
214
Gecode::IntSet
dom
;
216
bool
reified
;
218
Gecode::IntConLevel
icl
;
220
ConTestLevel
contest
;
222
bool
testsearch
;
224
bool
testfix
;
225
226
public
:
235
Test
(
const
std::string& s,
int
a
,
const
Gecode::IntSet
&
d
,
bool
r
=
false
,
236
Gecode::IntConLevel
i
=
Gecode::ICL_DEF
);
245
Test
(
const
std::string& s,
int
a
,
int
min
,
int
max
,
bool
r
=
false
,
246
Gecode::IntConLevel
i
=
Gecode::ICL_DEF
);
248
virtual
Assignment
*
assignment
(
void
)
const
;
250
virtual
bool
solution
(
const
Assignment
&)
const
= 0;
252
virtual
bool
ignore
(
const
Assignment
&)
const
;
254
virtual
void
post
(
Gecode::Space
& home,
Gecode::IntVarArray
& x) = 0;
256
virtual
void
post
(
Gecode::Space
& home,
Gecode::IntVarArray
& x,
257
Gecode::BoolVar
b
);
259
virtual
bool
run
(
void
);
261
262
263
static
std::string
str
(
Gecode::ExtensionalPropKind
epk);
265
static
std::string
str
(
Gecode::IntConLevel
icl
);
267
static
std::string
str
(
Gecode::IntRelType
irl);
269
static
std::string
str
(
Gecode::BoolOpType
bot);
271
static
std::string
str
(
int
i
);
273
static
std::string
str
(
const
Gecode::IntArgs
&
i
);
275
276
277
278
template
<
class
T>
static
bool
cmp
(T x,
Gecode::IntRelType
r
, T y);
280
};
282
284
class
IntConLevels
{
285
private
:
287
static
const
Gecode::IntConLevel
icls[3];
289
int
i;
290
public
:
292
IntConLevels
(
void
);
294
bool
operator()
(
void
)
const
;
296
void
operator++
(
void
);
298
Gecode::IntConLevel
icl
(
void
)
const
;
299
};
300
302
class
IntRelTypes
{
303
private
:
305
static
const
Gecode::IntRelType
irts[6];
307
int
i;
308
public
:
310
IntRelTypes
(
void
);
312
void
reset
(
void
);
314
bool
operator()
(
void
)
const
;
316
void
operator++
(
void
);
318
Gecode::IntRelType
irt
(
void
)
const
;
319
};
320
322
class
BoolOpTypes
{
323
private
:
325
static
const
Gecode::BoolOpType
bots[5];
327
int
i;
328
public
:
330
BoolOpTypes
(
void
);
332
bool
operator()
(
void
)
const
;
334
void
operator++
(
void
);
336
Gecode::BoolOpType
bot
(
void
)
const
;
337
};
338
339
}
340
}
341
346
std::ostream&
operator<<
(std::ostream& os,
const
Test::Int::Assignment
&
a
);
347
348
#include "
test/int.hpp
"
349
350
#endif
351
352
// STATISTICS: test-int
353