Generated on Sat Feb 7 2015 02:01:23 for Gecode by doxygen 1.8.9.1
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  * Last modified:
13  * $Date: 2011-08-24 16:34:16 +0200 (Wed, 24 Aug 2011) $ by $Author: tack $
14  * $Revision: 12346 $
15  *
16  * This file is part of Gecode, the generic constraint
17  * development environment:
18  * http://www.gecode.org
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  *
39  */
40 
41 #include <gecode/set.hh>
42 #include <gecode/set/rel.hh>
43 #include <gecode/set/rel-op.hh>
44 
45 namespace Gecode { namespace Set { namespace RelOp {
46 
47  template<class View0, class View1, class Res>
48  forceinline void
49  rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2) {
50  switch(op) {
51  case SOT_DUNION:
52  {
53  EmptyView emptyset;
55  ::post(home, x0, x1, emptyset)));
56  // fall through to SOT_UNION
57  }
58  case SOT_UNION:
59  {
62  ::post(home, x0, x1, x2)));
63  }
64  break;
65  case SOT_INTER:
66  {
68  ::post(home, x0,x1,x2)));
69  }
70  break;
71  case SOT_MINUS:
72  {
73  ComplementView<View1> cx1(x1);
75  (Intersection<View0,
77  ::post(home,x0,cx1,x2)));
78  }
79  break;
80  }
81  }
82 
83  template<class View0, class View1, class View2>
84  forceinline void
85  rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2) {
86  switch(op) {
87  case SOT_DUNION:
88  {
89  EmptyView emptyset;
91  ::post(home, x0, x1, emptyset)));
92  // fall through to SOT_UNION
93  }
94  case SOT_UNION:
95  {
96  SetVar tmp(home);
98  (Rel::Subset<SetView,View2>::post(home,tmp,x2)));
99 
102  ::post(home, x0, x1, tmp)));
103  }
104  break;
105  case SOT_INTER:
106  {
108  ::post(home, x0,x1,x2)));
109  }
110  break;
111  case SOT_MINUS:
112  {
113  ComplementView<View1> cx1(x1);
115  (SuperOfInter<View0,
116  ComplementView<View1>,View2>
117  ::post(home,x0,cx1,x2)));
118  }
119  break;
120  }
121 
122  }
123 
124  template<class View0, class View1, class View2>
125  forceinline void
126  rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2) {
127  switch(op) {
128  case SOT_DUNION:
129  {
130  EmptyView emptyset;
132  ::post(home, x0, x1, emptyset)));
133  // fall through to SOT_UNION
134  }
135  case SOT_UNION:
136  {
139  ::post(home, x0, x1, x2)));
140  }
141  break;
142  case SOT_INTER:
143  {
144  SetVar tmp(home);
146  (Rel::Subset<View2,SetView>::post(home,x2,tmp)));
147 
149  ::post(home, x0,x1,tmp)));
150  }
151  break;
152  case SOT_MINUS:
153  {
154  SetVar tmp(home);
156  (Rel::Subset<View2,SetView>::post(home,x2,tmp)));
157 
158  ComplementView<View1> cx1(x1);
160  (Intersection<View0,
162  ::post(home,x0,cx1,tmp)));
163  }
164  break;
165  }
166 
167  }
168 
169  template<class View>
170  forceinline void
171  rel_op_post_lex(Home home, SetView x0, SetRelType r, View x1) {
172  switch (r) {
173  case SRT_LQ:
175  break;
176  case SRT_LE:
178  break;
179  case SRT_GQ:
181  break;
182  case SRT_GR:
184  break;
185  default:
186  throw UnknownRelation("Set::rel");
187  }
188  }
189 
190  template<class View0, class View1, class View2>
191  forceinline void
192  rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y,
193  SetRelType r, View2 z) {
194  if (home.failed()) return;
195  switch(r) {
196  case SRT_EQ:
197  rel_eq<View0,View1,View2>(home, x, op, y, z);
198  break;
199  case SRT_LQ: case SRT_LE: case SRT_GQ: case SRT_GR:
200  {
202  rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
203  rel_op_post_lex<View2>(home,tmp,r,z);
204  }
205  break;
206  case SRT_NQ:
207  {
208  SetVar tmp(home);
211  ::post(home,tmp,z)));
212  rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
213  }
214  break;
215  case SRT_SUB:
216  rel_sub<View0,View1,View2>(home, x, op, y, z);
217  break;
218  case SRT_SUP:
219  rel_sup<View0,View1,View2>(home, x, op, y, z);
220  break;
221  case SRT_DISJ:
222  {
223  SetVar tmp(home);
224  EmptyView emptyset;
226  ::post(home, z, tmp, emptyset)));
227  rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
228  }
229  break;
230  default:
231  GECODE_NEVER;
232  }
233 
234  }
235 
236  GECODE_SET_EXPORT void
238  SetRelType r, SetView z);
239  GECODE_SET_EXPORT void
241  SetRelType r, SetView z);
242 
243  GECODE_SET_EXPORT void
246 
247  GECODE_SET_EXPORT void
250 
251  GECODE_SET_EXPORT void
252  post_compl(Home home, SetView x, SetOpType op, SetView y, SetView z);
253 
254  GECODE_SET_EXPORT void
256 
257  GECODE_SET_EXPORT void
259 
260  GECODE_SET_EXPORT void
262  ConstSetView z);
263 
264 }}}
265 
266 // STATISTICS: set-prop
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3446
Propagator for negated equality
Definition: rel.hh:261
SetRelType
Common relation types for sets.
Definition: set.hh:644
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:228
const int min
Smallest allowed integer in integer set.
Definition: set.hh:101
void post_nocompl(Home home, ConstSetView x, SetOpType op, SetView y, SetRelType r, ConstSetView z)
Propagator for ternary union
Definition: rel-op.hh:156
Propagator for the subset constraint
Definition: rel.hh:64
Propagator for set less than or equal
Definition: rel.hh:203
SetOpType
Common operations for sets.
Definition: set.hh:661
Superset ( )
Definition: set.hh:648
const int max
Largest allowed integer in integer set.
Definition: set.hh:99
Difference.
Definition: set.hh:665
Propagator for the subset of union
Definition: rel-op.hh:95
Exception: Unknown relation passed as argument
Definition: exception.hpp:91
void rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition: post.hpp:85
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
Less or equal ( )
Definition: set.hh:651
Subset ( )
Definition: set.hh:647
Intersection
Definition: set.hh:664
Less ( )
Definition: set.hh:652
static const IntSet empty
Empty set.
Definition: int.hh:262
Set view for set variables
Definition: view.hpp:60
void rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2)
Definition: post.hpp:49
Union.
Definition: set.hh:662
Greater or equal ( )
Definition: set.hh:653
Constant view.
Definition: view.hpp:190
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Set variables
Definition: set.hh:129
Disjoint union.
Definition: set.hh:663
void rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition: post.hpp:126
#define forceinline
Definition: config.hpp:132
Propagator for the superset of intersection
Definition: rel-op.hh:65
Greater ( )
Definition: set.hh:654
Equality ( )
Definition: set.hh:645
Disjoint ( )
Definition: set.hh:649
Disequality ( )
Definition: set.hh:646
Complement set view.
Definition: view.hpp:754
Gecode toplevel namespace
void post_compl(Home home, ConstSetView x, SetOpType op, SetView y, ConstSetView z)
void rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y, SetRelType r, View2 z)
Definition: post.hpp:192
Constant view for the empty set.
Definition: view.hpp:335
Home class for posting propagators
Definition: core.hpp:717
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition: macros.hpp:96
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
void rel_op_post_lex(Home home, SetView x0, SetRelType r, View x1)
Definition: post.hpp:171
#define GECODE_SET_EXPORT
Definition: set.hh:69
Propagator for ternary intersection
Definition: rel-op.hh:126