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
member.cpp
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, 2011
8
*
9
* Last modified:
10
* $Date: 2016-05-23 22:18:23 +0200 (Mon, 23 May 2016) $ by $Author: schulte $
11
* $Revision: 15073 $
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/member.hh
>
39
40
namespace
Gecode
{
41
42
void
43
member
(
Home
home,
const
IntVarArgs
&
x
,
IntVar
y
,
44
IntPropLevel
) {
45
using namespace
Int;
46
GECODE_POST
;
47
48
ViewArray<IntView>
xv(home,
x
);
49
GECODE_ES_FAIL
(
Member::Prop<IntView>::post
(home,xv,
y
));
50
}
51
52
void
53
member
(
Home
home,
const
BoolVarArgs
&
x
,
BoolVar
y
,
54
IntPropLevel
) {
55
using namespace
Int;
56
GECODE_POST
;
57
58
ViewArray<BoolView>
xv(home,
x
);
59
GECODE_ES_FAIL
(
Member::Prop<BoolView>::post
(home,xv,
y
));
60
}
61
62
void
63
member
(
Home
home,
const
IntVarArgs
&
x
,
IntVar
y
,
Reify
r
,
64
IntPropLevel
) {
65
using namespace
Int;
66
GECODE_POST
;
67
68
ViewArray<IntView>
xv(home,
x
);
69
70
switch
(
r
.mode()) {
71
case
RM_EQV
:
72
GECODE_ES_FAIL
((
Member::ReProp<IntView,RM_EQV>
73
::
post
(home,xv,
y
,
r
.var())));
74
break
;
75
case
RM_IMP
:
76
GECODE_ES_FAIL
((
Member::ReProp<IntView,RM_IMP>
77
::
post
(home,xv,
y
,
r
.var())));
78
break
;
79
case
RM_PMI
:
80
GECODE_ES_FAIL
((
Member::ReProp<IntView,RM_PMI>
81
::
post
(home,xv,
y
,
r
.var())));
82
break
;
83
default
:
throw
UnknownReifyMode
(
"Int::member"
);
84
}
85
}
86
87
void
88
member
(
Home
home,
const
BoolVarArgs
&
x
,
BoolVar
y
,
Reify
r
,
89
IntPropLevel
) {
90
using namespace
Int;
91
GECODE_POST
;
92
93
ViewArray<BoolView>
xv(home,
x
);
94
95
switch
(
r
.mode()) {
96
case
RM_EQV
:
97
GECODE_ES_FAIL
((
Member::ReProp<BoolView,RM_EQV>
98
::
post
(home,xv,
y
,
r
.var())));
99
break
;
100
case
RM_IMP
:
101
GECODE_ES_FAIL
((
Member::ReProp<BoolView,RM_IMP>
102
::
post
(home,xv,
y
,
r
.var())));
103
break
;
104
case
RM_PMI
:
105
GECODE_ES_FAIL
((
Member::ReProp<BoolView,RM_PMI>
106
::
post
(home,xv,
y
,
r
.var())));
107
break
;
108
default
:
throw
UnknownReifyMode
(
"Int::member"
);
109
}
110
111
}
112
113
}
114
115
// STATISTICS: int-post
116
Gecode::Int::UnknownReifyMode
Exception: Unknown reification mode passed as argument
Definition:
exception.hpp:119
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:784
Gecode::RM_PMI
@ RM_PMI
Inverse implication for reification.
Definition:
int.hh:850
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition:
macros.hpp:107
Gecode::IntVarArgs
Passing integer variables.
Definition:
int.hh:639
Gecode::RM_IMP
@ RM_IMP
Implication for reification.
Definition:
int.hh:843
Gecode::IntPropLevel
IntPropLevel
Propagation levels for integer propagators.
Definition:
int.hh:955
Gecode
Gecode toplevel namespace
Gecode::Reify
Reification specification.
Definition:
int.hh:857
Gecode::BoolVarArgs
Passing Boolean variables.
Definition:
int.hh:693
Gecode::RM_EQV
@ RM_EQV
Equivalence for reification (default)
Definition:
int.hh:836
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:922
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:784
Gecode::BoolVar
Boolean integer variables.
Definition:
int.hh:494
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition:
trace-filter.cpp:142
Gecode::IntVar
Integer variables.
Definition:
int.hh:353
Gecode::member
void member(Home home, const IntVarArgs &x, IntVar y, IntPropLevel)
Post domain consistent propagator for .
Definition:
member.cpp:43
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition:
macros.hpp:44
Gecode::ViewArray< IntView >
member.hh
Gecode::Int::Member::Prop
Membership propagator.
Definition:
member.hh:58
Gecode::Int::Member::ReProp
Reified membership propagator.
Definition:
member.hh:94