main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:25 for Gecode by
doxygen
1.8.4
test
float.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
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
7
*
8
* Copyright:
9
* Christian Schulte, 2005
10
* Mikael Lagerkvist, 2006
11
* Vincent Barichard, 2012
12
*
13
* Last modified:
14
* $Date: 2013-02-04 22:41:43 +0100 (Mon, 04 Feb 2013) $ by $Author: schulte $
15
* $Revision: 13264 $
16
*
17
* This file is part of Gecode, the generic constraint
18
* development environment:
19
* http://www.gecode.org
20
*
21
* Permission is hereby granted, free of charge, to any person obtaining
22
* a copy of this software and associated documentation files (the
23
* "Software"), to deal in the Software without restriction, including
24
* without limitation the rights to use, copy, modify, merge, publish,
25
* distribute, sublicense, and/or sell copies of the Software, and to
26
* permit persons to whom the Software is furnished to do so, subject to
27
* the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be
30
* included in all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
*
40
*/
41
42
#ifndef __GECODE_TEST_FLOAT_HH__
43
#define __GECODE_TEST_FLOAT_HH__
44
45
#include "
test/test.hh
"
46
47
#include <
gecode/float.hh
>
48
49
namespace
Test {
50
52
namespace
Float {
53
55
enum
MaybeType
{
56
MT_FALSE
= 0,
//< Does hold
57
MT_TRUE
,
//< Does not hold
58
MT_MAYBE
//< Might or might not hold
59
};
60
62
MaybeType
operator &
(
MaybeType
a
,
MaybeType
b
);
63
65
enum
AssignmentType
{
66
CPLT_ASSIGNMENT
= 0,
67
RANDOM_ASSIGNMENT
,
68
EXTEND_ASSIGNMENT
69
};
70
71
class
Test;
72
83
class
Assignment {
85
protected
:
86
int
n
;
87
Gecode::FloatVal
d
;
88
public
:
90
Assignment
(
int
n0,
const
Gecode::FloatVal
& d0);
92
virtual
bool
operator()
(
void
)
const
= 0;
94
virtual
void
operator++
(
void
) = 0;
96
virtual
Gecode::FloatVal
operator[]
(
int
i
)
const
= 0;
98
virtual
void
set
(
int
i
,
const
Gecode::FloatVal
& val) = 0;
100
int
size
(
void
)
const
;
102
virtual
~Assignment
(
void
);
103
};
104
106
class
CpltAssignment
:
public
Assignment
{
107
protected
:
108
Gecode::FloatVal
*
dsv
;
109
Gecode::FloatNum
step
;
110
public
:
112
CpltAssignment
(
int
n
,
const
Gecode::FloatVal
&
d
,
Gecode::FloatNum
s);
114
virtual
bool
operator()
(
void
)
const
;
116
virtual
void
operator++
(
void
);
118
virtual
Gecode::FloatVal
operator[]
(
int
i
)
const
;
120
virtual
void
set
(
int
i
,
const
Gecode::FloatVal
& val);
122
virtual
~CpltAssignment
(
void
);
123
};
124
126
class
ExtAssignment
:
public
Assignment
{
127
protected
:
128
const
Test
*
curPb
;
129
Gecode::FloatVal
*
dsv
;
130
Gecode::FloatNum
step
;
131
public
:
133
ExtAssignment
(
int
n
,
const
Gecode::FloatVal
&
d
,
Gecode::FloatNum
s,
const
Test
* pb);
135
virtual
bool
operator()
(
void
)
const
;
137
virtual
void
operator++
(
void
);
139
virtual
Gecode::FloatVal
operator[]
(
int
i
)
const
;
141
virtual
void
set
(
int
i
,
const
Gecode::FloatVal
& val);
143
virtual
~ExtAssignment
(
void
);
144
};
145
146
148
class
RandomAssignment
:
public
Assignment
{
149
protected
:
150
Gecode::FloatVal
*
vals
;
151
int
a
;
152
Gecode::FloatNum
randval
(
void
);
154
public
:
156
RandomAssignment
(
int
n
,
const
Gecode::FloatVal
&
d
,
int
a
);
158
virtual
bool
operator()
(
void
)
const
;
160
virtual
void
operator++
(
void
);
162
virtual
Gecode::FloatVal
operator[]
(
int
i
)
const
;
164
virtual
void
set
(
int
i
,
const
Gecode::FloatVal
& val);
166
virtual
~RandomAssignment
(
void
);
167
};
168
170
class
TestSpace
:
public
Gecode::Space
{
171
public
:
173
Gecode::FloatVal
d
;
175
Gecode::FloatNum
step
;
177
Gecode::FloatVarArray
x
;
179
Gecode::Reify
r
;
181
Test
*
test
;
183
bool
reified
;
184
192
TestSpace
(
int
n
,
Gecode::FloatVal
&
d
,
Gecode::FloatNum
s,
Test
*
t
);
200
TestSpace
(
int
n
,
Gecode::FloatVal
&
d
,
Gecode::FloatNum
s,
Test
*
t
,
201
Gecode::ReifyMode
rm);
203
TestSpace
(
bool
share,
TestSpace
& s);
205
virtual
Gecode::Space
*
copy
(
bool
share);
207
virtual
void
dropUntil
(
const
Assignment
&
a
);
209
bool
assigned
(
void
)
const
;
211
bool
matchAssignment
(
const
Assignment
&
a
)
const
;
213
void
post
(
void
);
215
bool
failed
(
void
);
217
void
rel
(
int
i
,
Gecode::FloatRelType
frt,
Gecode::FloatVal
n
);
219
void
rel
(
bool
sol);
223
void
assign
(
const
Assignment
&
a
,
MaybeType
& sol,
bool
skip=
false
);
225
void
bound
(
void
);
229
Gecode::FloatNum
cut
(
int
* cutDirections);
231
void
prune
(
int
i
);
233
void
prune
(
void
);
235
bool
prune
(
const
Assignment
&
a
,
bool
testfix);
236
};
237
242
class
Test
:
public
Base
{
243
protected
:
245
int
arity
;
247
Gecode::FloatVal
dom
;
249
Gecode::FloatNum
step
;
251
AssignmentType
assigmentType
;
253
bool
reified
;
255
int
rms
;
257
bool
testsearch
;
259
bool
testfix
;
261
bool
testsubsumed
;
263
264
bool
eqv
(
void
)
const
;
267
bool
imp
(
void
)
const
;
269
bool
pmi
(
void
)
const
;
271
public
:
279
Test
(
const
std::string& s,
int
a
,
const
Gecode::FloatVal
&
d
,
280
Gecode::FloatNum
st,
AssignmentType
at,
281
bool
r
);
289
Test
(
const
std::string& s,
int
a
,
290
Gecode::FloatNum
min
,
Gecode::FloatNum
max
,
291
Gecode::FloatNum
st,
AssignmentType
at,
292
bool
r
);
294
virtual
Assignment
*
assignment
(
void
)
const
;
297
virtual
bool
extendAssignement
(
Assignment
&
a
)
const
;
299
virtual
MaybeType
solution
(
const
Assignment
&)
const
= 0;
302
bool
subsumed
(
const
TestSpace
& ts)
const
;
304
virtual
bool
ignore
(
const
Assignment
&
a
)
const
;
306
virtual
void
post
(
Gecode::Space
& home,
Gecode::FloatVarArray
&
x
) = 0;
308
virtual
void
post
(
Gecode::Space
& home,
Gecode::FloatVarArray
&
x
,
309
Gecode::Reify
r
);
311
virtual
bool
run
(
void
);
313
314
static
std::string
str
(
Gecode::FloatRelType
frt);
317
static
std::string
str
(
Gecode::FloatNum
f);
319
static
std::string
str
(
Gecode::FloatVal
f);
321
static
std::string
str
(
const
Gecode::FloatValArgs
& f);
323
325
static
MaybeType
cmp
(
Gecode::FloatVal
x
,
Gecode::FloatRelType
r
,
327
Gecode::FloatVal
y);
329
static
MaybeType
eq
(
Gecode::FloatVal
x
,
Gecode::FloatVal
y);
331
bool
flip
(
void
);
333
};
335
337
class
FloatRelTypes
{
338
private
:
340
static
const
Gecode::FloatRelType
frts[6];
342
int
i;
343
public
:
345
FloatRelTypes
(
void
);
347
void
reset
(
void
);
349
bool
operator()
(
void
)
const
;
351
void
operator++
(
void
);
353
Gecode::FloatRelType
frt
(
void
)
const
;
354
};
355
356
}
357
}
358
363
std::ostream&
operator<<
(std::ostream& os,
const
Test::Float::Assignment
&
a
);
364
365
#include "
test/float.hpp
"
366
367
#endif
368
369
// STATISTICS: test-float
370