main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:00 for Gecode by
doxygen
1.8.4
gecode
int
branch
val-commit.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, 2012
8
*
9
* Last modified:
10
* $Date: 2013-07-04 17:03:13 +0200 (Thu, 04 Jul 2013) $ by $Author: schulte $
11
* $Revision: 13801 $
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
ValCommitEq<View>::ValCommitEq
(
Space
& home,
const
ValBranch
& vb)
43
:
ValCommit
<
View
,int>(home,vb) {}
44
template
<
class
View>
45
forceinline
46
ValCommitEq<View>::ValCommitEq
(
Space
& home,
bool
shared
,
ValCommitEq
& vc)
47
:
ValCommit
<
View
,int>(home,shared,vc) {}
48
template
<
class
View>
49
forceinline
ModEvent
50
ValCommitEq<View>::commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
,
int
n
) {
51
return
(a == 0) ? x.eq(home,n) : x.nq(home,n);
52
}
53
template
<
class
View>
54
forceinline
NGL
*
55
ValCommitEq<View>::ngl
(
Space
& home,
unsigned
int
a
,
View
x
,
int
n
)
const
{
56
if
(a == 0)
57
return
new
(home)
EqNGL<View>
(home,x,n);
58
else
59
return
NULL;
60
}
61
template
<
class
View>
62
forceinline
void
63
ValCommitEq<View>::print
(
const
Space
&,
unsigned
int
a
,
View
,
int
i
,
64
int
n
, std::ostream& o)
const
{
65
o <<
"var["
<< i <<
"] "
66
<< ((a == 0) ?
"="
:
"!="
) <<
" "
<<
n
;
67
}
68
69
template
<
class
View>
70
forceinline
71
ValCommitLq<View>::ValCommitLq
(
Space
& home,
const
ValBranch
& vb)
72
:
ValCommit
<
View
,int>(home,vb) {}
73
template
<
class
View>
74
forceinline
75
ValCommitLq<View>::ValCommitLq
(
Space
& home,
bool
shared
,
ValCommitLq
& vc)
76
:
ValCommit
<
View
,int>(home,shared,vc) {}
77
template
<
class
View>
78
forceinline
ModEvent
79
ValCommitLq<View>::commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
,
int
n
) {
80
return
(a == 0) ? x.lq(home,n) : x.gr(home,n);
81
}
82
template
<
class
View>
83
forceinline
NGL
*
84
ValCommitLq<View>::ngl
(
Space
& home,
unsigned
int
a
,
View
x
,
int
n
)
const
{
85
if
(a == 0)
86
return
new
(home)
LqNGL<View>
(home,x,n);
87
else
88
return
NULL;
89
}
90
template
<
class
View>
91
forceinline
void
92
ValCommitLq<View>::print
(
const
Space
&,
unsigned
int
a
,
View
,
int
i
,
93
int
n
, std::ostream& o)
const
{
94
o <<
"var["
<< i <<
"] "
95
<< ((a == 0) ?
"<="
:
">"
) <<
" "
<<
n
;
96
}
97
98
template
<
class
View>
99
forceinline
100
ValCommitGq<View>::ValCommitGq
(
Space
& home,
const
ValBranch
& vb)
101
:
ValCommit
<
View
,int>(home,vb) {}
102
template
<
class
View>
103
forceinline
104
ValCommitGq<View>::ValCommitGq
(
Space
& home,
bool
shared
,
ValCommitGq
& vc)
105
:
ValCommit
<
View
,int>(home,shared,vc) {}
106
template
<
class
View>
107
forceinline
ModEvent
108
ValCommitGq<View>::commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
,
int
n
) {
109
return
(a == 0) ? x.gq(home,n) : x.le(home,n);
110
}
111
template
<
class
View>
112
forceinline
NGL
*
113
ValCommitGq<View>::ngl
(
Space
& home,
unsigned
int
a
,
View
x
,
int
n
)
const
{
114
if
(a == 0)
115
return
new
(home)
GqNGL<View>
(home,x,n);
116
else
117
return
NULL;
118
}
119
template
<
class
View>
120
forceinline
void
121
ValCommitGq<View>::print
(
const
Space
&,
unsigned
int
a
,
View
,
int
i
,
122
int
n
, std::ostream& o)
const
{
123
o <<
"var["
<< i <<
"] "
124
<< ((a == 0) ?
">="
:
"<"
) <<
" "
<<
n
;
125
}
126
127
template
<
class
View>
128
forceinline
129
ValCommitGr<View>::ValCommitGr
(
Space
& home,
const
ValBranch
& vb)
130
:
ValCommit
<
View
,int>(home,vb) {}
131
template
<
class
View>
132
forceinline
133
ValCommitGr<View>::ValCommitGr
(
Space
& home,
bool
shared
,
ValCommitGr
& vc)
134
:
ValCommit
<
View
,int>(home,shared,vc) {}
135
template
<
class
View>
136
forceinline
ModEvent
137
ValCommitGr<View>::commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
,
int
n
) {
138
return
(a == 0) ? x.gr(home,n) : x.lq(home,n);
139
}
140
template
<
class
View>
141
forceinline
NGL
*
142
ValCommitGr<View>::ngl
(
Space
& home,
unsigned
int
a
,
View
x
,
int
n
)
const
{
143
if
(a == 0)
144
return
new
(home)
GqNGL<View>
(home,x,n+1);
145
else
146
return
NULL;
147
}
148
template
<
class
View>
149
forceinline
void
150
ValCommitGr<View>::print
(
const
Space
&,
unsigned
int
a
,
View
,
int
i
,
151
int
n
, std::ostream& o)
const
{
152
o <<
"var["
<< i <<
"] "
153
<< ((a == 0) ?
">"
:
"<="
) <<
" "
<<
n
;
154
}
155
156
}}}
157
158
// STATISTICS: int-branch
159