Generated on Sat Feb 7 2015 02:01:17 for Gecode by doxygen 1.8.9.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
NqFloat(Space &home, bool share, NqFloat< View > &p)
Constructor for cloning p.
Definition: nq.hpp:108
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:2973
Unary propagator.
Definition: propagator.hpp:59
bool overlap(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:502
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: nq.hpp:72
static ExecStatus post(Home home, View x0, FloatVal c)
Post bounds consistent propagator .
Definition: nq.hpp:96
Propagation has computed fixpoint.
Definition: core.hpp:528
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: nq.hpp:78
Computation spaces.
Definition: core.hpp:1362
Base-class for both propagators and branchers.
Definition: core.hpp:666
Binary bounds consistent disequality propagator.
Definition: rel.hh:183
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
bool same(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether two views are the same.
Definition: view.hpp:603
Execution has resulted in failure.
Definition: core.hpp:525
const Gecode::PropCond PC_FLOAT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:283
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: nq.hpp:119
Float value type.
Definition: float.hh:321
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Mixed binary propagator.
Definition: propagator.hpp:203
ExecStatus
Definition: core.hpp:523
#define forceinline
Definition: config.hpp:132
static ExecStatus post(Home home, View0 x0, View1 x1)
Post bounds consistent propagator .
Definition: nq.hpp:53
Execution is okay.
Definition: core.hpp:527
Gecode toplevel namespace
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
Home class for posting propagators
Definition: core.hpp:717
Multi _c(Gecode::IntArgs(3, 1, 2, 3))
Binary bounds consistent disequality propagator with float value.
Definition: rel.hh:211
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: nq.hpp:113
Nq(Space &home, bool share, Nq< View0, View1 > &p)
Constructor for cloning p.
Definition: nq.hpp:67