main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
int
dom
range.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: 2016-10-17 21:23:15 +0200 (Mon, 17 Oct 2016) $ by $Author: schulte $
11
* $Revision: 15215 $
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
#include <
gecode/int/rel.hh
>
39
40
namespace
Gecode
{
namespace
Int {
namespace
Dom {
41
42
template
<
class
View, ReifyMode rm>
43
forceinline
44
ReRange<View,rm>::ReRange
(
Home
home, View
x
,
int
min0,
int
max0,
BoolView
b
)
45
:
ReUnaryPropagator
<View,
PC_INT_DOM
,
BoolView
>(home,
x
,
b
),
46
min
(min0),
max
(max0) {}
47
48
template
<
class
View, ReifyMode rm>
49
ExecStatus
50
ReRange<View,rm>::post
(
Home
home, View
x
,
int
min
,
int
max
,
BoolView
b
) {
51
if
(
min
==
max
) {
52
return
Rel::ReEqDomInt<View,BoolView,rm>::post
(home,
x
,
min
,
b
);
53
}
else
if
((
min
>
max
) || (
max
<
x
.min()) || (
min
>
x
.max())) {
54
if
(rm ==
RM_PMI
)
55
return
ES_OK
;
56
GECODE_ME_CHECK
(
b
.zero(home));
57
}
else
if
((
min
<=
x
.min()) && (
x
.max() <=
max
)) {
58
if
(rm ==
RM_IMP
)
59
return
ES_OK
;
60
GECODE_ME_CHECK
(
b
.one(home));
61
}
else
if
(
b
.one()) {
62
if
(rm ==
RM_PMI
)
63
return
ES_OK
;
64
GECODE_ME_CHECK
(
x
.gq(home,
min
));
65
GECODE_ME_CHECK
(
x
.lq(home,
max
));
66
}
else
if
(
b
.zero()) {
67
if
(rm ==
RM_IMP
)
68
return
ES_OK
;
69
Iter::Ranges::Singleton
r
(
min
,
max
);
70
GECODE_ME_CHECK
(
x
.minus_r(home,
r
,
false
));
71
}
else
{
72
(void)
new
(home)
ReRange<View,rm>
(home,
x
,
min
,
max
,
b
);
73
}
74
return
ES_OK
;
75
}
76
77
78
template
<
class
View, ReifyMode rm>
79
forceinline
80
ReRange<View,rm>::ReRange
(
Space
& home,
bool
share,
ReRange
&
p
)
81
:
ReUnaryPropagator
<View,
PC_INT_DOM
,
BoolView
>(home,share,
p
),
82
min
(
p
.
min
),
max
(
p
.
max
) {}
83
84
template
<
class
View, ReifyMode rm>
85
Actor
*
86
ReRange<View,rm>::copy
(
Space
& home,
bool
share) {
87
return
new
(home)
ReRange<View,rm>
(home,share,*
this
);
88
}
89
90
template
<
class
View, ReifyMode rm>
91
ExecStatus
92
ReRange<View,rm>::propagate
(
Space
& home,
const
ModEventDelta
&) {
93
if
(
b
.one()) {
94
if
(rm !=
RM_PMI
) {
95
GECODE_ME_CHECK
(x0.gq(home,
min
));
96
GECODE_ME_CHECK
(x0.lq(home,
max
));
97
}
98
return
home.
ES_SUBSUMED
(*
this
);
99
}
else
if
(
b
.zero()) {
100
if
(rm !=
RM_IMP
) {
101
Iter::Ranges::Singleton
r
(
min
,
max
);
102
GECODE_ME_CHECK
(x0.minus_r(home,
r
,
false
));
103
}
104
return
home.
ES_SUBSUMED
(*
this
);
105
}
else
if
((x0.max() <=
max
) && (x0.min() >=
min
)) {
106
if
(rm !=
RM_IMP
)
107
GECODE_ME_CHECK
(
b
.one_none(home));
108
return
home.
ES_SUBSUMED
(*
this
);
109
}
else
if
((x0.max() <
min
) || (x0.min() >
max
)) {
110
if
(rm !=
RM_PMI
)
111
GECODE_ME_CHECK
(
b
.zero_none(home));
112
return
home.
ES_SUBSUMED
(*
this
);
113
}
else
if
(!x0.range()) {
114
ViewRanges<View>
i_x(x0);
115
Iter::Ranges::Singleton
i_mm(
min
,
max
);
116
117
switch
(
Iter::Ranges::compare
(i_x,i_mm)) {
118
case
Iter::Ranges::CS_SUBSET
:
119
if
(rm !=
RM_IMP
)
120
GECODE_ME_CHECK
(
b
.one_none(home));
121
return
home.
ES_SUBSUMED
(*
this
);
122
case
Iter::Ranges::CS_DISJOINT
:
123
if
(rm !=
RM_PMI
)
124
GECODE_ME_CHECK
(
b
.zero_none(home));
125
return
home.
ES_SUBSUMED
(*
this
);
126
case
Iter::Ranges::CS_NONE
:
127
break
;
128
default
:
GECODE_NEVER
;
129
}
130
return
ES_FIX
;
131
}
132
return
ES_FIX
;
133
}
134
135
}}}
136
137
// STATISTICS: int-prop
138
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::RM_PMI
@ RM_PMI
Inverse implication for reification.
Definition:
int.hh:850
Gecode::Int::Rel::ReEqDomInt::post
static ExecStatus post(Home home, View x, int c, CtrlView b)
Post domain consistent propagator .
Definition:
eq.hpp:648
Gecode::Int::Dom::ReRange
Reified range dom-propagator.
Definition:
dom.hh:60
Gecode::Int::Dom::ReRange::copy
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition:
range.hpp:86
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:53
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3614
Gecode::Iter::Ranges::CS_NONE
@ CS_NONE
Neither of the above.
Definition:
ranges-operations.hpp:67
Gecode::RM_IMP
@ RM_IMP
Implication for reification.
Definition:
int.hh:843
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:696
Gecode::Int::ReUnaryPropagator
Reified unary propagator.
Definition:
propagator.hpp:58
Gecode::Int::Dom::ReRange::post
static ExecStatus post(Home home, View x, int min, int max, BoolView b)
Post propagator for .
Definition:
range.hpp:50
Gecode::Int::BoolView
Boolean view for Boolean variables.
Definition:
view.hpp:1315
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::CS_SUBSET
@ CS_SUBSET
First is subset of second iterator.
Definition:
ranges-operations.hpp:65
Gecode::Int::ViewRanges
Range iterator for integer views.
Definition:
view.hpp:54
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:922
b
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:784
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:60
Gecode::Int::Dom::ReRange::ReRange
ReRange(Space &home, bool share, ReRange &p)
Constructor for cloning p.
Definition:
range.hpp:80
rel.hh
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:545
Gecode::Int::Dom::ReRange::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
range.hpp:92
Gecode::Iter::Ranges::Singleton
Range iterator for singleton range.
Definition:
ranges-singleton.hpp:46
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:56
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:71
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:169
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:131
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition:
core.hpp:544
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236
Gecode::Iter::Ranges::CS_DISJOINT
@ CS_DISJOINT
Intersection is empty.
Definition:
ranges-operations.hpp:66
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:540