main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:30 for Gecode by
doxygen
1.8.4
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: 2013-05-22 21:29:33 +0200 (Wed, 22 May 2013) $ by $Author: tack $
11
* $Revision: 13656 $
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 {
39
49
typedef
double (*
BranchTbl
)(
const
Space
& home,
double
w,
double
b
);
50
55
class
VarBranch
{
56
protected
:
58
BranchTbl
_tbl
;
60
Rnd
_rnd
;
62
double
_decay
;
64
AFC
_afc
;
66
Activity
_act
;
68
VoidFunction
_mf
;
69
public
:
71
VarBranch
(
BranchTbl
t
);
73
VarBranch
(
Rnd
r
);
75
VarBranch
(
double
d
,
BranchTbl
t
);
77
VarBranch
(
AFC
a
,
BranchTbl
t
);
79
VarBranch
(
Activity
a
,
BranchTbl
t
);
81
VarBranch
(
void
(*f)(
void
),
BranchTbl
t
);
83
BranchTbl
tbl
(
void
)
const
;
85
Rnd
rnd
(
void
)
const
;
87
double
decay
(
void
)
const
;
89
AFC
afc
(
void
)
const
;
91
void
afc
(
AFC
a
);
93
Activity
activity
(
void
)
const
;
95
void
activity
(
Activity
a
);
97
VoidFunction
merit
(
void
)
const
;
98
};
99
100
// Variable branching
101
forceinline
102
VarBranch::VarBranch
(
BranchTbl
t
)
103
: _tbl(t), _decay(1.0) {}
104
105
forceinline
106
VarBranch::VarBranch
(
double
d
,
BranchTbl
t
)
107
: _tbl(t), _decay(d) {}
108
109
forceinline
110
VarBranch::VarBranch
(
AFC
a
,
BranchTbl
t
)
111
: _tbl(t), _decay(1.0), _afc(a) {
112
if
(!
_afc
.
initialized
())
113
throw
UninitializedAFC
(
"VarBranch::VarBranch"
);
114
}
115
116
forceinline
117
VarBranch::VarBranch
(
Activity
a
,
BranchTbl
t
)
118
: _tbl(t), _decay(1.0), _act(a) {
119
if
(!
_act
.
initialized
())
120
throw
UninitializedActivity
(
"VarBranch::VarBranch"
);
121
}
122
123
forceinline
124
VarBranch::VarBranch
(
Rnd
r
)
125
: _tbl(NULL), _rnd(r), _decay(1.0) {
126
if
(!
_rnd
.
initialized
())
127
throw
UninitializedRnd
(
"VarBranch::VarBranch"
);
128
}
129
130
forceinline
131
VarBranch::VarBranch
(
VoidFunction
f,
BranchTbl
t
)
132
: _tbl(t), _decay(1.0), _mf(f) {}
133
134
forceinline
BranchTbl
135
VarBranch::tbl
(
void
)
const
{
136
return
_tbl
;
137
}
138
139
inline
Rnd
140
VarBranch::rnd
(
void
)
const
{
141
return
_rnd
;
142
}
143
144
inline
double
145
VarBranch::decay
(
void
)
const
{
146
return
_decay
;
147
}
148
149
inline
AFC
150
VarBranch::afc
(
void
)
const
{
151
return
_afc
;
152
}
153
154
inline
void
155
VarBranch::afc
(
AFC
a
) {
156
_afc
=
a
;
157
}
158
159
inline
Activity
160
VarBranch::activity
(
void
)
const
{
161
return
_act
;
162
}
163
164
inline
void
165
VarBranch::activity
(
Activity
a
) {
166
_act
=
a
;
167
}
168
169
forceinline
VoidFunction
170
VarBranch::merit
(
void
)
const
{
171
return
_mf
;
172
}
173
174
}
175
176
// STATISTICS: kernel-branch