main page
modules
namespaces
classes
files
Gecode home
Generated on Sat May 25 2013 18:00:37 for Gecode by
doxygen
1.8.3.1
gecode
int
dom
set.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: 2011-11-18 16:02:48 +0100 (Fri, 18 Nov 2011) $ by $Author: schulte $
11
* $Revision: 12472 $
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, ReifyMode rm>
41
forceinline
42
ReIntSet<View,rm>::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, ReifyMode rm>
49
forceinline
size_t
50
ReIntSet<View,rm>::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, ReifyMode rm>
58
ExecStatus
59
ReIntSet<View,rm>::post
(
Home
home, View x,
const
IntSet
& s,
BoolView
b) {
60
if
(s.
ranges
() == 0) {
61
if
(rm ==
RM_PMI
)
62
return
ES_OK
;
63
GECODE_ME_CHECK
(b.
zero
(home));
64
}
else
if
(s.
ranges
() == 1) {
65
return
ReRange<View,rm>::post
(home,x,s.
min
(),s.
max
(),
b
);
66
}
else
if
(b.
one
()) {
67
if
(rm ==
RM_PMI
)
68
return
ES_OK
;
69
IntSetRanges
i_is(s);
70
GECODE_ME_CHECK
(x.inter_r(home,i_is,
false
));
71
}
else
if
(b.
zero
()) {
72
if
(rm ==
RM_IMP
)
73
return
ES_OK
;
74
IntSetRanges
i_is(s);
75
GECODE_ME_CHECK
(x.minus_r(home,i_is,
false
));
76
}
else
{
77
(void)
new
(home)
ReIntSet<View,rm>
(home,
x
,s,
b
);
78
}
79
return
ES_OK
;
80
}
81
82
83
template
<
class
View, ReifyMode rm>
84
forceinline
85
ReIntSet<View,rm>::ReIntSet
(
Space
& home,
bool
share,
ReIntSet
&
p
)
86
:
ReUnaryPropagator
<View,
PC_INT_DOM
,
BoolView
>(home,share,p) {
87
is
.
update
(home,share,p.
is
);
88
}
89
90
template
<
class
View, ReifyMode rm>
91
Actor
*
92
ReIntSet<View,rm>::copy
(
Space
& home,
bool
share) {
93
return
new
(home)
ReIntSet
(home,share,*
this
);
94
}
95
96
template
<
class
View, ReifyMode rm>
97
ExecStatus
98
ReIntSet<View,rm>::propagate
(
Space
& home,
const
ModEventDelta
&) {
99
IntSetRanges
i_is(is);
100
if
(b.
one
()) {
101
if
(rm !=
RM_PMI
)
102
GECODE_ME_CHECK
(x0.inter_r(home,i_is,
false
));
103
return
home.
ES_SUBSUMED
(*
this
);
104
}
105
if
(b.
zero
()) {
106
if
(rm !=
RM_IMP
)
107
GECODE_ME_CHECK
(x0.minus_r(home,i_is,
false
));
108
return
home.
ES_SUBSUMED
(*
this
);
109
}
110
111
{
112
ViewRanges<View>
i_x(x0);
113
114
switch
(
Iter::Ranges::compare
(i_x,i_is)) {
115
case
Iter::Ranges::CS_SUBSET
:
116
if
(rm !=
RM_IMP
)
117
GECODE_ME_CHECK
(b.
one_none
(home));
118
return
home.
ES_SUBSUMED
(*
this
);
119
case
Iter::Ranges::CS_DISJOINT
:
120
if
(rm !=
RM_PMI
)
121
GECODE_ME_CHECK
(b.
zero_none
(home));
122
return
home.
ES_SUBSUMED
(*
this
);
123
case
Iter::Ranges::CS_NONE
:
124
break
;
125
default
:
GECODE_NEVER
;
126
}
127
}
128
return
ES_FIX
;
129
}
130
131
}}}
132
133
// STATISTICS: int-prop
134