main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:27 for Gecode by
doxygen
1.8.4
gecode
int
branch
ngl.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, 2013
8
*
9
* Last modified:
10
* $Date: 2013-07-08 19:23:25 +0200 (Mon, 08 Jul 2013) $ by $Author: schulte $
11
* $Revision: 13827 $
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
Branch {
39
40
template
<
class
View>
41
forceinline
42
EqNGL<View>::EqNGL
(
Space
& home, View
x
,
int
n
)
43
:
ViewValNGL
<View,int,
PC_INT_VAL
>(home,x,n) {}
44
template
<
class
View>
45
forceinline
46
EqNGL<View>::EqNGL
(
Space
& home,
bool
share,
EqNGL
& ngl)
47
:
ViewValNGL
<View,int,
PC_INT_VAL
>(home,share,ngl) {}
48
template
<
class
View>
49
NGL
*
50
EqNGL<View>::copy
(
Space
& home,
bool
share) {
51
return
new
(home)
EqNGL<View>
(home,share,*
this
);
52
}
53
template
<
class
View>
54
NGL::Status
55
EqNGL<View>::status
(
const
Space
&)
const
{
56
if
(
x
.assigned())
57
return
(
x
.val() ==
n
) ?
NGL::SUBSUMED
:
NGL::FAILED
;
58
else
59
return
x
.in(
n
) ?
NGL::NONE
:
NGL::FAILED
;
60
}
61
template
<
class
View>
62
ExecStatus
63
EqNGL<View>::prune
(
Space
& home) {
64
return
me_failed
(
x
.nq(home,
n
)) ?
ES_FAILED
:
ES_OK
;
65
}
66
67
68
template
<
class
View>
69
forceinline
70
NqNGL<View>::NqNGL
(
Space
& home, View
x
,
int
n
)
71
:
ViewValNGL
<View,int,
PC_INT_DOM
>(home,x,n) {}
72
template
<
class
View>
73
forceinline
74
NqNGL<View>::NqNGL
(
Space
& home,
bool
share,
NqNGL
& ngl)
75
:
ViewValNGL
<View,int,
PC_INT_DOM
>(home,share,ngl) {}
76
template
<
class
View>
77
NGL
*
78
NqNGL<View>::copy
(
Space
& home,
bool
share) {
79
return
new
(home)
NqNGL<View>
(home,share,*
this
);
80
}
81
template
<
class
View>
82
NGL::Status
83
NqNGL<View>::status
(
const
Space
&)
const
{
84
if
(
x
.assigned())
85
return
(
x
.val() ==
n
) ?
NGL::FAILED
:
NGL::SUBSUMED
;
86
else
87
return
x
.in(
n
) ?
NGL::NONE
:
NGL::SUBSUMED
;
88
}
89
template
<
class
View>
90
ExecStatus
91
NqNGL<View>::prune
(
Space
& home) {
92
return
me_failed
(
x
.eq(home,
n
)) ?
ES_FAILED
:
ES_OK
;
93
}
94
95
96
template
<
class
View>
97
forceinline
98
LqNGL<View>::LqNGL
(
Space
& home, View
x
,
int
n
)
99
:
ViewValNGL
<View,int,
PC_INT_BND
>(home,x,n) {}
100
template
<
class
View>
101
forceinline
102
LqNGL<View>::LqNGL
(
Space
& home,
bool
share,
LqNGL
& ngl)
103
:
ViewValNGL
<View,int,
PC_INT_BND
>(home,share,ngl) {}
104
template
<
class
View>
105
NGL
*
106
LqNGL<View>::copy
(
Space
& home,
bool
share) {
107
return
new
(home)
LqNGL<View>
(home,share,*
this
);
108
}
109
template
<
class
View>
110
NGL::Status
111
LqNGL<View>::status
(
const
Space
&)
const
{
112
if
(
x
.max() <=
n
)
113
return
NGL::SUBSUMED
;
114
else
if
(
x
.min() >
n
)
115
return
NGL::FAILED
;
116
else
117
return
NGL::NONE
;
118
}
119
template
<
class
View>
120
ExecStatus
121
LqNGL<View>::prune
(
Space
& home) {
122
return
me_failed
(
x
.gr(home,
n
)) ?
ES_FAILED
:
ES_OK
;
123
}
124
125
126
template
<
class
View>
127
forceinline
128
GqNGL<View>::GqNGL
(
Space
& home, View
x
,
int
n
)
129
:
ViewValNGL
<View,int,
PC_INT_BND
>(home,x,n) {}
130
template
<
class
View>
131
forceinline
132
GqNGL<View>::GqNGL
(
Space
& home,
bool
share,
GqNGL
& ngl)
133
:
ViewValNGL
<View,int,
PC_INT_BND
>(home,share,ngl) {}
134
template
<
class
View>
135
NGL
*
136
GqNGL<View>::copy
(
Space
& home,
bool
share) {
137
return
new
(home)
GqNGL<View>
(home,share,*
this
);
138
}
139
template
<
class
View>
140
NGL::Status
141
GqNGL<View>::status
(
const
Space
&)
const
{
142
if
(
x
.min() >=
n
)
143
return
NGL::SUBSUMED
;
144
else
if
(
x
.max() <
n
)
145
return
NGL::FAILED
;
146
else
147
return
NGL::NONE
;
148
}
149
template
<
class
View>
150
ExecStatus
151
GqNGL<View>::prune
(
Space
& home) {
152
return
me_failed
(
x
.lq(home,
n
)) ?
ES_FAILED
:
ES_OK
;
153
}
154
155
}}}
156
157
// STATISTICS: int-branch