main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 26 2012 08:42:52 for Gecode by
doxygen
1.8.1.1
gecode
int
dom
spec.hpp
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
*
6
* Copyright:
7
* Christian Schulte, 2004
8
*
9
* Last modified:
10
* $Date: 2012-02-22 16:04:20 +1100 (Wed, 22 Feb 2012) $ by $Author: tack $
11
* $Revision: 12537 $
12
*
13
* This file is part of Gecode, the generic constraint
14
* development environment:
15
* http://www.gecode.org
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining
18
* a copy of this software and associated documentation files (the
19
* "Software"), to deal in the Software without restriction, including
20
* without limitation the rights to use, copy, modify, merge, publish,
21
* distribute, sublicense, and/or sell copies of the Software, and to
22
* permit persons to whom the Software is furnished to do so, subject to
23
* the following conditions:
24
*
25
* The above copyright notice and this permission notice shall be
26
* included in all copies or substantial portions of the Software.
27
*
28
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
*
36
*/
37
38
namespace
Gecode {
namespace
Int {
namespace
Dom {
39
40
template
<
class
View>
41
forceinline
42
ReIntSet<View>::ReIntSet
43
(
Home
home, View x,
const
IntSet
& s,
BoolView
b
)
44
:
ReUnaryPropagator<View,PC_INT_DOM,BoolView>
(home,x,
b
), is(s) {
45
home.
notice
(*
this
,
AP_DISPOSE
);
46
}
47
48
template
<
class
View>
49
forceinline
size_t
50
ReIntSet<View>::dispose
(
Space
& home) {
51
home.
ignore
(*
this
,
AP_DISPOSE
);
52
is.~IntSet();
53
(void)
ReUnaryPropagator<View,PC_INT_DOM,BoolView>::dispose
(home);
54
return
sizeof
(*this);
55
}
56
57
template
<
class
View>
58
ExecStatus
59
ReIntSet<View>::post
(
Home
home, View x,
const
IntSet
& s,
BoolView
b) {
60
if
(s.
ranges
() == 0) {
61
GECODE_ME_CHECK
(b.
zero
(home));
62
}
else
if
(s.
ranges
() == 1) {
63
return
ReRange<View>::post
(home,x,s.
min
(),s.
max
(),
b
);
64
}
else
if
(b.
one
()) {
65
IntSetRanges
i_is(s);
66
GECODE_ME_CHECK
(x.inter_r(home,i_is,
false
));
67
}
else
if
(b.
zero
()) {
68
IntSetRanges
i_is(s);
69
GECODE_ME_CHECK
(x.minus_r(home,i_is,
false
));
70
}
else
{
71
(void)
new
(home)
ReIntSet<View>
(home,x,s,
b
);
72
}
73
return
ES_OK
;
74
}
75
76
77
template
<
class
View>
78
forceinline
79
ReIntSet<View>::ReIntSet
(
Space
& home,
bool
share,
ReIntSet
& p)
80
:
ReUnaryPropagator
<View,
PC_INT_DOM
,
BoolView
>(home,share,p) {
81
is
.
update
(home,share,p.
is
);
82
}
83
84
template
<
class
View>
85
Actor
*
86
ReIntSet<View>::copy
(
Space
& home,
bool
share) {
87
return
new
(home)
ReIntSet
(home,share,*
this
);
88
}
89
90
template
<
class
View>
91
ExecStatus
92
ReIntSet<View>::propagate
(
Space
& home,
const
ModEventDelta
&) {
93
IntSetRanges
i_is(is);
94
if
(b.
one
()) {
95
GECODE_ME_CHECK
(x0.inter_r(home,i_is,
false
));
96
return
home.
ES_SUBSUMED
(*
this
);
97
}
98
if
(b.
zero
()) {
99
GECODE_ME_CHECK
(x0.minus_r(home,i_is,
false
));
100
return
home.
ES_SUBSUMED
(*
this
);
101
}
102
103
{
104
ViewRanges<View>
i_x(x0);
105
106
switch
(
Iter::Ranges::compare
(i_x,i_is)) {
107
case
Iter::Ranges::CS_SUBSET
:
108
GECODE_ME_CHECK
(b.
one_none
(home));
109
return
home.
ES_SUBSUMED
(*
this
);
110
case
Iter::Ranges::CS_DISJOINT
:
111
GECODE_ME_CHECK
(b.
zero_none
(home));
112
return
home.
ES_SUBSUMED
(*
this
);
113
case
Iter::Ranges::CS_NONE
:
114
break
;
115
default
:
GECODE_NEVER
;
116
}
117
}
118
return
ES_FIX
;
119
}
120
121
}}}
122
123
// STATISTICS: int-prop
124