main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
int
distinct
ter-dom.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, 2003
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
Distinct {
35
36
37
/*
38
* Ternary domain consistent distinct
39
*
40
*/
41
42
template
<
class
View>
43
forceinline
44
TerDom<View>::TerDom
(
Home
home, View x0, View x1, View x2)
45
:
TernaryPropagator
<View,
PC_INT_DOM
>(home,x0,x1,x2) {}
46
47
template
<
class
View>
48
ExecStatus
49
TerDom<View>::post
(
Home
home, View x0, View x1, View x2) {
50
(void)
new
(home)
TerDom<View>
(home,x0,x1,x2);
51
return
ES_OK
;
52
}
53
54
template
<
class
View>
55
forceinline
56
TerDom<View>::TerDom
(
Space
& home,
TerDom<View>
&
p
)
57
:
TernaryPropagator
<View,
PC_INT_DOM
>(home,
p
) {}
58
59
template
<
class
View>
60
Actor
*
61
TerDom<View>::copy
(
Space
& home) {
62
return
new
(home)
TerDom<View>
(home,*
this
);
63
}
64
66
#define GECODE_INT_HALL_ONE(x0,x1,x2) \
67
if (x0.assigned()) { \
68
GECODE_ME_CHECK(x1.nq(home,x0.val())); \
69
GECODE_ME_CHECK(x2.nq(home,x0.val())); \
70
if (x1.assigned()) { \
71
GECODE_ME_CHECK(x2.nq(home,x1.val())); \
72
return home.ES_SUBSUMED(*this); \
73
} \
74
if (x2.assigned()) { \
75
GECODE_ME_CHECK(x1.nq(home,x2.val())); \
76
return home.ES_SUBSUMED(*this); \
77
} \
78
return ES_FIX; \
79
}
80
81
83
#define GECODE_INT_HALL_TWO(x0,x1,x2) \
84
if ((x0.size() == 2) && (x1.size() == 2) && \
85
(x0.min() == x1.min()) && (x0.max() == x1.max())) { \
86
GECODE_ME_CHECK(x2.nq(home,x0.min())); \
87
GECODE_ME_CHECK(x2.nq(home,x0.max())); \
88
return ES_FIX; \
89
}
90
91
template
<
class
View>
92
ExecStatus
93
TerDom<View>::propagate
(
Space
& home,
const
ModEventDelta
&) {
94
GECODE_INT_HALL_ONE
(x0,x1,x2);
95
GECODE_INT_HALL_ONE
(x1,x0,x2);
96
GECODE_INT_HALL_ONE
(x2,x0,x1);
97
GECODE_INT_HALL_TWO
(x0,x1,x2);
98
GECODE_INT_HALL_TWO
(x0,x2,x1);
99
GECODE_INT_HALL_TWO
(x1,x2,x0);
100
return
ES_FIX
;
101
}
102
103
#undef GECODE_INT_HALL_ONE
104
#undef GECODE_INT_HALL_TWO
105
106
}}}
107
108
// STATISTICS: int-prop
109
Gecode::Int::Distinct::TerDom::TerDom
TerDom(Space &home, TerDom< View > &p)
Constructor for cloning p.
Definition:
ter-dom.hpp:56
Gecode::Int::Distinct::TerDom::post
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator for views x.
Definition:
ter-dom.hpp:49
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:628
Gecode
Gecode toplevel namespace
Gecode::Int::Distinct::TerDom::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
ter-dom.hpp:93
Gecode::Int::Distinct::TerDom::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition:
ter-dom.hpp:61
Gecode::Int::Distinct::TerDom
Ternary domain consistent distinct propagator.
Definition:
distinct.hh:322
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::TernaryPropagator
Ternary propagator.
Definition:
pattern.hpp:113
GECODE_INT_HALL_TWO
#define GECODE_INT_HALL_TWO(x0, x1, x2)
Check whether x0 and x1 form a Hall set of cardinality two.
Definition:
ter-dom.hpp:83
GECODE_INT_HALL_ONE
#define GECODE_INT_HALL_ONE(x0, x1, x2)
Check whether x0 forms a Hall set of cardinality one.
Definition:
ter-dom.hpp:66
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:477
forceinline
#define forceinline
Definition:
config.hpp:185
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::ES_OK
@ 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::ExecStatus
ExecStatus
Definition:
core.hpp:472