Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
post.hpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Guido Tack <tack@gecode.org>
5 *
6 * Contributing authors:
7 * Gabor Szokoli <szokoli@gecode.org>
8 *
9 * Copyright:
10 * Guido Tack, 2004, 2005
11 *
12 * This file is part of Gecode, the generic constraint
13 * development environment:
14 * http://www.gecode.org
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining
17 * a copy of this software and associated documentation files (the
18 * "Software"), to deal in the Software without restriction, including
19 * without limitation the rights to use, copy, modify, merge, publish,
20 * distribute, sublicense, and/or sell copies of the Software, and to
21 * permit persons to whom the Software is furnished to do so, subject to
22 * the following conditions:
23 *
24 * The above copyright notice and this permission notice shall be
25 * included in all copies or substantial portions of the Software.
26 *
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 *
35 */
36
37#include <gecode/set.hh>
38#include <gecode/set/rel.hh>
39#include <gecode/set/rel-op.hh>
40
41namespace Gecode { namespace Set { namespace RelOp {
42
43 template<class View0, class View1, class Res>
44 forceinline void
45 rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2) {
46 switch(op) {
47 case SOT_DUNION:
48 {
49 EmptyView emptyset;
51 ::post(home, x0, x1, emptyset)));
52 // fall through to SOT_UNION
53 }
54 case SOT_UNION:
55 {
58 ::post(home, x0, x1, x2)));
59 }
60 break;
61 case SOT_INTER:
62 {
64 ::post(home, x0,x1,x2)));
65 }
66 break;
67 case SOT_MINUS:
68 {
71 (Intersection<View0,
73 ::post(home,x0,cx1,x2)));
74 }
75 break;
76 }
77 }
78
79 template<class View0, class View1, class View2>
80 forceinline void
81 rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2) {
82 switch(op) {
83 case SOT_DUNION:
84 {
85 EmptyView emptyset;
87 ::post(home, x0, x1, emptyset)));
88 // fall through to SOT_UNION
89 }
90 case SOT_UNION:
91 {
92 SetVar tmp(home);
95
98 ::post(home, x0, x1, tmp)));
99 }
100 break;
101 case SOT_INTER:
102 {
104 ::post(home, x0,x1,x2)));
105 }
106 break;
107 case SOT_MINUS:
108 {
109 ComplementView<View1> cx1(x1);
111 (SuperOfInter<View0,
113 ::post(home,x0,cx1,x2)));
114 }
115 break;
116 }
117
118 }
119
120 template<class View0, class View1, class View2>
121 forceinline void
122 rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2) {
123 switch(op) {
124 case SOT_DUNION:
125 {
126 EmptyView emptyset;
128 ::post(home, x0, x1, emptyset)));
129 // fall through to SOT_UNION
130 }
131 case SOT_UNION:
132 {
135 ::post(home, x0, x1, x2)));
136 }
137 break;
138 case SOT_INTER:
139 {
140 SetVar tmp(home);
142 (Rel::Subset<View2,SetView>::post(home,x2,tmp)));
143
145 ::post(home, x0,x1,tmp)));
146 }
147 break;
148 case SOT_MINUS:
149 {
150 SetVar tmp(home);
152 (Rel::Subset<View2,SetView>::post(home,x2,tmp)));
153
154 ComplementView<View1> cx1(x1);
156 (Intersection<View0,
158 ::post(home,x0,cx1,tmp)));
159 }
160 break;
161 }
162
163 }
164
165 template<class View>
166 forceinline void
168 switch (r) {
169 case SRT_LQ:
171 break;
172 case SRT_LE:
174 break;
175 case SRT_GQ:
177 break;
178 case SRT_GR:
180 break;
181 default:
182 throw UnknownRelation("Set::rel");
183 }
184 }
185
186 template<class View0, class View1, class View2>
187 forceinline void
188 rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y,
189 SetRelType r, View2 z) {
190 if (home.failed()) return;
191 switch(r) {
192 case SRT_EQ:
193 rel_eq<View0,View1,View2>(home, x, op, y, z);
194 break;
195 case SRT_LQ: case SRT_LE: case SRT_GQ: case SRT_GR:
196 {
198 rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
199 rel_op_post_lex<View2>(home,tmp,r,z);
200 }
201 break;
202 case SRT_NQ:
203 {
204 SetVar tmp(home);
207 ::post(home,tmp,z)));
208 rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
209 }
210 break;
211 case SRT_SUB:
213 break;
214 case SRT_SUP:
216 break;
217 case SRT_DISJ:
218 {
219 SetVar tmp(home);
220 EmptyView emptyset;
222 ::post(home, z, tmp, emptyset)));
223 rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
224 }
225 break;
226 default:
228 }
229
230 }
231
238
242
246
249
252
255
259
260}}}
261
262// STATISTICS: set-prop
Home class for posting propagators
Definition core.hpp:856
bool failed(void) const
Check whether corresponding space is failed.
Definition core.hpp:4048
static const IntSet empty
Empty set.
Definition int.hh:283
Exception: Unknown relation passed as argument
Definition exception.hpp:87
Set variables
Definition set.hh:127
Complement set view.
Definition view.hpp:769
Constant view.
Definition view.hpp:186
Constant view for the empty set.
Definition view.hpp:336
Propagator for ternary intersection
Definition rel-op.hh:124
Propagator for the subset of union
Definition rel-op.hh:93
Propagator for the superset of intersection
Definition rel-op.hh:63
Propagator for ternary union
Definition rel-op.hh:154
Propagator for negated equality
Definition rel.hh:268
Propagator for set less than or equal
Definition rel.hh:208
Propagator for the subset constraint
Definition rel.hh:65
Set view for set variables
Definition view.hpp:56
#define GECODE_SET_EXPORT
Definition set.hh:67
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition macros.hpp:103
SetOpType
Common operations for sets.
Definition set.hh:660
SetRelType
Common relation types for sets.
Definition set.hh:643
@ SOT_MINUS
Difference.
Definition set.hh:664
@ SOT_DUNION
Disjoint union.
Definition set.hh:662
@ SOT_UNION
Union.
Definition set.hh:661
@ SOT_INTER
Intersection
Definition set.hh:663
@ SRT_GQ
Greater or equal ( )
Definition set.hh:652
@ SRT_GR
Greater ( )
Definition set.hh:653
@ SRT_LQ
Less or equal ( )
Definition set.hh:650
@ SRT_NQ
Disequality ( )
Definition set.hh:645
@ SRT_LE
Less ( )
Definition set.hh:651
@ SRT_EQ
Equality ( )
Definition set.hh:644
@ SRT_SUP
Superset ( )
Definition set.hh:647
@ SRT_DISJ
Disjoint ( )
Definition set.hh:648
@ SRT_SUB
Subset ( )
Definition set.hh:646
const int min
Smallest allowed integer in integer set.
Definition set.hh:99
const int max
Largest allowed integer in integer set.
Definition set.hh:97
void post_compl(Home home, ConstSetView x, SetOpType op, SetView y, ConstSetView z)
void post_nocompl(Home home, ConstSetView x, SetOpType op, SetView y, SetRelType r, ConstSetView z)
void rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y, SetRelType r, View2 z)
Definition post.hpp:188
void rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2)
Definition post.hpp:45
void rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition post.hpp:122
void rel_op_post_lex(Home home, SetView x0, SetRelType r, View x1)
Definition post.hpp:167
void rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition post.hpp:81
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition set.hh:767
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition set.hh:767
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:767
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition filter.cpp:138
Post propagator for SetVar x
Definition set.hh:767
Post propagator for SetVar SetOpType op
Definition set.hh:767
#define forceinline
Definition config.hpp:187
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56