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
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
* Last modified:
10
* $Date: 2010-03-03 16:38:41 +0100 (Wed, 03 Mar 2010) $
11
* $Revision: 10359 $
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
Sequence {
39
41
enum
TakesStatus
{
42
TS_NO
,
43
TS_YES
,
44
TS_MAYBE
45
};
46
48
template
<
class
View>
49
forceinline
TakesStatus
50
takes
(
const
View&
x
,
int
s) {
51
if
(
x
.in(s))
52
return
x
.
assigned
() ?
TS_YES
:
TS_MAYBE
;
53
else
54
return
TS_NO
;
55
}
57
template
<
class
View>
58
forceinline
TakesStatus
59
takes
(
const
View&
x
,
const
IntSet
& s) {
60
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
61
return
TS_NO
;
62
ViewRanges<View>
ix(
x
);
63
IntSetRanges
is(s);
64
switch
(
Iter::Ranges::compare
(ix,is)) {
65
case
Iter::Ranges::CS_SUBSET
:
return
TS_YES
;
66
case
Iter::Ranges::CS_DISJOINT
:
return
TS_NO
;
67
case
Iter::Ranges::CS_NONE
:
return
TS_MAYBE
;
68
default
:
GECODE_NEVER
;
69
}
70
return
TS_MAYBE
;
71
}
72
74
template
<
class
View>
75
forceinline
bool
76
includes
(
const
View&
x
,
int
s) {
77
return
x
.
assigned
() &&
x
.in(s);
78
}
80
template
<
class
View>
81
forceinline
bool
82
includes
(
const
View&
x
,
const
IntSet
& s) {
83
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
84
return
false
;
85
ViewRanges<View>
ix(
x
);
86
IntSetRanges
is(s);
87
return
Iter::Ranges::subset
(ix,is);
88
}
89
91
template
<
class
View>
92
forceinline
bool
93
excludes
(
const
View&
x
,
int
s) {
94
return
!
x
.in(s);
95
}
97
template
<
class
View>
98
forceinline
bool
99
excludes
(
const
View&
x
,
const
IntSet
& s) {
100
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
101
return
true
;
102
ViewRanges<View>
ix(
x
);
103
IntSetRanges
is(s);
104
return
Iter::Ranges::disjoint
(ix,is);
105
}
106
108
template
<
class
View>
109
forceinline
bool
110
undecided
(
const
View&
x
,
int
s) {
111
return
!
x
.
assigned
() &&
x
.in(s);
112
}
114
template
<
class
View>
115
forceinline
bool
116
undecided
(
const
View&
x
,
const
IntSet
& s) {
117
if
((
x
.max() < s.
min
()) || (
x
.min() > s.
max
()))
118
return
false
;
119
ViewRanges<View>
ix(
x
);
120
IntSetRanges
is(s);
121
return
Iter::Ranges::compare
(ix,is) ==
Iter::Ranges::CS_NONE
;
122
}
123
125
template
<
class
View>
126
forceinline
ModEvent
127
include
(
Space
& home, View&
x
,
int
s) {
128
return
x
.eq(home,s);
129
}
131
template
<
class
View>
132
forceinline
ModEvent
133
include
(
Space
& home, View&
x
,
const
IntSet
& s) {
134
IntSetRanges
is(s);
135
return
x
.inter_r(home,is,
false
);
136
}
137
139
template
<
class
View>
140
forceinline
ModEvent
141
exclude
(
Space
& home, View&
x
,
int
s) {
142
return
x
.nq(home,s);
143
}
145
template
<
class
View>
146
forceinline
ModEvent
147
exclude
(
Space
& home, View&
x
,
const
IntSet
& s) {
148
IntSetRanges
is(s);
149
return
x
.minus_r(home,is,
false
);
150
}
151
152
}}}
153
154
// STATISTICS: int-prop
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
Gecode::IntSet::min
int min(int i) const
Return minimum of range at position i.
Definition:
int-set-1.hpp:115
forceinline
#define forceinline
Definition:
config.hpp:173
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:141
Gecode::IntSet::max
int max(int i) const
Return maximum of range at position i.
Definition:
int-set-1.hpp:121
Gecode::Iter::Ranges::CS_NONE
@ CS_NONE
Neither of the above.
Definition:
ranges-operations.hpp:67
Gecode::Iter::Ranges::disjoint
bool disjoint(I &i, J &j)
Check whether range iterators i and j are disjoint.
Definition:
ranges-operations.hpp:116
Gecode::Int::Sequence::TS_MAYBE
@ TS_MAYBE
Maybe or maybe not.
Definition:
set-op.hpp:44
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
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:101
Gecode::VarImpVar::assigned
bool assigned(void) const
Test whether view is assigned.
Definition:
var.hpp:123
Gecode::IntSetRanges
Range iterator for integer sets.
Definition:
int.hh:274
Gecode::Int::Sequence::TS_YES
@ TS_YES
Definitely yes.
Definition:
set-op.hpp:43
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::CS_SUBSET
@ CS_SUBSET
First is subset of second iterator.
Definition:
ranges-operations.hpp:65
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:110
Gecode::Int::Sequence::TS_NO
@ TS_NO
Definitely not.
Definition:
set-op.hpp:42
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:60
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition:
core.hpp:142
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:93
Gecode::Int::Sequence::TakesStatus
TakesStatus
Status of whether a view takes a value from a set.
Definition:
set-op.hpp:41
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:127
Gecode::Int::Sequence::takes
TakesStatus takes(const View &x, int s)
Return whether view x takes value s.
Definition:
set-op.hpp:50
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:131
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:76
Gecode::Iter::Ranges::CS_DISJOINT
@ CS_DISJOINT
Intersection is empty.
Definition:
ranges-operations.hpp:66