Generated on Wed Sep 5 2012 18:51:49 for Gecode by doxygen 1.8.1.1
dom.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2004
8  *
9  * Last modified:
10  * $Date: 2010-03-04 03:40:32 +1100 (Thu, 04 Mar 2010) $ by $Author: schulte $
11  * $Revision: 10365 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 
39 #include <gecode/int/dom.hh>
40 #include <gecode/int/rel.hh>
41 
42 namespace Gecode {
43 
44  using namespace Int;
45 
46  void
47  dom(Home home, IntVar x, int n, IntConLevel) {
48  Limits::check(n,"Int::dom");
49  if (home.failed()) return;
50  IntView xv(x);
51  GECODE_ME_FAIL(xv.eq(home,n));
52  }
53 
54  void
55  dom(Home home, const IntVarArgs& x, int n, IntConLevel) {
56  Limits::check(n,"Int::dom");
57  if (home.failed()) return;
58  for (int i=x.size(); i--; ) {
59  IntView xv(x[i]);
60  GECODE_ME_FAIL(xv.eq(home,n));
61  }
62  }
63 
64  void
65  dom(Home home, IntVar x, int min, int max, IntConLevel) {
66  Limits::check(min,"Int::dom");
67  Limits::check(max,"Int::dom");
68  if (home.failed()) return;
69  IntView xv(x);
70  GECODE_ME_FAIL(xv.gq(home,min));
71  GECODE_ME_FAIL(xv.lq(home,max));
72  }
73 
74  void
75  dom(Home home, const IntVarArgs& x, int min, int max, IntConLevel) {
76  Limits::check(min,"Int::dom");
77  Limits::check(max,"Int::dom");
78  if (home.failed()) return;
79  for (int i=x.size(); i--; ) {
80  IntView xv(x[i]);
81  GECODE_ME_FAIL(xv.gq(home,min));
82  GECODE_ME_FAIL(xv.lq(home,max));
83  }
84  }
85 
86  void
87  dom(Home home, IntVar x, const IntSet& is, IntConLevel) {
88  Limits::check(is.min(),"Int::dom");
89  Limits::check(is.max(),"Int::dom");
90  if (home.failed()) return;
91  IntView xv(x);
92  IntSetRanges ris(is);
93  GECODE_ME_FAIL(xv.inter_r(home,ris,false));
94  }
95 
96  void
97  dom(Home home, const IntVarArgs& x, const IntSet& is, IntConLevel) {
98  Limits::check(is.min(),"Int::dom");
99  Limits::check(is.max(),"Int::dom");
100  if (home.failed()) return;
101  for (int i = x.size(); i--; ) {
102  IntSetRanges ris(is);
103  IntView xv(x[i]);
104  GECODE_ME_FAIL(xv.inter_r(home,ris,false));
105  }
106  }
107 
108  void
109  dom(Home home, IntVar x, int n, BoolVar b, IntConLevel) {
110  Limits::check(n,"Int::dom");
111  if (home.failed()) return;
113  }
114 
115  void
116  dom(Home home, IntVar x, int min, int max, BoolVar b, IntConLevel) {
117  Limits::check(min,"Int::dom");
118  Limits::check(max,"Int::dom");
119  if (home.failed()) return;
120  GECODE_ES_FAIL(Dom::ReRange<IntView>::post(home,x,min,max,b));
121  }
122 
123 
124  void
125  dom(Home home, IntVar x, const IntSet& is, BoolVar b, IntConLevel) {
126  Limits::check(is.min(),"Int::dom");
127  Limits::check(is.max(),"Int::dom");
128  if (home.failed()) return;
130  }
131 
132 }
133 
134 // STATISTICS: int-post
135