main page
modules
namespaces
classes
files
Gecode home
Generated on Wed Jan 1 2020 10:37:59 for Gecode by
doxygen
1.8.16
gecode
int
nvalues
bool-base.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
*
6
* Copyright:
7
* Christian Schulte, 2011
8
*
9
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
namespace
Gecode
{
namespace
Int {
namespace
NValues {
35
36
template
<
class
VY>
37
forceinline
38
BoolBase<VY>::BoolBase
(
Home
home,
39
int
status0,
ViewArray<BoolView>
&
x
, VY y0)
40
:
Propagator
(home), status(status0),
c
(home),
y
(y0) {
41
y
.subscribe(home,*
this
,
PC_INT_BND
);
42
for
(
int
i
=0;
i
<
x
.size();
i
++) {
43
assert(!
x
[
i
].
assigned
());
44
(void)
new
(home)
ViewAdvisor<BoolView>
(home, *
this
,
c
,
x
[
i
]);
45
}
46
}
47
48
template
<
class
VY>
49
forceinline
50
BoolBase<VY>::BoolBase
(
Space
& home,
BoolBase<VY>
&
p
)
51
:
Propagator
(home,
p
), status(
p
.status) {
52
c
.update(home,
p
.c);
53
y
.update(home,
p
.y);
54
}
55
56
template
<
class
VY>
57
PropCost
58
BoolBase<VY>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
59
return
PropCost::unary
(
PropCost::LO
);
60
}
61
62
template
<
class
VY>
63
void
64
BoolBase<VY>::reschedule
(
Space
& home) {
65
y
.reschedule(home,*
this
,
PC_INT_BND
);
66
}
67
68
template
<
class
VY>
69
ExecStatus
70
BoolBase<VY>::advise
(
Space
& home,
Advisor
&
_a
,
const
Delta
&) {
71
ViewAdvisor<BoolView>
&
a
(
static_cast<
ViewAdvisor<BoolView>
&
>
(
_a
));
72
ExecStatus
es;
73
if
(status == (VS_ZERO | VS_ONE)) {
74
// Everything is already decided
75
es =
ES_FIX
;
76
}
else
{
77
if
(
a
.view().zero())
78
status |= VS_ZERO;
79
else
80
status |= VS_ONE;
81
es =
ES_NOFIX
;
82
}
83
a
.dispose(home,
c
);
84
if
(
c
.empty())
85
es =
ES_NOFIX
;
86
return
es;
87
}
88
89
template
<
class
VY>
90
forceinline
size_t
91
BoolBase<VY>::dispose
(
Space
& home) {
92
c
.dispose(home);
93
y
.cancel(home,*
this
,
PC_INT_BND
);
94
(void)
Propagator::dispose
(home);
95
return
sizeof
(*this);
96
}
97
98
}}}
99
100
// STATISTICS: int-prop
Gecode::Int::NValues::BoolBase::BoolBase
BoolBase(Home home, int status, ViewArray< BoolView > &x, VY y)
Constructor for posting.
Definition:
bool-base.hpp:38
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:767
Gecode::Int::NValues::BoolBase::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition:
bool-base.hpp:64
Gecode::Int::NValues::BoolBase::y
VY y
The view for counting the number of values.
Definition:
nvalues.hh:304
Test::Int::Precede::_a
Single _a(2, 3)
Gecode::Int::Precede::assigned
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition:
single.hpp:43
Gecode::Int::NValues::BoolBase::advise
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition:
bool-base.hpp:70
Gecode::PropCost::LO
Cheap.
Definition:
core.hpp:513
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::ViewAdvisor
Advisor storing a single view
Definition:
advisor.hpp:43
Gecode::Int::NValues::BoolBase::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition:
bool-base.hpp:91
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1064
a
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition:
core.hpp:204
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::Int::NValues::BoolBase
Number of values propagator for Boolean views base class.
Definition:
nvalues.hh:293
Gecode::PropCost::unary
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition:
core.hpp:4813
Gecode::Int::NValues::BoolBase::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition:
bool-base.hpp:58
Gecode::Int::PC_INT_BND
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition:
var-type.hpp:91
Gecode::PropCost
Propagation cost.
Definition:
core.hpp:486
Gecode::Advisor
Base-class for advisors.
Definition:
core.hpp:1292
Gecode::ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:477
Gecode::Int::NValues::BoolBase::c
Council< ViewAdvisor< BoolView > > c
The advisor council.
Definition:
nvalues.hh:302
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Actor::dispose
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition:
core.hpp:3252
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
Gecode::ViewArray< BoolView >
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
Gecode::ES_NOFIX
Propagation has not computed fixpoint.
Definition:
core.hpp:475
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:472