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