Generated on Sat May 25 2013 18:00:34 for Gecode by doxygen 1.8.3.1
nq.hpp
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  * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
6  *
7  * Copyright:
8  * Christian Schulte, 2004
9  * Vincent Barichard, 2012
10  *
11  * Last modified:
12  * $Date: 2013-01-24 19:28:06 +0100 (Thu, 24 Jan 2013) $ by $Author: schulte $
13  * $Revision: 13235 $
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 namespace Gecode { namespace Float { namespace Rel {
41 
42  /*
43  * Disequality
44  *
45  */
46  template<class View0, class View1>
48  Nq<View0,View1>::Nq(Home home, View0 x0, View1 x1)
49  : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,x0,x1) {}
50 
51  template<class View0, class View1>
53  Nq<View0,View1>::post(Home home, View0 x0, View1 x1){
54  if (x0.assigned() && x1.assigned()) {
55  if (overlap(x0.val(),x1.val()))
56  return ES_FAILED;
57  } else if (same(x0,x1)) {
58  return ES_FAILED;
59  } else {
60  (void) new (home) Nq<View0,View1>(home,x0,x1);
61  }
62  return ES_OK;
63  }
64 
65  template<class View0, class View1>
68  : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,share,p) {}
69 
70  template<class View0, class View1>
71  Actor*
72  Nq<View0,View1>::copy(Space& home, bool share) {
73  return new (home) Nq<View0,View1>(home,share,*this);
74  }
75 
76  template<class View0, class View1>
79  if (x0.assigned() && x1.assigned()) {
80  return overlap(x0.val(),x1.val()) ? ES_FAILED : home.ES_SUBSUMED(*this);
81  }
82  return ES_FIX;
83  }
84 
85  /*
86  * Disequality with float value
87  *
88  */
89  template<class View>
92  : UnaryPropagator<View,PC_FLOAT_VAL>(home,x), c(_c) {}
93 
94  template<class View>
97  if (x.assigned()) {
98  if (overlap(x.val(),c))
99  return ES_FAILED;
100  } else {
101  (void) new (home) NqFloat<View>(home,x,c);
102  }
103  return ES_OK;
104  }
105 
106  template<class View>
109  : UnaryPropagator<View,PC_FLOAT_VAL>(home,share,p), c(p.c) {}
110 
111  template<class View>
112  Actor*
113  NqFloat<View>::copy(Space& home, bool share) {
114  return new (home) NqFloat<View>(home,share,*this);
115  }
116 
117  template<class View>
118  ExecStatus
120  if (x0.assigned()) {
121  return (overlap(x0.val(),c)) ? ES_FAILED : home.ES_SUBSUMED(*this);
122  }
123  return ES_FIX;
124  }
125 
126 
127 
128 }}}
129 
130 // STATISTICS: float-prop