Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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
36namespace Gecode {
37
47 typedef std::function<double(const Space& home, double w, double b)>
49
54 template<class Var>
55 class VarBranch {
56 public:
59 protected:
65 double _decay;
74 public:
76 VarBranch(void);
82 VarBranch(double d, 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
117 : _tbl(nullptr), _decay(1.0) {}
118
119 template<class Var>
120 inline
123
124 template<class Var>
125 inline
127 : _tbl(t), _decay(d) {}
128
129 template<class Var>
130 inline
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
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
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
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
165
166 template<class Var>
167 inline BranchTbl
169 return _tbl;
170 }
171
172 template<class Var>
173 inline Rnd
175 return _rnd;
176 }
177
178 template<class Var>
179 inline double
181 return _decay;
182 }
183
184 template<class Var>
185 inline AFC
187 return _afc;
188 }
189
190 template<class Var>
191 inline void
193 _afc=a;
194 }
195
196 template<class Var>
197 inline Action
199 return _act;
200 }
201
202 template<class Var>
203 inline void
207
208 template<class Var>
209 inline CHB
211 return _chb;
212 }
213
214 template<class Var>
215 inline void
219
220 template<class Var>
221 inline typename VarBranch<Var>::MeritFunction
223 return _mf;
224 }
225
226}
227
228// STATISTICS: kernel-branch
Class for AFC (accumulated failure count) management.
Definition afc.hpp:40
Class for action management.
Definition action.hpp:42
Traits for branching.
Definition traits.hpp:55
Class for CHB management.
Definition chb.hpp:46
Random number generator.
Definition rnd.hpp:42
Computation spaces.
Definition core.hpp:1744
Exception: uninitialized AFC
Exception: uninitialized action
Exception: uninitialized CHB
Exception: uninitialized random number generator
Action action(void) const
Return action.
Definition var.hpp:198
VarBranch(void)
Initialize.
Definition var.hpp:116
double decay(void) const
Return decay factor.
Definition var.hpp:180
BranchTbl tbl(void) const
Return tie-break limit function.
Definition var.hpp:168
MeritFunction merit(void) const
Return merit function.
Definition var.hpp:222
BranchTbl _tbl
Tie-breaking limit function.
Definition var.hpp:61
BranchTraits< Var >::Merit MeritFunction
Corresponding merit function.
Definition var.hpp:58
AFC _afc
AFC information.
Definition var.hpp:67
AFC afc(void) const
Return AFC.
Definition var.hpp:186
Rnd rnd(void) const
Return random number generator.
Definition var.hpp:174
CHB chb(void) const
Return CHB.
Definition var.hpp:210
MeritFunction _mf
Merit function.
Definition var.hpp:73
Rnd _rnd
Random number generator.
Definition var.hpp:63
CHB _chb
CHB information.
Definition var.hpp:71
Action _act
Action information.
Definition var.hpp:69
double _decay
Decay information for AFC and action.
Definition var.hpp:65
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition var.hpp:48
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition set.hh:773