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
kernel
branch-var.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: 2017-03-08 11:58:56 +0100 (Wed, 08 Mar 2017) $ by $Author: schulte $
11
* $Revision: 15562 $
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
#include <functional>
39
40
namespace
Gecode
{
41
51
typedef
std::function<double(
const
Space& home,
double
w,
double
b
)>
52
BranchTbl
;
53
58
template
<
class
Var>
59
class
VarBranch
{
60
public
:
62
typedef
typename
BranchTraits<Var>::Merit
MeritFunction
;
63
protected
:
65
BranchTbl
_tbl
;
67
Rnd
_rnd
;
69
double
_decay
;
71
AFC
_afc
;
73
Action
_act
;
75
CHB
_chb
;
77
MeritFunction
_mf
;
78
public
:
80
VarBranch
(
void
);
82
VarBranch
(
BranchTbl
t
);
84
VarBranch
(
Rnd
r
);
86
VarBranch
(
double
d
,
BranchTbl
t
);
88
VarBranch
(
AFC
a
,
BranchTbl
t
);
90
VarBranch
(
Action
a
,
BranchTbl
t
);
92
VarBranch
(
CHB
c
,
BranchTbl
t
);
94
VarBranch
(
MeritFunction
f
,
BranchTbl
t
);
96
BranchTbl
tbl
(
void
)
const
;
98
Rnd
rnd
(
void
)
const
;
100
double
decay
(
void
)
const
;
102
AFC
afc
(
void
)
const
;
104
void
afc
(
AFC
a
);
106
Action
action
(
void
)
const
;
108
void
action
(
Action
a
);
110
CHB
chb
(
void
)
const
;
112
void
chb
(
CHB
chb
);
114
MeritFunction
merit
(
void
)
const
;
115
};
116
117
// Variable branching
118
template
<
class
Var>
119
inline
120
VarBranch<Var>::VarBranch
(
void
)
121
: _tbl(nullptr), _decay(1.0) {}
122
123
template
<
class
Var>
124
inline
125
VarBranch<Var>::VarBranch
(
BranchTbl
t
)
126
: _tbl(
t
), _decay(1.0) {}
127
128
template
<
class
Var>
129
inline
130
VarBranch<Var>::VarBranch
(
double
d
,
BranchTbl
t
)
131
: _tbl(
t
), _decay(
d
) {}
132
133
template
<
class
Var>
134
inline
135
VarBranch<Var>::VarBranch
(
AFC
a
,
BranchTbl
t
)
136
: _tbl(
t
), _decay(1.0), _afc(
a
) {
137
if
(!_afc)
138
throw
UninitializedAFC
(
"VarBranch<Var>::VarBranch"
);
139
}
140
141
template
<
class
Var>
142
inline
143
VarBranch<Var>::VarBranch
(
Action
a
,
BranchTbl
t
)
144
: _tbl(
t
), _decay(1.0), _act(
a
) {
145
if
(!_act)
146
throw
UninitializedAction
(
"VarBranch<Var>::VarBranch"
);
147
}
148
149
template
<
class
Var>
150
inline
151
VarBranch<Var>::VarBranch
(
CHB
c
,
BranchTbl
t
)
152
: _tbl(
t
), _decay(1.0), _chb(
c
) {
153
if
(!_chb)
154
throw
UninitializedCHB
(
"VarBranch<Var>::VarBranch"
);
155
}
156
157
template
<
class
Var>
158
inline
159
VarBranch<Var>::VarBranch
(
Rnd
r
)
160
: _tbl(nullptr), _rnd(
r
), _decay(1.0) {
161
if
(!_rnd)
162
throw
UninitializedRnd
(
"VarBranch<Var>::VarBranch"
);
163
}
164
165
template
<
class
Var>
166
inline
167
VarBranch<Var>::VarBranch
(
MeritFunction
f
,
BranchTbl
t
)
168
: _tbl(
t
), _decay(1.0), _mf(
f
) {}
169
170
template
<
class
Var>
171
inline
BranchTbl
172
VarBranch<Var>::tbl
(
void
)
const
{
173
return
_tbl;
174
}
175
176
template
<
class
Var>
177
inline
Rnd
178
VarBranch<Var>::rnd
(
void
)
const
{
179
return
_rnd;
180
}
181
182
template
<
class
Var>
183
inline
double
184
VarBranch<Var>::decay
(
void
)
const
{
185
return
_decay;
186
}
187
188
template
<
class
Var>
189
inline
AFC
190
VarBranch<Var>::afc
(
void
)
const
{
191
return
_afc;
192
}
193
194
template
<
class
Var>
195
inline
void
196
VarBranch<Var>::afc
(
AFC
a
) {
197
_afc=
a
;
198
}
199
200
template
<
class
Var>
201
inline
Action
202
VarBranch<Var>::action
(
void
)
const
{
203
return
_act;
204
}
205
206
template
<
class
Var>
207
inline
void
208
VarBranch<Var>::action
(
Action
a
) {
209
_act=
a
;
210
}
211
212
template
<
class
Var>
213
inline
CHB
214
VarBranch<Var>::chb
(
void
)
const
{
215
return
_chb;
216
}
217
218
template
<
class
Var>
219
inline
void
220
VarBranch<Var>::chb
(
CHB
chb) {
221
_chb=chb;
222
}
223
224
template
<
class
Var>
225
inline
typename
VarBranch<Var>::MeritFunction
226
VarBranch<Var>::merit
(
void
)
const
{
227
return
_mf;
228
}
229
230
}
231
232
// STATISTICS: kernel-branch
Gecode::Action
Class for action management.
Definition:
action.hpp:46
Gecode::VarBranch::decay
double decay(void) const
Return decay factor.
Definition:
branch-var.hpp:184
Gecode::VarBranch::merit
MeritFunction merit(void) const
Return merit function.
Definition:
branch-var.hpp:226
Gecode::CHB
Class for CHB management.
Definition:
chb.hpp:50
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:234
Gecode::VarBranch::_act
Action _act
Action information.
Definition:
branch-var.hpp:73
Gecode::UninitializedAFC
Exception: uninitialized AFC
Definition:
exception.hpp:125
Gecode::BranchTraits
Traits for branching.
Definition:
branch-traits.hpp:59
Gecode::VarBranch
Variable branching information.
Definition:
branch-var.hpp:59
Gecode
Gecode toplevel namespace
Gecode::VarBranch::rnd
Rnd rnd(void) const
Return random number generator.
Definition:
branch-var.hpp:178
Test::Branch::tbl
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition:
branch.cpp:65
Gecode::VarBranch::_chb
CHB _chb
CHB information.
Definition:
branch-var.hpp:75
a
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::VarBranch::_mf
MeritFunction _mf
Merit function.
Definition:
branch-var.hpp:77
b
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Gecode::VarBranch::_decay
double _decay
Decay information for AFC and action.
Definition:
branch-var.hpp:69
Gecode::VarBranch::MeritFunction
BranchTraits< Var >::Merit MeritFunction
Corresponding merit function.
Definition:
branch-var.hpp:62
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:784
Gecode::VarBranch::tbl
BranchTbl tbl(void) const
Return tie-break limit function.
Definition:
branch-var.hpp:172
Gecode::Rnd
Random number generator.
Definition:
rnd.hpp:46
Gecode::VarBranch::VarBranch
VarBranch(void)
Initialize.
Definition:
branch-var.hpp:120
Gecode::VarBranch::_rnd
Rnd _rnd
Random number generator.
Definition:
branch-var.hpp:67
Test::afc
AFC afc
Definition:
afc.cpp:139
Gecode::VarBranch::chb
CHB chb(void) const
Return CHB.
Definition:
branch-var.hpp:214
Gecode::VarBranch::action
Action action(void) const
Return action.
Definition:
branch-var.hpp:202
Gecode::VarBranch::_afc
AFC _afc
AFC information.
Definition:
branch-var.hpp:71
Gecode::AFC
Class for AFC (accumulated failure count) management.
Definition:
afc.hpp:44
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::UninitializedAction
Exception: uninitialized action
Definition:
exception.hpp:132
r
NNF * r
Right subtree.
Definition:
bool-expr.cpp:246
Gecode::UninitializedRnd
Exception: uninitialized random number generator
Definition:
exception.hpp:146
Gecode::BranchTbl
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition:
branch-var.hpp:52
Gecode::f
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
Gecode::VarBranch::_tbl
BranchTbl _tbl
Tie-breaking limit function.
Definition:
branch-var.hpp:65
Gecode::UninitializedCHB
Exception: uninitialized action
Definition:
exception.hpp:139
Gecode::VarBranch::afc
AFC afc(void) const
Return AFC.
Definition:
branch-var.hpp:190