3
* Christian Schulte <schulte@gecode.org>
6
* Christian Schulte, 2002
9
* $Date: 2005-07-28 22:52:19 +0200 (Thu, 28 Jul 2005) $ by $Author: schulte $
12
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
16
* See the file "LICENSE" for information on usage and
17
* redistribution of this file, and for a
18
* DISCLAIMER OF ALL WARRANTIES.
22
namespace Gecode { namespace Int { namespace Branch {
24
// Select first variable
25
forceinline ViewSelStatus
26
ByNone::init(IntView) {
29
forceinline ViewSelStatus
30
ByNone::select(IntView) {
35
// Select variable with smallest min
36
forceinline ViewSelStatus
37
ByMinMin::init(IntView x) {
41
forceinline ViewSelStatus
42
ByMinMin::select(IntView x) {
44
min = x.min(); return VSS_SELECT;
49
// Select variable with largest min
50
forceinline ViewSelStatus
51
ByMinMax::init(IntView x) {
55
forceinline ViewSelStatus
56
ByMinMax::select(IntView x) {
58
min = x.min(); return VSS_SELECT;
63
// Select variable with smallest max
64
forceinline ViewSelStatus
65
ByMaxMin::init(IntView x) {
69
forceinline ViewSelStatus
70
ByMaxMin::select(IntView x) {
72
max = x.max(); return VSS_SELECT;
77
// Select variable with largest max
78
forceinline ViewSelStatus
79
ByMaxMax::init(IntView x) {
83
forceinline ViewSelStatus
84
ByMaxMax::select(IntView x) {
86
max = x.max(); return VSS_SELECT;
91
// Select variable with smallest size
92
forceinline ViewSelStatus
93
BySizeMin::init(IntView x) {
95
return (size == 2) ? VSS_COMMIT : VSS_SELECT;
97
forceinline ViewSelStatus
98
BySizeMin::select(IntView x) {
99
if (x.size() < size) {
101
return (size == 2) ? VSS_COMMIT : VSS_SELECT;
106
// Select variable with largest size
107
forceinline ViewSelStatus
108
BySizeMax::init(IntView x) {
112
forceinline ViewSelStatus
113
BySizeMax::select(IntView x) {
114
if (x.size() > size) {
115
size = x.size(); return VSS_SELECT;
120
// Select variable with smallest degree (and smallest size in case of ties)
121
forceinline ViewSelStatus
122
ByDegreeMin::init(IntView x) {
123
degree = x.degree(); size = x.size();
126
forceinline ViewSelStatus
127
ByDegreeMin::select(IntView x) {
128
if (x.degree() < degree) {
132
} else if ((x.degree() == degree) && (x.size() < size)) {
139
// Select variable with smallest degree (and smallest size in case of ties)
140
forceinline ViewSelStatus
141
ByDegreeMax::init(IntView x) {
142
degree = x.degree(); size = x.size();
145
forceinline ViewSelStatus
146
ByDegreeMax::select(IntView x) {
147
if (x.degree() > degree) {
151
} else if ((x.degree() == degree) && (x.size() < size)) {
158
// Select variable with smallest min-regret
159
forceinline ViewSelStatus
160
ByRegretMinMin::init(IntView x) {
161
regret = x.regret_min();
162
return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
164
forceinline ViewSelStatus
165
ByRegretMinMin::select(IntView x) {
166
if (x.regret_min() < regret) {
167
regret = x.regret_min();
168
return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
173
// Select variable with largest min-regret
174
forceinline ViewSelStatus
175
ByRegretMinMax::init(IntView x) {
176
regret = x.regret_min();
179
forceinline ViewSelStatus
180
ByRegretMinMax::select(IntView x) {
181
if (x.regret_min() > regret) {
182
regret = x.regret_min(); return VSS_SELECT;
187
// Select variable with smallest max-regret
188
forceinline ViewSelStatus
189
ByRegretMaxMin::init(IntView x) {
190
regret = x.regret_max();
191
return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
193
forceinline ViewSelStatus
194
ByRegretMaxMin::select(IntView x) {
195
if (x.regret_max() < regret) {
196
regret = x.regret_max();
197
return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
202
// Select variable with smallest min-regret
203
forceinline ViewSelStatus
204
ByRegretMaxMax::init(IntView x) {
205
regret = x.regret_max();
208
forceinline ViewSelStatus
209
ByRegretMaxMax::select(IntView x) {
210
if (x.regret_max() > regret) {
211
regret = x.regret_max(); return VSS_SELECT;
218
// STATISTICS: int-branch