Generated on Mon Feb 8 2021 00:00:00 for Gecode by doxygen 1.8.20
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  * This file is part of Gecode, the generic constraint
12  * development environment:
13  * http://www.gecode.org
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining
16  * a copy of this software and associated documentation files (the
17  * "Software"), to deal in the Software without restriction, including
18  * without limitation the rights to use, copy, modify, merge, publish,
19  * distribute, sublicense, and/or sell copies of the Software, and to
20  * permit persons to whom the Software is furnished to do so, subject to
21  * the following conditions:
22  *
23  * The above copyright notice and this permission notice shall be
24  * included in all copies or substantial portions of the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33  *
34  */
35 
36 namespace Gecode { namespace Float { namespace Rel {
37 
38  /*
39  * Disequality
40  *
41  */
42  template<class View0, class View1>
44  Nq<View0,View1>::Nq(Home home, View0 x0, View1 x1)
45  : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,x0,x1) {}
46 
47  template<class View0, class View1>
49  Nq<View0,View1>::post(Home home, View0 x0, View1 x1){
50  if (x0.assigned() && x1.assigned()) {
51  if (overlap(x0.val(),x1.val()))
52  return ES_FAILED;
53  } else if (x0 == x1) {
54  return ES_FAILED;
55  } else {
56  (void) new (home) Nq<View0,View1>(home,x0,x1);
57  }
58  return ES_OK;
59  }
60 
61  template<class View0, class View1>
64  : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,p) {}
65 
66  template<class View0, class View1>
67  Actor*
69  return new (home) Nq<View0,View1>(home,*this);
70  }
71 
72  template<class View0, class View1>
75  if (x0.assigned() && x1.assigned()) {
76  return overlap(x0.val(),x1.val()) ? ES_FAILED : home.ES_SUBSUMED(*this);
77  }
78  return ES_FIX;
79  }
80 
81  /*
82  * Disequality with float value
83  *
84  */
85  template<class View>
88  : UnaryPropagator<View,PC_FLOAT_VAL>(home,x), c(_c) {}
89 
90  template<class View>
93  if (x.assigned()) {
94  if (overlap(x.val(),c))
95  return ES_FAILED;
96  } else {
97  (void) new (home) NqFloat<View>(home,x,c);
98  }
99  return ES_OK;
100  }
101 
102  template<class View>
105  : UnaryPropagator<View,PC_FLOAT_VAL>(home,p), c(p.c) {}
106 
107  template<class View>
108  Actor*
110  return new (home) NqFloat<View>(home,*this);
111  }
112 
113  template<class View>
114  ExecStatus
116  if (x0.assigned()) {
117  return (overlap(x0.val(),c)) ? ES_FAILED : home.ES_SUBSUMED(*this);
118  }
119  return ES_FIX;
120  }
121 
122 
123 
124 }}}
125 
126 // STATISTICS: float-prop
const Gecode::PropCond PC_FLOAT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:283
Binary bounds consistent disequality propagator with float value.
Definition: rel.hh:208
Post propagator for SetVar x
Definition: set.hh:767
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3563
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: nq.hpp:109
static ExecStatus post(Home home, View0 x0, View1 x1)
Post bounds consistent propagator .
Definition: nq.hpp:49
Computation spaces.
Definition: core.hpp:1742
Multi _c(Gecode::IntArgs({1, 2, 3}))
Base-class for both propagators and branchers.
Definition: core.hpp:628
bool assigned(void) const
Test whether view is assigned.
Definition: var.hpp:111
Gecode toplevel namespace
Mixed binary propagator.
Definition: pattern.hpp:204
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: nq.hpp:68
NqFloat(Space &home, NqFloat< View > &p)
Constructor for cloning p.
Definition: nq.hpp:104
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: nq.hpp:74
Home class for posting propagators
Definition: core.hpp:856
Binary bounds consistent disequality propagator.
Definition: rel.hh:180
Nq(Space &home, Nq< View0, View1 > &p)
Constructor for cloning p.
Definition: nq.hpp:63
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: nq.hpp:115
Float value type.
Definition: float.hh:334
static ExecStatus post(Home home, View x0, FloatVal c)
Post bounds consistent propagator .
Definition: nq.hpp:92
bool overlap(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:498
@ ES_FIX
Propagation has computed fixpoint.
Definition: core.hpp:477
#define forceinline
Definition: config.hpp:192
Unary propagator.
Definition: pattern.hpp:55
Gecode::FloatVal c(-8, 8)
@ ES_FAILED
Execution has resulted in failure.
Definition: core.hpp:474
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
@ ES_OK
Execution is okay.
Definition: core.hpp:476
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
ExecStatus
Definition: core.hpp:472