Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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
39
40namespace Gecode {
41
42 void
43 extensional(Home home, const IntVarArgs& x, const TupleSet& t, bool pos,
45 using namespace Int;
46 if (!t.finalized())
47 throw NotYetFinalized("Int::extensional");
48 if (t.arity() != x.size())
49 throw ArgumentSizeMismatch("Int::extensional");
51
52 ViewArray<IntView> xv(home,x);
53 if (pos)
55 else
57 }
58
59 void
60 extensional(Home home, const IntVarArgs& x, const TupleSet& t, bool pos,
61 Reify r,
63 using namespace Int;
64 if (!t.finalized())
65 throw NotYetFinalized("Int::extensional");
66 if (t.arity() != x.size())
67 throw ArgumentSizeMismatch("Int::extensional");
69
70 ViewArray<IntView> xv(home,x);
71 if (pos) {
72 switch (r.mode()) {
73 case RM_EQV:
75 (home,xv,t,r.var())));
76 break;
77 case RM_IMP:
79 (home,xv,t,r.var())));
80 break;
81 case 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:
92 (home,xv,t,n)));
93 break;
94 case RM_IMP:
96 (home,xv,t,n)));
97 break;
98 case RM_PMI:
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");
118
119 ViewArray<BoolView> xv(home,x);
120 if (pos)
122 else
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");
138
139 ViewArray<BoolView> xv(home,x);
140 if (pos) {
141 switch (r.mode()) {
142 case RM_EQV:
144 (home,xv,t,r.var())));
145 break;
146 case RM_IMP:
148 (home,xv,t,r.var())));
149 break;
150 case 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:
161 (home,xv,t,n)));
162 break;
163 case RM_IMP:
165 (home,xv,t,n)));
166 break;
167 case RM_PMI:
169 (home,xv,t,n)));
170 break;
171 default: throw UnknownReifyMode("Int::extensional");
172 }
173 }
174 }
175
176}
177
178// STATISTICS: int-post
Passing Boolean variables.
Definition int.hh:721
Home class for posting propagators
Definition core.hpp:856
Passing integer variables.
Definition int.hh:662
Exception: Arguments are of different size
Definition exception.hpp:73
Negated Boolean view.
Definition view.hpp:1574
Exception: Tuple set not yet finalized
Exception: Not 0/1 integer
Definition exception.hpp:51
Exception: Unknown reification mode passed as argument
Reification specification.
Definition int.hh:891
Class represeting a set of tuples.
Definition int.hh:2206
int max(void) const
Return maximal value in all tuples.
bool finalized(void) const
Is tuple set finalized.
int min(void) const
Return minimal value in all tuples.
int arity(void) const
Arity of tuple set.
View arrays.
Definition array.hpp:253
#define GECODE_POST
Check for failure in a constraint post function.
Definition macros.hpp:40
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition macros.hpp:103
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:989
@ RM_IMP
Implication for reification.
Definition int.hh:877
@ RM_PMI
Inverse implication for reification.
Definition int.hh:884
@ RM_EQV
Equivalence for reification (default)
Definition int.hh:870
ExecStatus postnegcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for compact table propagator.
Definition compact.hpp:955
ExecStatus postposcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table propagator.
Definition compact.hpp:685
ExecStatus postrecompact(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for compact table propagator.
Definition compact.hpp:1192
Finite domain integers.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition set.hh:773
Post propagator for SetVar x
Definition set.hh:773