this repo has no description
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, 2002
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34namespace Gecode {
35
36 namespace Int { namespace Linear {
37
38 /**
39 * \brief No view serves as filler for empty view arrays
40 *
41 */
42 class NoView : public ConstView<IntView> {
43 public:
44 /// \name Constructors and initialization
45 //@{
46 /// Default constructor
47 NoView(void) {}
48 //@}
49
50 /// \name Value access
51 //@{
52 /// Return minimum of domain
53 int min(void) const { return 0; }
54 /// Return maximum of domain
55 int max(void) const { return 0; }
56 /// Return median of domain (greatest element not greater than the median)
57 int med(void) const { return 0; }
58 /// Return assigned value (only if assigned)
59 int val(void) const { return 0; }
60
61 /// Return size (cardinality) of domain
62 unsigned int size(void) const { return 1; }
63 /// Return width of domain (distance between maximum and minimum)
64 unsigned int width(void) const { return 1; }
65 /// Return regret of domain minimum (distance to next larger value)
66 unsigned int regret_min(void) const { return 0; }
67 /// Return regret of domain maximum (distance to next smaller value)
68 unsigned int regret_max(void) const { return 0; }
69 //@}
70
71 /// \name Domain tests
72 //@{
73 /// Test whether domain is a range
74 bool range(void) const { return true; }
75 /// Test whether view is assigned
76 bool assigned(void) const { return true; }
77
78 /// Test whether \a n is contained in domain
79 bool in(int n) const { (void) n; return false; }
80 /// Test whether \a n is contained in domain
81 bool in(long long int n) const { (void) n; return false; }
82 //@}
83
84 /// \name Domain update by value
85 //@{
86 /// Restrict domain values to be less or equal than \a n
87 ModEvent lq(Space& home, int n) {
88 (void) home; (void) n;
89 return ME_INT_NONE;
90 }
91 /// Restrict domain values to be less or equal than \a n
92 ModEvent lq(Space& home, long long int n) {
93 (void) home; (void) n;
94 return ME_INT_NONE;
95 }
96 /// Restrict domain values to be less than \a n
97 ModEvent le(Space& home, int n) {
98 (void) home; (void) n;
99 return ME_INT_NONE;
100 }
101 /// Restrict domain values to be less than \a n
102 ModEvent le(Space& home, long long int n) {
103 (void) home; (void) n;
104 return ME_INT_NONE;
105 }
106 /// Restrict domain values to be greater or equal than \a n
107 ModEvent gq(Space& home, int n) {
108 (void) home; (void) n;
109 return ME_INT_NONE;
110 }
111 /// Restrict domain values to be greater or equal than \a n
112 ModEvent gq(Space& home, long long int n) {
113 (void) home; (void) n;
114 return ME_INT_NONE;
115 }
116 /// Restrict domain values to be greater than \a n
117 ModEvent gr(Space& home, int n) {
118 (void) home; (void) n;
119 return ME_INT_NONE;
120 }
121 /// Restrict domain values to be greater than \a n
122 ModEvent gr(Space& home, long long int n) {
123 (void) home; (void) n;
124 return ME_INT_NONE;
125 }
126 /// Restrict domain values to be different from \a n
127 ModEvent nq(Space& home, int n) {
128 (void) home; (void) n;
129 return ME_INT_NONE;
130 }
131 /// Restrict domain values to be different from \a n
132 ModEvent nq(Space& home, long long int n) {
133 (void) home; (void) n;
134 return ME_INT_NONE;
135 }
136 /// Restrict domain values to be equal to \a n
137 ModEvent eq(Space& home, int n) {
138 (void) home; (void) n;
139 return ME_INT_NONE;
140 }
141 /// Restrict domain values to be equal to \a n
142 ModEvent eq(Space& home, long long int n) {
143 (void) home; (void) n;
144 return ME_INT_NONE;
145 }
146 //@}
147 };
148
149 /**
150 * \brief Print integer variable view
151 * \relates Gecode::Int::Linear::NoView
152 */
153 template<class Char, class Traits>
154 std::basic_ostream<Char,Traits>&
155 operator <<(std::basic_ostream<Char,Traits>& os, const NoView&) { return os; }
156
157 }}
158
159
160 /**
161 * \brief View array for no view (empty)
162 *
163 */
164 template<>
165 class ViewArray<Int::Linear::NoView> {
166 public:
167 /// \name Constructors and initialization
168 //@{
169 /// Default constructor (array of size 0)
170 ViewArray(void) {}
171 /// Allocate array with \a m variables
172 ViewArray(Space& home, int m) { (void) home; (void) m; }
173 /// Initialize
174 ViewArray(const ViewArray<Int::Linear::NoView>&) {}
175 /// Initialize
176 ViewArray(Space&, const ViewArray<Int::Linear::NoView>&) {}
177 /// Initialize
178 const ViewArray<Int::Linear::NoView>& operator =(const ViewArray<Int::Linear::NoView>&) { return *this; }
179 //@}
180
181 /// \name Array size
182 //@{
183 /// Return size of array (number of elements)
184 int size(void) const { return 0; }
185 /// Decrease size of array (number of elements)
186 void size(int n) { (void) n; }
187 //@}
188
189 /// \name Array elements
190 //@{
191 /// Return view at position \a i
192 Int::Linear::NoView operator [](int i) {
193 (void) i;
194 Int::Linear::NoView n;
195 return n;
196 }
197 /// Return view at position \a i
198 const Int::Linear::NoView operator [](int i) const {
199 (void) i;
200 Int::Linear::NoView n;
201 return n;
202 }
203 //@}
204
205 /// \name Dependencies
206 //@{
207 /// Subscribe propagator \a p with propagation condition \a pc to all views
208 void subscribe(Space&, Propagator& p, PropCond pc, bool process=true) {
209 (void) p; (void) pc; (void) process;
210 }
211 /// Cancel subscription of propagator \a p with propagation condition \a pc to all views
212 void cancel(Space& home, Propagator& p, PropCond pc) {
213 (void) home; (void) p; (void) pc;
214 }
215 /// Schedule propagator \a p
216 void reschedule(Space& home, Propagator& p, PropCond pc) {
217 (void) home; (void) p; (void) pc;
218 }
219 //@}
220
221 /// \name Cloning
222 //@{
223 /// Update array to be a clone of array \a a
224 void update(Space& home, ViewArray<Int::Linear::NoView>& a) {
225 (void) home; (void) a;
226 }
227 //@}
228
229 /// \name Moving elements
230 //@{
231 /// Move assigned view from position 0 to position \a i (shift elements to the left)
232 void move_fst(int i) { (void) i; }
233 /// Move assigned view from position \c size()-1 to position \a i (truncate array by one)
234 void move_lst(int i) { (void) i; }
235 //@}
236 private:
237 static void* operator new(size_t);
238 static void operator delete(void*,size_t);
239 };
240
241}
242
243
244// STATISTICS: int-prop
245