Generated on Sat Feb 7 2015 02:01:30 for Gecode by doxygen 1.8.9.1
rel-op-const-vcc.cpp
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 {
46  using namespace Gecode::Set;
47  using namespace Gecode::Set::Rel;
48  using namespace Gecode::Set::RelOp;
49 
50  void
51  rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
52  const IntSet& z) {
53  Set::Limits::check(y, "Set::rel");
54  Set::Limits::check(z, "Set::rel");
55  ConstSetView yv(home, y);
56  ConstSetView zv(home, z);
57 
58  if (op==SOT_MINUS) {
59  switch (r) {
60  case SRT_EQ:
61  {
64  IntSet yc(yrc);
65  ConstSetView cy(home, yc);
69  ::post(home,cy,x,zv)));
70  }
71  break;
72  case SRT_LQ: case SRT_LE: case SRT_GQ: case SRT_GR:
73  {
76  IntSet yc(yrc);
77  ConstSetView cy(home, yc);
82  ::post(home,cy,x,tmp)));
83  dom(home,tmp,r,z);
84  }
85  break;
86  case SRT_NQ:
87  {
88  SetVar tmp(home);
91  ::post(home,tmp,zv)));
94  IntSet yc(yrc);
95  ConstSetView cy(home, yc);
99  ::post(home,cy,x,tmp)));
100  }
101  break;
102  case SRT_SUB:
103  {
106  IntSet yc(yrc);
107  ConstSetView cy(home, yc);
110  ::post(home,cy,x,zv)));
111 
112  }
113  break;
114  case SRT_SUP:
115  {
116  // z <= tmp
117  SetVar tmp(home,z,Limits::min, Limits::max);
118  SetView xv(x);
119 
122  IntSet yc(yrc);
123  ConstSetView cy(home, yc);
124 
128  ::post(home,cy,xv,tmp)));
129  }
130  break;
131  case SRT_DISJ:
132  {
133  SetVar tmp(home);
134  SetView tmpv(tmp);
135  IntSetRanges zi(z);
136  GECODE_ME_FAIL( tmpv.excludeI(home, zi));
137 
140  IntSet yc(yrc);
141  ConstSetView cy(home, yc);
145  ::post(home,cy,x,tmp)));
146  }
147  break;
148  case SRT_CMPL:
149  {
150  SetView xv(x);
155  ConstSetView>::post(home, yv, cx, zv)));
156  }
157  break;
158  default:
159  throw UnknownRelation("Set::rel");
160  }
161  } else {
162  rel(home, y, op, x, r, z);
163  }
164  }
165 
166 }
167 
168 // STATISTICS: set-post
Range iterator for greatest lower bound of constant set view
Definition: const.hpp:668
Propagator for negated equality
Definition: rel.hh:261
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l...
Definition: limits.hpp:41
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
Range iterator for integer sets.
Definition: int.hh:271
Propagator for ternary union
Definition: rel-op.hh:156
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition: dom.cpp:44
SetOpType
Common operations for sets.
Definition: set.hh:661
Superset ( )
Definition: set.hh:648
ModEvent excludeI(Space &home, I &i)
Remove range sequence described by i from least upper bound.
Definition: set.hpp:164
Complement.
Definition: set.hh:650
const int max
Largest allowed integer in integer set.
Definition: set.hh:99
Difference.
Definition: set.hh:665
Exception: Unknown relation passed as argument
Definition: exception.hpp:91
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
Less or equal ( )
Definition: set.hh:651
A complement iterator spezialized for the BndSet limits.
Definition: var-imp.hpp:296
Subset ( )
Definition: set.hh:647
Integer sets.
Definition: int.hh:171
Less ( )
Definition: set.hh:652
static const IntSet empty
Empty set.
Definition: int.hh:262
Standard set operation propagators.
Definition: common.hpp:81
Set view for set variables
Definition: view.hpp:60
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
Standard set relation propagators.
Definition: common.hpp:57
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
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
#define GECODE_ME_FAIL(me)
Check whether modification event me is failed, and fail space home.
Definition: macros.hpp:70
Finite integer sets.
Definition: var-imp.hpp:115
Disequality ( )
Definition: set.hh:646
Complement set view.
Definition: view.hpp:754
Gecode toplevel namespace
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
Propagator for ternary intersection
Definition: rel-op.hh:126