Generated on Sat Feb 7 2015 02:01:30 for Gecode by doxygen 1.8.9.1
rel-op-singleton.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: 2010-03-03 17:40:32 +0100 (Wed, 03 Mar 2010) $ by $Author: schulte $
14  * $Revision: 10365 $
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/rel-op.hh>
42 
43 namespace Gecode {
44  using namespace Gecode::Set;
45  using namespace Gecode::Set::Rel;
46  using namespace Gecode::Set::RelOp;
47 
48  void
49  rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y) {
50  if (home.failed()) return;
51  ViewArray<SingletonView> xa(home,x.size());
52  for (int i=x.size(); i--;) {
53  Int::IntView iv(x[i]);
54  SingletonView sv(iv);
55  xa[i] = sv;
56  }
57 
58  switch (op) {
59  case SOT_UNION:
61  ::post(home, xa, y)));
62  break;
63  case SOT_DUNION:
65  ::post(home, xa, y)));
66  break;
67  case SOT_INTER:
70  ::post(home, xa, y)));
71  break;
72  case SOT_MINUS:
73  throw IllegalOperation("Set::rel");
74  break;
75  default:
76  throw UnknownOperation("Set::rel");
77  }
78  }
79 
80  void
81  rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z,
82  SetVar y) {
83  if (home.failed()) return;
84  Set::Limits::check(z, "Set::rel");
85  ViewArray<SingletonView> xa(home,x.size());
86  for (int i=x.size(); i--;) {
87  Int::IntView iv(x[i]);
88  SingletonView sv(iv);
89  xa[i] = sv;
90  }
91 
92  switch (op) {
93  case SOT_UNION:
95  ::post(home, xa, z, y)));
96  break;
97  case SOT_DUNION:
99  ::post(home, xa, z, y)));
100  break;
101  case SOT_INTER:
104  ::post(home, xa, z, y)));
105  break;
106  case SOT_MINUS:
107  throw IllegalOperation("set::rel");
108  break;
109  default:
110  throw UnknownOperation("Set::rel");
111  }
112  }
113 }
114 
115 // STATISTICS: set-post
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3446
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
Propagator for nary union
Definition: rel-op.hh:221
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:228
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1662
Exception: Unknown operation passed as argument
Definition: exception.hpp:98
SetOpType
Common operations for sets.
Definition: set.hh:661
Difference.
Definition: set.hh:665
Gecode::IntArgs i(4, 1, 2, 3, 4)
Exception: Illegal operation passed as argument
Definition: exception.hpp:105
Propagator for nary partition
Definition: rel-op.hh:257
Intersection
Definition: set.hh:664
Integer sets.
Definition: int.hh:171
View arrays.
Definition: array.hpp:234
Passing integer variables.
Definition: int.hh:636
Singleton set view.
Definition: view.hpp:589
Standard set operation propagators.
Definition: common.hpp:81
Union.
Definition: set.hh:662
Integer view for integer variables.
Definition: view.hpp:129
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
Standard set relation propagators.
Definition: common.hpp:57
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
Finite integer sets.
Definition: var-imp.hpp:115
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 nary intersection
Definition: rel-op.hh:186