main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Jan 10 2020 11:38:25 for Gecode by
doxygen
1.8.16
gecode
int
no-overlap
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
NoOverlap {
35
36
template
<
class
Box>
37
forceinline
38
Base<Box>::Base
(
Home
home, Box* b0,
int
n0)
39
:
Propagator
(home),
b
(b0),
n
(n0) {
40
for
(
int
i
=0;
i
<
n
;
i
++)
41
b
[
i
].
subscribe
(home,*
this
);
42
}
43
44
template
<
class
Box>
45
forceinline
int
46
Base<Box>::partition
(Box*
b
,
int
i
,
int
n
) {
47
int
j =
n
-1;
48
while
(
true
) {
49
while
(!
b
[j].mandatory() && (--j >= 0)) {}
50
while
(
b
[
i
].mandatory() && (++
i
<
n
)) {}
51
if
(j <=
i
)
break
;
52
std::swap
(
b
[
i
],
b
[j]);
53
}
54
return
i
;
55
}
56
57
template
<
class
Box>
58
forceinline
size_t
59
Base<Box>::dispose
(
Space
& home) {
60
for
(
int
i
=0;
i
<
n
;
i
++)
61
b
[
i
].
cancel
(home,*
this
);
62
(void)
Propagator::dispose
(home);
63
return
sizeof
(*this);
64
}
65
66
67
template
<
class
Box>
68
forceinline
69
Base<Box>::Base
(
Space
& home,
Base<Box>
&
p
,
int
m)
70
:
Propagator
(home,
p
),
b
(home.alloc<Box>(m)),
n
(
p
.
n
) {
71
for
(
int
i
=0;
i
<m;
i
++)
72
b
[
i
].
update
(home,
p
.b[
i
]);
73
}
74
75
template
<
class
Box>
76
PropCost
77
Base<Box>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
78
return
PropCost::quadratic
(
PropCost::HI
,Box::dim()*
n
);
79
}
80
81
template
<
class
Box>
82
void
83
Base<Box>::reschedule
(
Space
& home) {
84
for
(
int
i
=0;
i
<
n
;
i
++)
85
b
[
i
].
reschedule
(home,*
this
);
86
}
87
88
}}}
89
90
// STATISTICS: int-prop
91
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::Int::NoOverlap::Base::b
Box * b
Boxes.
Definition:
no-overlap.hh:237
Gecode::Int::NoOverlap::Base::dispose
virtual size_t dispose(Space &home)
Destructor.
Definition:
base.hpp:59
Gecode::Int::NoOverlap::Base::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition:
base.hpp:77
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::PropCost::quadratic
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
Definition:
core.hpp:4787
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1064
Gecode::Int::Count::update
void update(IntSet &y, Space &home, IntSet &py)
Definition:
rel.hpp:103
Gecode::Int::Count::reschedule
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:92
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::Int::NoOverlap::Base::partition
static int partition(Box *b, int i, int n)
Partition n boxes b starting at position i.
Definition:
base.hpp:46
Gecode::Int::NoOverlap::Base::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition:
base.hpp:83
Gecode::swap
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Definition:
irt.hpp:37
Gecode::PropCost
Propagation cost.
Definition:
core.hpp:486
Gecode::Int::Count::cancel
void cancel(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:81
Gecode::Int::NoOverlap::Base
Base class for no-overlap propagator.
Definition:
no-overlap.hh:234
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
Gecode::Int::NoOverlap::Base::n
int n
Number of mandatory boxes: b[0] ... b[n-1].
Definition:
no-overlap.hh:239
Gecode::PropCost::HI
Expensive.
Definition:
core.hpp:514
Gecode::Int::Count::subscribe
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:71
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
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::Int::NoOverlap::Base::Base
Base(Home home, Box *b, int n)
Constructor for posting with n mandatory boxes.
Definition:
base.hpp:38