Generated on Sat Feb 7 2015 02:01:21 for Gecode by doxygen 1.8.9.1
distinct.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  * Gabor Szokoli <szokoli@gecode.org>
6  *
7  * Copyright:
8  * Christian Schulte, 2002
9  * Gabor Szokoli, 2003
10  *
11  * Last modified:
12  * $Date: 2013-02-14 16:29:11 +0100 (Thu, 14 Feb 2013) $ by $Author: schulte $
13  * $Revision: 13292 $
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/int/distinct.hh>
41 
42 namespace Gecode {
43 
44  using namespace Int;
45 
46  void
47  distinct(Home home, const IntVarArgs& x, IntConLevel icl) {
48  if (x.same(home))
49  throw ArgumentSame("Int::distinct");
50  if (home.failed()) return;
51  ViewArray<IntView> xv(home,x);
52  switch (icl) {
53  case ICL_BND:
55  break;
56  case ICL_DOM:
58  break;
59  default:
61  }
62  }
63 
64  void
65  distinct(Home home, const IntArgs& c, const IntVarArgs& x,
66  IntConLevel icl) {
67  if (x.same(home))
68  throw ArgumentSame("Int::distinct");
69  if (c.size() != x.size())
70  throw ArgumentSizeMismatch("Int::distinct");
71  if (home.failed()) return;
72  ViewArray<OffsetView> cx(home,x.size());
73  for (int i = c.size(); i--; ) {
74  long long int cx_min = (static_cast<long long int>(c[i]) +
75  static_cast<long long int>(x[i].min()));
76  long long int cx_max = (static_cast<long long int>(c[i]) +
77  static_cast<long long int>(x[i].max()));
78  Limits::check(c[i],"Int::distinct");
79  Limits::check(cx_min,"Int::distinct");
80  Limits::check(cx_max,"Int::distinct");
81  cx[i] = OffsetView(x[i],c[i]);
82  }
83  switch (icl) {
84  case ICL_BND:
86  break;
87  case ICL_DOM:
89  break;
90  default:
92  }
93  }
94 
95 }
96 
97 // STATISTICS: int-post
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3446
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:937
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1662
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
Domain consistent distinct propagator.
Definition: distinct.hh:251
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i(4, 1, 2, 3, 4)
Offset integer view.
Definition: view.hpp:422
Passing integer variables.
Definition: int.hh:636
Passing integer arguments.
Definition: int.hh:607
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
Naive value distinct propagator.
Definition: distinct.hh:68
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Exception: Arguments contain same variable multiply
Definition: exception.hpp:84
void distinct(Home home, const IntVarArgs &x, IntConLevel icl)
Post propagator for for all .
Definition: distinct.cpp:47
Bounds propagation or consistency.
Definition: int.hh:939
Bounds consistent distinct propagator.
Definition: distinct.hh:129
Gecode toplevel namespace
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
Definition: limits.hpp:50
Home class for posting propagators
Definition: core.hpp:717
Exception: Arguments are of different size
Definition: exception.hpp:77
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition: macros.hpp:96
Domain propagation or consistency.
Definition: int.hh:940
bool same(const Space &home) const
Test whether array contains same variable multiply.
Definition: array.hpp:2085