main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
int
sequence
set-op.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, 2009
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
Sequence {
35
37
enum
TakesStatus
{
38
TS_NO
,
39
TS_YES
,
40
TS_MAYBE
41
};
42
44
template
<
class
View>
45
forceinline
TakesStatus
46
takes
(
const
View&
x
,
int
s) {
47
if
(
x
.in(s))
48
return
x
.
assigned
() ?
TS_YES
:
TS_MAYBE
;
49
else
50
return
TS_NO
;
51
}
53
template
<
class
View>
54
forceinline
TakesStatus
55
takes
(
const
View&
x
,
const
IntSet
& s) {
56
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
57
return
TS_NO
;
58
ViewRanges<View>
ix(
x
);
59
IntSetRanges
is(s);
60
switch
(
Iter::Ranges::compare
(ix,is)) {
61
case
Iter::Ranges::CS_SUBSET
:
return
TS_YES
;
62
case
Iter::Ranges::CS_DISJOINT
:
return
TS_NO
;
63
case
Iter::Ranges::CS_NONE
:
return
TS_MAYBE
;
64
default
:
GECODE_NEVER
;
65
}
66
return
TS_MAYBE
;
67
}
68
70
template
<
class
View>
71
forceinline
bool
72
includes
(
const
View&
x
,
int
s) {
73
return
x
.
assigned
() &&
x
.in(s);
74
}
76
template
<
class
View>
77
forceinline
bool
78
includes
(
const
View&
x
,
const
IntSet
& s) {
79
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
80
return
false
;
81
ViewRanges<View>
ix(
x
);
82
IntSetRanges
is(s);
83
return
Iter::Ranges::subset
(ix,is);
84
}
85
87
template
<
class
View>
88
forceinline
bool
89
excludes
(
const
View&
x
,
int
s) {
90
return
!
x
.in(s);
91
}
93
template
<
class
View>
94
forceinline
bool
95
excludes
(
const
View&
x
,
const
IntSet
& s) {
96
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
97
return
true
;
98
ViewRanges<View>
ix(
x
);
99
IntSetRanges
is(s);
100
return
Iter::Ranges::disjoint
(ix,is);
101
}
102
104
template
<
class
View>
105
forceinline
bool
106
undecided
(
const
View&
x
,
int
s) {
107
return
!
x
.
assigned
() &&
x
.in(s);
108
}
110
template
<
class
View>
111
forceinline
bool
112
undecided
(
const
View&
x
,
const
IntSet
& s) {
113
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
114
return
false
;
115
ViewRanges<View>
ix(
x
);
116
IntSetRanges
is(s);
117
return
Iter::Ranges::compare
(ix,is) ==
Iter::Ranges::CS_NONE
;
118
}
119
121
template
<
class
View>
122
forceinline
ModEvent
123
include
(
Space
& home, View&
x
,
int
s) {
124
return
x
.eq(home,s);
125
}
127
template
<
class
View>
128
forceinline
ModEvent
129
include
(
Space
& home, View&
x
,
const
IntSet
& s) {
130
IntSetRanges
is(s);
131
return
x
.inter_r(home,is,
false
);
132
}
133
135
template
<
class
View>
136
forceinline
ModEvent
137
exclude
(
Space
& home, View&
x
,
int
s) {
138
return
x
.nq(home,s);
139
}
141
template
<
class
View>
142
forceinline
ModEvent
143
exclude
(
Space
& home, View&
x
,
const
IntSet
& s) {
144
IntSetRanges
is(s);
145
return
x
.minus_r(home,is,
false
);
146
}
147
148
}}}
149
150
// STATISTICS: int-prop
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::IntSet::min
int min(int i) const
Return minimum of range at position i.
Definition:
int-set-1.hpp:152
Gecode::Int::Sequence::exclude
ModEvent exclude(Space &home, View &x, int s)
Prune view x to exclude all values from s.
Definition:
set-op.hpp:137
Gecode::IntSet::max
int max(int i) const
Return maximum of range at position i.
Definition:
int-set-1.hpp:158
Gecode::Iter::Ranges::CS_NONE
@ CS_NONE
Neither of the above.
Definition:
ranges-operations.hpp:63
Gecode::Iter::Ranges::disjoint
bool disjoint(I &i, J &j)
Check whether range iterators i and j are disjoint.
Definition:
ranges-operations.hpp:112
Gecode::Int::Sequence::TS_MAYBE
@ TS_MAYBE
Maybe or maybe not.
Definition:
set-op.hpp:40
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Iter::Ranges::subset
bool subset(I &i, J &j)
Check whether range iterator i is subset of range iterator j.
Definition:
ranges-operations.hpp:97
Gecode::VarImpVar::assigned
bool assigned(void) const
Test whether view is assigned.
Definition:
var.hpp:111
Gecode::IntSetRanges
Range iterator for integer sets.
Definition:
int.hh:292
Gecode::Int::Sequence::TS_YES
@ TS_YES
Definitely yes.
Definition:
set-op.hpp:39
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::CS_SUBSET
@ CS_SUBSET
First is subset of second iterator.
Definition:
ranges-operations.hpp:61
Gecode::Int::ViewRanges
Range iterator for integer views.
Definition:
view.hpp:54
Gecode::IntSet
Integer sets.
Definition:
int.hh:174
Gecode::Int::Sequence::undecided
bool undecided(const View &x, int s)
Test whether no decision on inclusion or exclusion of values of view x in s can be made.
Definition:
set-op.hpp:106
Gecode::Int::Sequence::TS_NO
@ TS_NO
Definitely not.
Definition:
set-op.hpp:38
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:56
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition:
core.hpp:62
Gecode::Int::Sequence::excludes
bool excludes(const View &x, int s)
Test whether all values of view x are excluded from s.
Definition:
set-op.hpp:89
Gecode::Int::Sequence::TakesStatus
TakesStatus
Status of whether a view takes a value from a set.
Definition:
set-op.hpp:37
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Int::Sequence::include
ModEvent include(Space &home, View &x, int s)
Prune view x to only include values from s.
Definition:
set-op.hpp:123
Gecode::Int::Sequence::takes
TakesStatus takes(const View &x, int s)
Return whether view x takes value s.
Definition:
set-op.hpp:46
Gecode::Iter::Ranges::compare
CompareStatus compare(I &i, J &j)
Check whether range iterator i is a subset of j, or whether they are disjoint.
Definition:
ranges-operations.hpp:127
Gecode::Int::Sequence::includes
bool includes(const View &x, int s)
Test whether all values of view x are included in s.
Definition:
set-op.hpp:72
Gecode::Iter::Ranges::CS_DISJOINT
@ CS_DISJOINT
Intersection is empty.
Definition:
ranges-operations.hpp:62