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
idx-view.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
* Contributing authors:
7
* Guido Tack <tack@gecode.org>
8
*
9
* Copyright:
10
* Christian Schulte, 2004
11
* Guido Tack, 2004
12
*
13
* Last modified:
14
* $Date: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
15
* $Revision: 15137 $
16
*
17
* This file is part of Gecode, the generic constraint
18
* development environment:
19
* http://www.gecode.org
20
*
21
* Permission is hereby granted, free of charge, to any person obtaining
22
* a copy of this software and associated documentation files (the
23
* "Software"), to deal in the Software without restriction, including
24
* without limitation the rights to use, copy, modify, merge, publish,
25
* distribute, sublicense, and/or sell copies of the Software, and to
26
* permit persons to whom the Software is furnished to do so, subject to
27
* the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be
30
* included in all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
*
40
*/
41
42
namespace
Gecode
{
namespace
Int {
43
45
template
<>
46
class
ViewToVarArg
<
IntView
> {
47
public
:
48
typedef
IntVarArgs
argtype
;
49
};
51
template
<>
52
class
ViewToVarArg
<
MinusView
> {
53
public
:
54
typedef
IntVarArgs
argtype
;
55
};
57
template
<>
58
class
ViewToVarArg
<
BoolView
> {
59
public
:
60
typedef
BoolVarArgs
argtype
;
61
};
62
63
template
<
class
View>
64
forceinline
IdxView<View>
*
65
IdxView<View>::allocate
(
Space
& home,
int
n
) {
66
return
home.
alloc
<
IdxView<View>
>(
n
);
67
}
68
69
template
<
class
View>
70
forceinline
71
IdxViewArray<View>::IdxViewArray
(
void
) : xs(NULL),
n
(0) {}
72
73
template
<
class
View>
74
forceinline
75
IdxViewArray<View>::IdxViewArray
(
const
IdxViewArray<View>
&
a
) {
76
n
=
a
.n; xs =
a
.xs;
77
}
78
79
template
<
class
View>
80
forceinline
81
IdxViewArray<View>::IdxViewArray
(
Space
& home,
82
const
typename
ViewToVarArg<View>::argtype
& xa) : xs(NULL) {
83
n
= xa.size();
84
if
(
n
>0) {
85
xs =
IdxView<View>::allocate
(home,
n
);
86
for
(
int
i
=
n
;
i
--; ) {
87
xs[
i
].idx =
i
; xs[
i
].view = xa[
i
];
88
}
89
}
90
}
91
92
template
<
class
View>
93
forceinline
94
IdxViewArray<View>::IdxViewArray
(
Space
& home,
int
n0) : xs(NULL) {
95
n
= n0;
96
if
(
n
>0) {
97
xs =
IdxView<View>::allocate
(home,
n
);
98
}
99
}
100
101
template
<
class
View>
102
forceinline
int
103
IdxViewArray<View>::size
(
void
)
const
{
104
return
n
;
105
}
106
107
template
<
class
View>
108
forceinline
void
109
IdxViewArray<View>::size
(
int
n0) {
110
n
= n0;
111
}
112
113
template
<
class
View>
114
forceinline
IdxView<View>
&
115
IdxViewArray<View>::operator []
(
int
i
) {
116
assert((
i
>= 0) && (
i
<
size
()));
117
return
xs[
i
];
118
}
119
120
template
<
class
View>
121
forceinline
const
IdxView<View>
&
122
IdxViewArray<View>::operator []
(
int
i
)
const
{
123
assert((
i
>= 0) && (
i
<
size
()));
124
return
xs[
i
];
125
}
126
127
template
<
class
View>
128
forceinline
void
129
IdxViewArray<View>::subscribe
(
Space
& home,
Propagator
&
p
,
PropCond
pc,
130
bool
process) {
131
for
(
int
i
=
n
;
i
--; )
132
xs[
i
].view.subscribe(home,
p
,pc,process);
133
}
134
135
template
<
class
View>
136
forceinline
void
137
IdxViewArray<View>::cancel
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
138
for
(
int
i
=
n
;
i
--; )
139
xs[
i
].view.cancel(home,
p
,pc);
140
}
141
142
template
<
class
View>
143
forceinline
void
144
IdxViewArray<View>::reschedule
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
145
for
(
int
i
=
n
;
i
--; )
146
xs[
i
].view.reschedule(home,
p
,pc);
147
}
148
149
template
<
class
View>
150
forceinline
void
151
IdxViewArray<View>::update
(
Space
& home,
bool
share,
IdxViewArray<View>
&
a
) {
152
n
=
a
.size();
153
if
(
n
>0) {
154
xs =
IdxView<View>::allocate
(home,
n
);
155
for
(
int
i
=
n
;
i
--; ) {
156
xs[
i
].idx =
a
[
i
].idx;
157
xs[
i
].view.update(home,share,
a
[
i
].view);
158
}
159
}
160
}
161
162
163
template
<
class
Char,
class
Traits,
class
View>
164
std::basic_ostream<Char,Traits>&
165
operator <<
(std::basic_ostream<Char,Traits>& os,
166
const
IdxViewArray<View>
&
x
) {
167
std::basic_ostringstream<Char,Traits> s;
168
s.copyfmt(os); s.width(0);
169
s <<
'{'
;
170
if
(
x
.size() > 0) {
171
s <<
x
[0].idx <<
':'
<<
x
[0].view;
172
for
(
int
i
=1;
i
<
x
.size();
i
++)
173
s <<
", "
<<
x
[
i
].idx <<
':'
<<
x
[
i
].view;
174
}
175
s <<
'}'
;
176
return
os << s.str();
177
}
178
179
}}
180
181
// STATISTICS: int-prop
182
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::Int::IdxViewArray
An array of IdxView pairs.
Definition:
idx-view.hh:71
Gecode::Int::IdxView::allocate
static IdxView * allocate(Space &home, int n)
Allocate memory for n index-view pairs.
Definition:
idx-view.hpp:65
Gecode::IntVarArgs
Passing integer variables.
Definition:
int.hh:639
Gecode::Iter::Ranges::size
unsigned int size(I &i)
Size of all ranges of range iterator i.
Definition:
ranges-operations.hpp:78
Gecode::Int::MinusView
Minus integer view.
Definition:
view.hpp:276
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::Int::ViewToVarArg
Class to map VarArg type to view.
Definition:
idx-view.hh:64
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::Int::BoolView
Boolean view for Boolean variables.
Definition:
view.hpp:1315
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1092
Gecode::Float::FloatView::operator<<
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
Definition:
print.hpp:62
x
Node * x
Pointer to corresponding Boolean expression node.
Definition:
bool-expr.cpp:253
Gecode::Int::Count::reschedule
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:96
Gecode::BoolVarArgs
Passing Boolean variables.
Definition:
int.hh:693
a
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::Int::ViewToVarArg< MinusView >::argtype
IntVarArgs argtype
Definition:
idx-view.hpp:54
Gecode::Space::alloc
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Definition:
core.hpp:2868
Gecode::Int::ViewToVarArg< IntView >::argtype
IntVarArgs argtype
Definition:
idx-view.hpp:48
Gecode::PropCond
int PropCond
Type for propagation conditions.
Definition:
core.hpp:152
Gecode::Int::Count::cancel
void cancel(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:85
Gecode::Int::IdxViewArray::IdxViewArray
IdxViewArray(void)
Default constructor.
Definition:
idx-view.hpp:71
Gecode::Int::IntView
Integer view for integer variables.
Definition:
view.hpp:129
Gecode::Int::ViewToVarArg< BoolView >::argtype
BoolVarArgs argtype
Definition:
idx-view.hpp:60
Gecode::Int::IdxView
Class for pair of index and view.
Definition:
idx-view.hh:52
Gecode::Int::Count::subscribe
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:75
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:238
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236