Generated on Mon Feb 8 2021 00:00:00 for Gecode by doxygen 1.8.20
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)>
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
122  : _tbl(t), _decay(1.0) {}
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
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
193  _afc=a;
194  }
195 
196  template<class Var>
197  inline Action
199  return _act;
200  }
201 
202  template<class Var>
203  inline void
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
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
Class for action management.
Definition: action.hpp:42
VarBranch(Action a, BranchTbl t)
Initialize with action a and tie-break limit function t.
Definition: var.hpp:139
double decay(void) const
Return decay factor.
Definition: var.hpp:180
MeritFunction merit(void) const
Return merit function.
Definition: var.hpp:222
Class for CHB management.
Definition: chb.hpp:46
NodeType t
Type of node.
Definition: bool-expr.cpp:230
Action _act
Action information.
Definition: var.hpp:69
Exception: uninitialized AFC
Definition: exception.hpp:121
void action(Action a)
Set action to a.
Definition: var.hpp:204
Traits for branching.
Definition: traits.hpp:55
Variable branching information.
Definition: var.hpp:55
Gecode toplevel namespace
Rnd rnd(void) const
Return random number generator.
Definition: var.hpp:174
CHB _chb
CHB information.
Definition: var.hpp:71
void chb(CHB chb)
Set CHB to chb.
Definition: var.hpp:216
VarBranch(AFC a, BranchTbl t)
Initialize with AFC a and tie-break limit function t.
Definition: var.hpp:131
MeritFunction _mf
Merit function.
Definition: var.hpp:73
double _decay
Decay information for AFC and action.
Definition: var.hpp:65
BranchTraits< Var >::Merit MeritFunction
Corresponding merit function.
Definition: var.hpp:58
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:767
BranchTbl tbl(void) const
Return tie-break limit function.
Definition: var.hpp:168
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Random number generator.
Definition: rnd.hpp:42
VarBranch(void)
Initialize.
Definition: var.hpp:116
void afc(AFC a)
Set AFC to a.
Definition: var.hpp:192
Rnd _rnd
Random number generator.
Definition: var.hpp:63
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
CHB chb(void) const
Return CHB.
Definition: var.hpp:210
Action action(void) const
Return action.
Definition: var.hpp:198
AFC _afc
AFC information.
Definition: var.hpp:67
VarBranch(MeritFunction f, BranchTbl t)
Initialize with merit function f and tie-break limit function t.
Definition: var.hpp:163
VarBranch(BranchTbl t)
Initialize with tie-break limit function t.
Definition: var.hpp:121
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:40
Gecode::IntSet d(v, 7)
Exception: uninitialized action
Definition: exception.hpp:128
Exception: uninitialized random number generator
Definition: exception.hpp:142
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: var.hpp:48
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Gecode::FloatVal c(-8, 8)
VarBranch(Rnd r)
Initialize with random number generator r.
Definition: var.hpp:155
VarBranch(double d, BranchTbl t)
Initialize with decay factor d and tie-break limit function t.
Definition: var.hpp:126
BranchTbl _tbl
Tie-breaking limit function.
Definition: var.hpp:61
VarBranch(CHB c, BranchTbl t)
Initialize with CHB c and tie-break limit function t.
Definition: var.hpp:147
Exception: uninitialized CHB
Definition: exception.hpp:135
AFC afc(void) const
Return AFC.
Definition: var.hpp:186