main page
modules
namespaces
classes
files
Gecode home
Generated on Wed Jan 1 2020 10:37:59 for Gecode by
doxygen
1.8.16
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
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
#include <functional>
35
36
namespace
Gecode
{
37
47
typedef
std::function<double(
const
Space& home,
double
w,
double
b
)>
48
BranchTbl
;
49
54
template
<
class
Var>
55
class
VarBranch
{
56
public
:
58
typedef
typename
BranchTraits<Var>::Merit
MeritFunction
;
59
protected
:
61
BranchTbl
_tbl
;
63
Rnd
_rnd
;
65
double
_decay
;
67
AFC
_afc
;
69
Action
_act
;
71
CHB
_chb
;
73
MeritFunction
_mf
;
74
public
:
76
VarBranch
(
void
);
78
VarBranch
(
BranchTbl
t
);
80
VarBranch
(
Rnd
r
);
82
VarBranch
(
double
d
,
BranchTbl
t
);
84
VarBranch
(
AFC
a
,
BranchTbl
t
);
86
VarBranch
(
Action
a
,
BranchTbl
t
);
88
VarBranch
(
CHB
c
,
BranchTbl
t
);
90
VarBranch
(
MeritFunction
f
,
BranchTbl
t
);
92
BranchTbl
tbl
(
void
)
const
;
94
Rnd
rnd
(
void
)
const
;
96
double
decay
(
void
)
const
;
98
AFC
afc
(
void
)
const
;
100
void
afc
(
AFC
a
);
102
Action
action
(
void
)
const
;
104
void
action
(
Action
a
);
106
CHB
chb
(
void
)
const
;
108
void
chb
(
CHB
chb
);
110
MeritFunction
merit
(
void
)
const
;
111
};
112
113
// Variable branching
114
template
<
class
Var>
115
inline
116
VarBranch<Var>::VarBranch
(
void
)
117
: _tbl(nullptr), _decay(1.0) {}
118
119
template
<
class
Var>
120
inline
121
VarBranch<Var>::VarBranch
(
BranchTbl
t
)
122
: _tbl(
t
), _decay(1.0) {}
123
124
template
<
class
Var>
125
inline
126
VarBranch<Var>::VarBranch
(
double
d
,
BranchTbl
t
)
127
: _tbl(
t
), _decay(
d
) {}
128
129
template
<
class
Var>
130
inline
131
VarBranch<Var>::VarBranch
(
AFC
a
,
BranchTbl
t
)
132
: _tbl(
t
), _decay(1.0), _afc(
a
) {
133
if
(!_afc)
134
throw
UninitializedAFC
(
"VarBranch<Var>::VarBranch"
);
135
}
136
137
template
<
class
Var>
138
inline
139
VarBranch<Var>::VarBranch
(
Action
a
,
BranchTbl
t
)
140
: _tbl(
t
), _decay(1.0), _act(
a
) {
141
if
(!_act)
142
throw
UninitializedAction
(
"VarBranch<Var>::VarBranch"
);
143
}
144
145
template
<
class
Var>
146
inline
147
VarBranch<Var>::VarBranch
(
CHB
c
,
BranchTbl
t
)
148
: _tbl(
t
), _decay(1.0), _chb(
c
) {
149
if
(!_chb)
150
throw
UninitializedCHB
(
"VarBranch<Var>::VarBranch"
);
151
}
152
153
template
<
class
Var>
154
inline
155
VarBranch<Var>::VarBranch
(
Rnd
r
)
156
: _tbl(nullptr), _rnd(
r
), _decay(1.0) {
157
if
(!_rnd)
158
throw
UninitializedRnd
(
"VarBranch<Var>::VarBranch"
);
159
}
160
161
template
<
class
Var>
162
inline
163
VarBranch<Var>::VarBranch
(
MeritFunction
f
,
BranchTbl
t
)
164
: _tbl(
t
), _decay(1.0), _mf(
f
) {}
165
166
template
<
class
Var>
167
inline
BranchTbl
168
VarBranch<Var>::tbl
(
void
)
const
{
169
return
_tbl;
170
}
171
172
template
<
class
Var>
173
inline
Rnd
174
VarBranch<Var>::rnd
(
void
)
const
{
175
return
_rnd;
176
}
177
178
template
<
class
Var>
179
inline
double
180
VarBranch<Var>::decay
(
void
)
const
{
181
return
_decay;
182
}
183
184
template
<
class
Var>
185
inline
AFC
186
VarBranch<Var>::afc
(
void
)
const
{
187
return
_afc;
188
}
189
190
template
<
class
Var>
191
inline
void
192
VarBranch<Var>::afc
(
AFC
a
) {
193
_afc=
a
;
194
}
195
196
template
<
class
Var>
197
inline
Action
198
VarBranch<Var>::action
(
void
)
const
{
199
return
_act;
200
}
201
202
template
<
class
Var>
203
inline
void
204
VarBranch<Var>::action
(
Action
a
) {
205
_act=
a
;
206
}
207
208
template
<
class
Var>
209
inline
CHB
210
VarBranch<Var>::chb
(
void
)
const
{
211
return
_chb;
212
}
213
214
template
<
class
Var>
215
inline
void
216
VarBranch<Var>::chb
(
CHB
chb) {
217
_chb=chb;
218
}
219
220
template
<
class
Var>
221
inline
typename
VarBranch<Var>::MeritFunction
222
VarBranch<Var>::merit
(
void
)
const
{
223
return
_mf;
224
}
225
226
}
227
228
// STATISTICS: kernel-branch
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::Action
Class for action management.
Definition:
action.hpp:42
Gecode::VarBranch::decay
double decay(void) const
Return decay factor.
Definition:
var.hpp:180
Gecode::VarBranch::merit
MeritFunction merit(void) const
Return merit function.
Definition:
var.hpp:222
Gecode::CHB
Class for CHB management.
Definition:
chb.hpp:46
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:230
Gecode::VarBranch::_act
Action _act
Action information.
Definition:
var.hpp:69
Gecode::UninitializedAFC
Exception: uninitialized AFC
Definition:
exception.hpp:121
Gecode::BranchTraits
Traits for branching.
Definition:
traits.hpp:55
Gecode::VarBranch
Variable branching information.
Definition:
var.hpp:55
Gecode
Gecode toplevel namespace
Gecode::VarBranch::rnd
Rnd rnd(void) const
Return random number generator.
Definition:
var.hpp:174
Test::Branch::tbl
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition:
branch.cpp:61
Gecode::VarBranch::_chb
CHB _chb
CHB information.
Definition:
var.hpp:71
a
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Gecode::VarBranch::_mf
MeritFunction _mf
Merit function.
Definition:
var.hpp:73
Gecode::VarBranch::_decay
double _decay
Decay information for AFC and action.
Definition:
var.hpp:65
Gecode::VarBranch::MeritFunction
BranchTraits< Var >::Merit MeritFunction
Corresponding merit function.
Definition:
var.hpp:58
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:767
Gecode::VarBranch::tbl
BranchTbl tbl(void) const
Return tie-break limit function.
Definition:
var.hpp:168
Gecode::Rnd
Random number generator.
Definition:
rnd.hpp:42
Gecode::VarBranch::VarBranch
VarBranch(void)
Initialize.
Definition:
var.hpp:116
Gecode::VarBranch::_rnd
Rnd _rnd
Random number generator.
Definition:
var.hpp:63
Test::afc
AFC afc
Definition:
afc.cpp:135
Gecode::VarBranch::chb
CHB chb(void) const
Return CHB.
Definition:
var.hpp:210
Gecode::VarBranch::action
Action action(void) const
Return action.
Definition:
var.hpp:198
Gecode::VarBranch::_afc
AFC _afc
AFC information.
Definition:
var.hpp:67
Gecode::AFC
Class for AFC (accumulated failure count) management.
Definition:
afc.hpp:40
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::UninitializedAction
Exception: uninitialized action
Definition:
exception.hpp:128
r
NNF * r
Right subtree.
Definition:
bool-expr.cpp:242
Gecode::UninitializedRnd
Exception: uninitialized random number generator
Definition:
exception.hpp:142
Test::Int::Unshare::f
Failed f
Definition:
unshare.cpp:124
Gecode::BranchTbl
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition:
var.hpp:48
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:
var.hpp:61
Gecode::UninitializedCHB
Exception: uninitialized CHB
Definition:
exception.hpp:135
Gecode::VarBranch::afc
AFC afc(void) const
Return AFC.
Definition:
var.hpp:186