Generated on Sat Nov 9 2013 19:18:29 for Gecode by doxygen 1.8.4
int.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  * Christian Schulte <schulte@gecode.org>
6  *
7  * Copyright:
8  * Guido Tack, 2004
9  * Christian Schulte, 2004
10  *
11  * Last modified:
12  * $Date: 2012-10-19 05:58:26 +0200 (Fri, 19 Oct 2012) $ by $Author: tack $
13  * $Revision: 13156 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #include <gecode/set.hh>
41 
42 #include <gecode/set/int.hh>
43 #include <gecode/set/rel.hh>
44 
45 namespace Gecode {
46 
47  void
49  if (home.failed()) return;
50  switch (r) {
51  case IRT_EQ:
52  {
54  Set::SingletonView xsingle(xv);
57  ::post(home,s,xsingle)));
58 
59  }
60  break;
61  case IRT_NQ:
62  {
64  GECODE_ME_FAIL( sv.cardMin(home, 1));
66  Set::SingletonView xsingle(xv);
69  ::post(home,xsingle,sv)));
70 
71  }
72  break;
73  case IRT_LQ:
74  {
76  rel(home, tmp, IRT_LQ, x);
78  }
79  break;
80  case IRT_LE:
81  {
83  rel(home, tmp, IRT_LE, x);
85  }
86  break;
87  case IRT_GQ:
88  {
90  rel(home, tmp, IRT_GQ, x);
92  }
93  break;
94  case IRT_GR:
95  {
97  rel(home, tmp, IRT_GR, x);
99  }
100  break;
101  default:
102  throw Int::UnknownRelation("Set::rel");
103  }
104 
105  }
106 
107  void
109  IntRelType rr;
110  switch (r) {
111  case IRT_LE: rr=IRT_GR; break;
112  case IRT_LQ: rr=IRT_GQ; break;
113  case IRT_GR: rr=IRT_LE; break;
114  case IRT_GQ: rr=IRT_LQ; break;
115  default: rr=r;
116  }
117  rel(home, s, rr, x);
118  }
119 
120  void
121  min(Home home, SetVar s, IntVar x){
122  if (home.failed()) return;
124  }
125  void
126  notMin(Home home, SetVar s, IntVar x){
127  if (home.failed()) return;
129  }
130  void
131  min(Home home, SetVar s, IntVar x, Reify r){
132  if (home.failed()) return;
133  switch (r.mode()) {
134  case RM_EQV:
136  ::post(home,s,x,r.var())));
137  break;
138  case RM_IMP:
140  ::post(home,s,x,r.var())));
141  break;
142  case RM_PMI:
144  ::post(home,s,x,r.var())));
145  break;
146  default: throw Gecode::Int::UnknownReifyMode("Set::min");
147  }
148  }
149  void
150  max(Home home, SetVar s, IntVar x){
151  if (home.failed()) return;
153  }
154  void
155  notMax(Home home, SetVar s, IntVar x){
156  if (home.failed()) return;
158  }
159  void
160  max(Home home, SetVar s, IntVar x, Reify r){
161  if (home.failed()) return;
162  switch (r.mode()) {
163  case RM_EQV:
165  ::post(home,s,x,r.var())));
166  break;
167  case RM_IMP:
169  ::post(home,s,x,r.var())));
170  break;
171  case RM_PMI:
173  ::post(home,s,x,r.var())));
174  break;
175  default: throw Gecode::Int::UnknownReifyMode("Set::max");
176  }
177  }
178 
180  SetVar x, IntVar y) {
181  if (home.failed()) return;
183  weights,x,y));
184  }
185 
186 }
187 
188 // STATISTICS: set-post