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
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
* 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 {
39
41
template
<>
42
class
ViewToVarArg
<
IntView
> {
43
public
:
44
typedef
IntVarArgs
argtype
;
45
};
47
template
<>
48
class
ViewToVarArg
<
MinusView
> {
49
public
:
50
typedef
IntVarArgs
argtype
;
51
};
53
template
<>
54
class
ViewToVarArg
<
BoolView
> {
55
public
:
56
typedef
BoolVarArgs
argtype
;
57
};
59
template
<>
60
class
ViewToVarArg
<
NegBoolView
> {
61
public
:
62
typedef
BoolVarArgs
argtype
;
63
};
64
65
template
<
class
View>
66
forceinline
IdxView<View>
*
67
IdxView<View>::allocate
(
Space
& home,
int
n
) {
68
return
home.
alloc
<
IdxView<View>
>(
n
);
69
}
70
71
template
<
class
View>
72
forceinline
73
IdxViewArray<View>::IdxViewArray
(
void
) : xs(NULL),
n
(0) {}
74
75
template
<
class
View>
76
forceinline
77
IdxViewArray<View>::IdxViewArray
(
const
IdxViewArray<View>
&
a
) {
78
n
=
a
.n; xs =
a
.xs;
79
}
80
81
template
<
class
View>
82
forceinline
83
IdxViewArray<View>::IdxViewArray
(
Space
& home,
84
const
typename
ViewToVarArg<View>::argtype
& xa) : xs(NULL) {
85
n
= xa.size();
86
if
(
n
>0) {
87
xs =
IdxView<View>::allocate
(home,
n
);
88
for
(
int
i
=0;
i
<
n
;
i
++) {
89
xs[
i
].idx =
i
; xs[
i
].view = xa[
i
];
90
}
91
}
92
}
93
94
template
<
class
View>
95
forceinline
96
IdxViewArray<View>::IdxViewArray
(
Space
& home,
int
n0) : xs(NULL) {
97
n
= n0;
98
if
(
n
>0) {
99
xs =
IdxView<View>::allocate
(home,
n
);
100
}
101
}
102
103
template
<
class
View>
104
forceinline
int
105
IdxViewArray<View>::size
(
void
)
const
{
106
return
n
;
107
}
108
109
template
<
class
View>
110
forceinline
void
111
IdxViewArray<View>::size
(
int
n0) {
112
n
= n0;
113
}
114
115
template
<
class
View>
116
forceinline
IdxView<View>
&
117
IdxViewArray<View>::operator []
(
int
i
) {
118
assert((
i
>= 0) && (
i
<
size
()));
119
return
xs[
i
];
120
}
121
122
template
<
class
View>
123
forceinline
const
IdxView<View>
&
124
IdxViewArray<View>::operator []
(
int
i
)
const
{
125
assert((
i
>= 0) && (
i
<
size
()));
126
return
xs[
i
];
127
}
128
129
template
<
class
View>
130
forceinline
void
131
IdxViewArray<View>::subscribe
(
Space
& home,
Propagator
&
p
,
PropCond
pc,
132
bool
process) {
133
for
(
int
i
=0;
i
<
n
;
i
++)
134
xs[
i
].view.subscribe(home,
p
,pc,process);
135
}
136
137
template
<
class
View>
138
forceinline
void
139
IdxViewArray<View>::cancel
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
140
for
(
int
i
=0;
i
<
n
;
i
++)
141
xs[
i
].view.cancel(home,
p
,pc);
142
}
143
144
template
<
class
View>
145
forceinline
void
146
IdxViewArray<View>::reschedule
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
147
for
(
int
i
=0;
i
<
n
;
i
++)
148
xs[
i
].view.reschedule(home,
p
,pc);
149
}
150
151
template
<
class
View>
152
forceinline
void
153
IdxViewArray<View>::update
(
Space
& home,
IdxViewArray<View>
&
a
) {
154
n
=
a
.size();
155
if
(
n
>0) {
156
xs =
IdxView<View>::allocate
(home,
n
);
157
for
(
int
i
=0;
i
<
n
;
i
++) {
158
xs[
i
].idx =
a
[
i
].idx;
159
xs[
i
].view.update(home,
a
[
i
].view);
160
}
161
}
162
}
163
164
165
template
<
class
Char,
class
Traits,
class
View>
166
std::basic_ostream<Char,Traits>&
167
operator <<
(std::basic_ostream<Char,Traits>& os,
168
const
IdxViewArray<View>
&
x
) {
169
std::basic_ostringstream<Char,Traits> s;
170
s.copyfmt(os); s.width(0);
171
s <<
'{'
;
172
if
(
x
.size() > 0) {
173
s <<
x
[0].idx <<
':'
<<
x
[0].view;
174
for
(
int
i
=1;
i
<
x
.size();
i
++)
175
s <<
", "
<<
x
[
i
].idx <<
':'
<<
x
[
i
].view;
176
}
177
s <<
'}'
;
178
return
os << s.str();
179
}
180
181
}}
182
183
// STATISTICS: int-prop
184
Gecode::Int::NegBoolView
Negated Boolean view.
Definition:
view.hpp:1574
Gecode::Int::IdxViewArray
An array of IdxView pairs.
Definition:
idx-view.hh:67
Gecode::Int::IdxView::allocate
static IdxView * allocate(Space &home, int n)
Allocate memory for n index-view pairs.
Definition:
idx-view.hpp:67
Gecode::IntVarArgs
Passing integer variables.
Definition:
int.hh:656
Gecode::Iter::Ranges::size
unsigned int size(I &i)
Size of all ranges of range iterator i.
Definition:
ranges-operations.hpp:74
Gecode::Int::MinusView
Minus integer view.
Definition:
view.hpp:282
Gecode::Int::ViewToVarArg
Class to map VarArg type to view.
Definition:
idx-view.hh:60
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Int::BoolView
Boolean view for Boolean variables.
Definition:
view.hpp:1380
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1064
Gecode::Float::FloatView::operator<<
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
Gecode::Int::Count::update
void update(IntSet &y, Space &home, IntSet &py)
Definition:
rel.hpp:103
a
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
x
Node * x
Pointer to corresponding Boolean expression node.
Definition:
bool-expr.cpp:249
Gecode::Int::Count::reschedule
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:92
Gecode::BoolVarArgs
Passing Boolean variables.
Definition:
int.hh:712
Gecode::Int::ViewToVarArg< MinusView >::argtype
IntVarArgs argtype
Definition:
idx-view.hpp:50
Gecode::Space::alloc
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Definition:
core.hpp:2837
Gecode::Int::ViewToVarArg< NegBoolView >::argtype
BoolVarArgs argtype
Definition:
idx-view.hpp:62
Gecode::Int::ViewToVarArg< IntView >::argtype
IntVarArgs argtype
Definition:
idx-view.hpp:44
Gecode::PropCond
int PropCond
Type for propagation conditions.
Definition:
core.hpp:72
Gecode::Int::Count::cancel
void cancel(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:81
Gecode::Int::IdxViewArray::IdxViewArray
IdxViewArray(void)
Default constructor.
Definition:
idx-view.hpp:73
Gecode::Int::IntView
Integer view for integer variables.
Definition:
view.hpp:129
Gecode::Int::ViewToVarArg< BoolView >::argtype
BoolVarArgs argtype
Definition:
idx-view.hpp:56
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Int::IdxView
Class for pair of index and view.
Definition:
idx-view.hh:48
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
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