main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Feb 11 2025 17:33:26 for Gecode by
doxygen
1.12.0
gecode
int
extensional-tuple-set.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Linnea Ingmar <linnea.ingmar@hotmail.com>
5
* Mikael Lagerkvist <lagerkvist@gecode.org>
6
* Christian Schulte <schulte@gecode.org>
7
*
8
* Copyright:
9
* Linnea Ingmar, 2017
10
* Mikael Lagerkvist, 2007
11
* Christian Schulte, 2017
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/extensional.hh
>
39
40
namespace
Gecode
{
41
42
void
43
extensional
(
Home
home,
const
IntVarArgs
&
x
,
const
TupleSet
&
t
,
bool
pos,
44
IntPropLevel
) {
45
using namespace
Int;
46
if
(!
t
.finalized())
47
throw
NotYetFinalized
(
"Int::extensional"
);
48
if
(
t
.arity() !=
x
.size())
49
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
50
GECODE_POST
;
51
52
ViewArray<IntView>
xv(home,
x
);
53
if
(pos)
54
GECODE_ES_FAIL
((
Extensional::postposcompact<IntView>
(home,xv,
t
)));
55
else
56
GECODE_ES_FAIL
((
Extensional::postnegcompact<IntView>
(home,xv,
t
)));
57
}
58
59
void
60
extensional
(
Home
home,
const
IntVarArgs
&
x
,
const
TupleSet
&
t
,
bool
pos,
61
Reify
r
,
62
IntPropLevel
) {
63
using namespace
Int;
64
if
(!
t
.finalized())
65
throw
NotYetFinalized
(
"Int::extensional"
);
66
if
(
t
.arity() !=
x
.size())
67
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
68
GECODE_POST
;
69
70
ViewArray<IntView>
xv(home,
x
);
71
if
(pos) {
72
switch
(
r
.mode()) {
73
case
RM_EQV
:
74
GECODE_ES_FAIL
((
Extensional::postrecompact<IntView,BoolView,RM_EQV>
75
(home,xv,
t
,
r
.var())));
76
break
;
77
case
RM_IMP
:
78
GECODE_ES_FAIL
((
Extensional::postrecompact<IntView,BoolView,RM_IMP>
79
(home,xv,
t
,
r
.var())));
80
break
;
81
case
RM_PMI
:
82
GECODE_ES_FAIL
((
Extensional::postrecompact<IntView,BoolView,RM_PMI>
83
(home,xv,
t
,
r
.var())));
84
break
;
85
default
:
throw
UnknownReifyMode
(
"Int::extensional"
);
86
}
87
}
else
{
88
NegBoolView
n
(
r
.var());
89
switch
(
r
.mode()) {
90
case
RM_EQV
:
91
GECODE_ES_FAIL
((
Extensional::postrecompact<IntView,NegBoolView,RM_EQV>
92
(home,xv,
t
,
n
)));
93
break
;
94
case
RM_IMP
:
95
GECODE_ES_FAIL
((
Extensional::postrecompact<IntView,NegBoolView,RM_PMI>
96
(home,xv,
t
,
n
)));
97
break
;
98
case
RM_PMI
:
99
GECODE_ES_FAIL
((
Extensional::postrecompact<IntView,NegBoolView,RM_IMP>
100
(home,xv,
t
,
n
)));
101
break
;
102
default
:
throw
UnknownReifyMode
(
"Int::extensional"
);
103
}
104
}
105
}
106
107
void
108
extensional
(
Home
home,
const
BoolVarArgs
&
x
,
const
TupleSet
&
t
,
bool
pos,
109
IntPropLevel
) {
110
using namespace
Int;
111
if
(!
t
.finalized())
112
throw
NotYetFinalized
(
"Int::extensional"
);
113
if
(
t
.arity() !=
x
.size())
114
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
115
if
((
t
.min() < 0) || (
t
.max() > 1))
116
throw
NotZeroOne
(
"Int::extensional"
);
117
GECODE_POST
;
118
119
ViewArray<BoolView>
xv(home,
x
);
120
if
(pos)
121
GECODE_ES_FAIL
((
Extensional::postposcompact<BoolView>
(home,xv,
t
)));
122
else
123
GECODE_ES_FAIL
((
Extensional::postnegcompact<BoolView>
(home,xv,
t
)));
124
}
125
126
void
127
extensional
(
Home
home,
const
BoolVarArgs
&
x
,
const
TupleSet
&
t
,
bool
pos,
128
Reify
r
,
129
IntPropLevel
) {
130
using namespace
Int;
131
if
(!
t
.finalized())
132
throw
NotYetFinalized
(
"Int::extensional"
);
133
if
(
t
.arity() !=
x
.size())
134
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
135
if
((
t
.min() < 0) || (
t
.max() > 1))
136
throw
NotZeroOne
(
"Int::extensional"
);
137
GECODE_POST
;
138
139
ViewArray<BoolView>
xv(home,
x
);
140
if
(pos) {
141
switch
(
r
.mode()) {
142
case
RM_EQV
:
143
GECODE_ES_FAIL
((
Extensional::postrecompact<BoolView,BoolView,RM_EQV>
144
(home,xv,
t
,
r
.var())));
145
break
;
146
case
RM_IMP
:
147
GECODE_ES_FAIL
((
Extensional::postrecompact<BoolView,BoolView,RM_IMP>
148
(home,xv,
t
,
r
.var())));
149
break
;
150
case
RM_PMI
:
151
GECODE_ES_FAIL
((
Extensional::postrecompact<BoolView,BoolView,RM_PMI>
152
(home,xv,
t
,
r
.var())));
153
break
;
154
default
:
throw
UnknownReifyMode
(
"Int::extensional"
);
155
}
156
}
else
{
157
NegBoolView
n
(
r
.var());
158
switch
(
r
.mode()) {
159
case
RM_EQV
:
160
GECODE_ES_FAIL
((
Extensional::postrecompact<BoolView,NegBoolView,RM_EQV>
161
(home,xv,
t
,
n
)));
162
break
;
163
case
RM_IMP
:
164
GECODE_ES_FAIL
((
Extensional::postrecompact<BoolView,NegBoolView,RM_PMI>
165
(home,xv,
t
,
n
)));
166
break
;
167
case
RM_PMI
:
168
GECODE_ES_FAIL
((
Extensional::postrecompact<BoolView,NegBoolView,RM_IMP>
169
(home,xv,
t
,
n
)));
170
break
;
171
default
:
throw
UnknownReifyMode
(
"Int::extensional"
);
172
}
173
}
174
}
175
176
}
177
178
// STATISTICS: int-post
t
NodeType t
Type of node.
Definition
bool-expr.cpp:230
n
int n
Number of negative literals for node type.
Definition
bool-expr.cpp:234
Gecode::BoolVarArgs
Passing Boolean variables.
Definition
int.hh:712
Gecode::Home
Home class for posting propagators
Definition
core.hpp:856
Gecode::IntVarArgs
Passing integer variables.
Definition
int.hh:656
Gecode::Int::ArgumentSizeMismatch
Exception: Arguments are of different size
Definition
exception.hpp:73
Gecode::Int::NegBoolView
Negated Boolean view.
Definition
view.hpp:1574
Gecode::Int::NotYetFinalized
Exception: Tuple set not yet finalized
Definition
exception.hpp:136
Gecode::Int::NotZeroOne
Exception: Not 0/1 integer
Definition
exception.hpp:51
Gecode::Int::UnknownReifyMode
Exception: Unknown reification mode passed as argument
Definition
exception.hpp:115
Gecode::Reify
Reification specification.
Definition
int.hh:876
Gecode::TupleSet
Class represeting a set of tuples.
Definition
int.hh:2191
Gecode::ViewArray
View arrays.
Definition
array.hpp:253
extensional.hh
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition
macros.hpp:40
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition
macros.hpp:103
Gecode::extensional
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
Definition
extensional-regular.cpp:39
Gecode::IntPropLevel
IntPropLevel
Propagation levels for integer propagators.
Definition
int.hh:974
Gecode::RM_IMP
@ RM_IMP
Implication for reification.
Definition
int.hh:862
Gecode::RM_PMI
@ RM_PMI
Inverse implication for reification.
Definition
int.hh:869
Gecode::RM_EQV
@ RM_EQV
Equivalence for reification (default)
Definition
int.hh:855
Gecode::Int::Extensional::postnegcompact
ExecStatus postnegcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for compact table propagator.
Definition
compact.hpp:955
Gecode::Int::Extensional::postposcompact
ExecStatus postposcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table propagator.
Definition
compact.hpp:685
Gecode::Int::Extensional::postrecompact
ExecStatus postrecompact(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for compact table propagator.
Definition
compact.hpp:1192
Gecode
Gecode toplevel namespace
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition
set.hh:767
Gecode::x
Post propagator for SetVar x
Definition
set.hh:767