main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Jan 10 2020 11:38:25 for Gecode by
doxygen
1.8.16
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
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
namespace
Gecode
{
namespace
Int {
namespace
Dom {
35
36
template
<
class
View, ReifyMode rm>
37
forceinline
38
ReIntSet<View,rm>::ReIntSet
39
(
Home
home, View
x
,
const
IntSet
& s,
BoolView
b
)
40
:
ReUnaryPropagator<View,PC_INT_DOM,BoolView>
(home,
x
,
b
), is(s) {
41
home.
notice
(*
this
,
AP_DISPOSE
);
42
}
43
44
template
<
class
View, ReifyMode rm>
45
forceinline
size_t
46
ReIntSet<View,rm>::dispose
(
Space
& home) {
47
home.
ignore
(*
this
,
AP_DISPOSE
);
48
is.~IntSet();
49
(void)
ReUnaryPropagator<View,PC_INT_DOM,BoolView>::dispose
(home);
50
return
sizeof
(*this);
51
}
52
53
template
<
class
View, ReifyMode rm>
54
ExecStatus
55
ReIntSet<View,rm>::post
(
Home
home, View
x
,
const
IntSet
& s,
BoolView
b
) {
56
if
(s.
ranges
() == 0) {
57
if
(rm ==
RM_PMI
)
58
return
ES_OK
;
59
GECODE_ME_CHECK
(
b
.zero(home));
60
}
else
if
(s.
ranges
() == 1) {
61
return
ReRange<View,rm>::post
(home,
x
,s.
min
(),s.
max
(),
b
);
62
}
else
if
(
b
.one()) {
63
if
(rm ==
RM_PMI
)
64
return
ES_OK
;
65
IntSetRanges
i_is(s);
66
GECODE_ME_CHECK
(
x
.inter_r(home,i_is,
false
));
67
}
else
if
(
b
.zero()) {
68
if
(rm ==
RM_IMP
)
69
return
ES_OK
;
70
IntSetRanges
i_is(s);
71
GECODE_ME_CHECK
(
x
.minus_r(home,i_is,
false
));
72
}
else
{
73
(void)
new
(home)
ReIntSet<View,rm>
(home,
x
,s,
b
);
74
}
75
return
ES_OK
;
76
}
77
78
79
template
<
class
View, ReifyMode rm>
80
forceinline
81
ReIntSet<View,rm>::ReIntSet
(
Space
& home,
ReIntSet
&
p
)
82
:
ReUnaryPropagator
<View,
PC_INT_DOM
,
BoolView
>(home,
p
), is(
p
.is) {
83
}
84
85
template
<
class
View, ReifyMode rm>
86
Actor
*
87
ReIntSet<View,rm>::copy
(
Space
& home) {
88
return
new
(home)
ReIntSet
(home,*
this
);
89
}
90
91
template
<
class
View, ReifyMode rm>
92
ExecStatus
93
ReIntSet<View,rm>::propagate
(
Space
& home,
const
ModEventDelta
&) {
94
IntSetRanges
i_is(is);
95
if
(
b
.one()) {
96
if
(rm !=
RM_PMI
)
97
GECODE_ME_CHECK
(x0.inter_r(home,i_is,
false
));
98
return
home.
ES_SUBSUMED
(*
this
);
99
}
100
if
(
b
.zero()) {
101
if
(rm !=
RM_IMP
)
102
GECODE_ME_CHECK
(x0.minus_r(home,i_is,
false
));
103
return
home.
ES_SUBSUMED
(*
this
);
104
}
105
106
{
107
ViewRanges<View>
i_x(x0);
108
109
switch
(
Iter::Ranges::compare
(i_x,i_is)) {
110
case
Iter::Ranges::CS_SUBSET
:
111
if
(rm !=
RM_IMP
)
112
GECODE_ME_CHECK
(
b
.one_none(home));
113
return
home.
ES_SUBSUMED
(*
this
);
114
case
Iter::Ranges::CS_DISJOINT
:
115
if
(rm !=
RM_PMI
)
116
GECODE_ME_CHECK
(
b
.zero_none(home));
117
return
home.
ES_SUBSUMED
(*
this
);
118
case
Iter::Ranges::CS_NONE
:
119
break
;
120
default
:
GECODE_NEVER
;
121
}
122
}
123
return
ES_FIX
;
124
}
125
126
}}}
127
128
// STATISTICS: int-prop
129
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::Home::notice
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Definition:
core.hpp:3219
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::IntSet::min
int min(int i) const
Return minimum of range at position i.
Definition:
int-set-1.hpp:152
Gecode::RM_PMI
Inverse implication for reification.
Definition:
int.hh:869
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3563
Gecode::IntSet::max
int max(int i) const
Return maximum of range at position i.
Definition:
int-set-1.hpp:158
Gecode::Iter::Ranges::CS_NONE
Neither of the above.
Definition:
ranges-operations.hpp:63
Gecode::Int::Dom::ReIntSet
Reified domain dom-propagator.
Definition:
dom.hh:84
Gecode::RM_IMP
Implication for reification.
Definition:
int.hh:862
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:628
Gecode::Int::ReUnaryPropagator< View, PC_INT_DOM, BoolView >
Gecode::IntSetRanges
Range iterator for integer sets.
Definition:
int.hh:292
Gecode::Int::Dom::ReRange::post
static ExecStatus post(Home home, View x, int min, int max, BoolView b)
Post propagator for .
Definition:
range.hpp:46
Gecode::Int::BoolView
Boolean view for Boolean variables.
Definition:
view.hpp:1380
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::CS_SUBSET
First is subset of second iterator.
Definition:
ranges-operations.hpp:61
Gecode::Int::ViewRanges
Range iterator for integer views.
Definition:
view.hpp:54
Gecode::IntSet
Integer sets.
Definition:
int.hh:174
Gecode::Int::Dom::ReIntSet::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
set.hpp:93
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::AP_DISPOSE
Actor must always be disposed.
Definition:
core.hpp:562
Gecode::Int::Dom::ReIntSet::ReIntSet
ReIntSet(Space &home, ReIntSet &p)
Constructor for cloning p.
Definition:
set.hpp:81
Gecode::Int::Dom::ReIntSet::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition:
set.hpp:46
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:56
Gecode::Int::Dom::ReIntSet::post
static ExecStatus post(Home home, View x, const IntSet &s, BoolView b)
Post propagator for .
Definition:
set.hpp:55
Gecode::ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:477
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Space::ignore
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition:
core.hpp:4074
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:52
Gecode::Int::Dom::ReIntSet::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition:
set.hpp:87
Gecode::Int::PC_INT_DOM
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition:
var-type.hpp:100
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
Gecode::Iter::Ranges::compare
CompareStatus compare(I &i, J &j)
Check whether range iterator i is a subset of j, or whether they are disjoint.
Definition:
ranges-operations.hpp:127
Gecode::ES_OK
Execution is okay.
Definition:
core.hpp:476
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::IntSet::ranges
int ranges(void) const
Return number of ranges of the specification.
Definition:
int-set-1.hpp:171
Gecode::Iter::Ranges::CS_DISJOINT
Intersection is empty.
Definition:
ranges-operations.hpp:62
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:472