main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Jul 27 2020 00:00:00 for Gecode by
doxygen
1.8.18
gecode
float
rel
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>
43
forceinline
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>
48
ExecStatus
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>
62
forceinline
63
Nq<View0,View1>::Nq
(
Space
& home,
Nq<View0,View1>
&
p
)
64
:
MixBinaryPropagator
<View0,
PC_FLOAT_VAL
,View1,
PC_FLOAT_VAL
>(home,
p
) {}
65
66
template
<
class
View0,
class
View1>
67
Actor
*
68
Nq<View0,View1>::copy
(
Space
& home) {
69
return
new
(home)
Nq<View0,View1>
(home,*
this
);
70
}
71
72
template
<
class
View0,
class
View1>
73
ExecStatus
74
Nq<View0,View1>::propagate
(
Space
& home,
const
ModEventDelta
&) {
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>
86
forceinline
87
NqFloat<View>::NqFloat
(
Home
home, View
x
,
FloatVal
_c
)
88
:
UnaryPropagator
<View,
PC_FLOAT_VAL
>(home,
x
),
c
(
_c
) {}
89
90
template
<
class
View>
91
ExecStatus
92
NqFloat<View>::post
(
Home
home, View
x
,
FloatVal
c
){
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>
103
forceinline
104
NqFloat<View>::NqFloat
(
Space
& home,
NqFloat<View>
&
p
)
105
:
UnaryPropagator
<View,
PC_FLOAT_VAL
>(home,
p
),
c
(
p
.
c
) {}
106
107
template
<
class
View>
108
Actor
*
109
NqFloat<View>::copy
(
Space
& home) {
110
return
new
(home)
NqFloat<View>
(home,*
this
);
111
}
112
113
template
<
class
View>
114
ExecStatus
115
NqFloat<View>::propagate
(
Space
& home,
const
ModEventDelta
&) {
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
Gecode::Float::PC_FLOAT_VAL
const Gecode::PropCond PC_FLOAT_VAL
Propagate when a view becomes assigned (single value)
Definition:
var-type.hpp:283
Gecode::Float::Rel::NqFloat
Binary bounds consistent disequality propagator with float value.
Definition:
rel.hh:208
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3563
Gecode::Float::Rel::NqFloat::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition:
nq.hpp:109
Gecode::Float::Rel::Nq::post
static ExecStatus post(Home home, View0 x0, View1 x1)
Post bounds consistent propagator .
Definition:
nq.hpp:49
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Test::Int::Precede::_c
Multi _c(Gecode::IntArgs({1, 2, 3}))
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:628
Gecode::VarImpVar::assigned
bool assigned(void) const
Test whether view is assigned.
Definition:
var.hpp:111
Gecode
Gecode toplevel namespace
Gecode::MixBinaryPropagator
Mixed binary propagator.
Definition:
pattern.hpp:204
Gecode::Float::Rel::Nq::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition:
nq.hpp:68
Gecode::Float::Rel::NqFloat::NqFloat
NqFloat(Space &home, NqFloat< View > &p)
Constructor for cloning p.
Definition:
nq.hpp:104
Gecode::Float::Rel::Nq::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
nq.hpp:74
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::Float::Rel::Nq
Binary bounds consistent disequality propagator.
Definition:
rel.hh:180
Gecode::Float::Rel::Nq::Nq
Nq(Space &home, Nq< View0, View1 > &p)
Constructor for cloning p.
Definition:
nq.hpp:63
Gecode::Float::Rel::NqFloat::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
nq.hpp:115
Gecode::FloatVal
Float value type.
Definition:
float.hh:334
Gecode::Float::Rel::NqFloat::post
static ExecStatus post(Home home, View x0, FloatVal c)
Post bounds consistent propagator .
Definition:
nq.hpp:92
Gecode::Float::overlap
bool overlap(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:498
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:477
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::UnaryPropagator
Unary propagator.
Definition:
pattern.hpp:55
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
Gecode::ES_FAILED
@ ES_FAILED
Execution has resulted in failure.
Definition:
core.hpp:474
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition:
core.hpp:476
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:472