Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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$ by $Author$
11  * $Revision$
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)>
53 
58  template<class Var>
59  class VarBranch {
60  public:
63  protected:
69  double _decay;
77  MeritFunction _mf;
78  public:
80  VarBranch(void);
84  VarBranch(Rnd r);
86  VarBranch(double d, 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
121  : _tbl(nullptr), _decay(1.0) {}
122 
123  template<class Var>
124  inline
126  : _tbl(t), _decay(1.0) {}
127 
128  template<class Var>
129  inline
131  : _tbl(t), _decay(d) {}
132 
133  template<class Var>
134  inline
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
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
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
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
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
197  _afc=a;
198  }
199 
200  template<class Var>
201  inline Action
203  return _act;
204  }
205 
206  template<class Var>
207  inline void
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
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
NodeType t
Type of node.
Definition: bool-expr.cpp:234
CHB _chb
CHB information.
Definition: var.hpp:75
BranchTbl _tbl
Tie-breaking limit function.
Definition: var.hpp:65
AFC _afc
AFC information.
Definition: var.hpp:71
AFC afc
Definition: afc.cpp:139
Exception: uninitialized AFC
Definition: exception.hpp:125
Exception: uninitialized action
Definition: exception.hpp:132
Action _act
Action information.
Definition: var.hpp:73
AFC afc(void) const
Return AFC.
Definition: var.hpp:190
Gecode::IntSet d(v, 7)
Gecode::FloatVal c(-8, 8)
BranchTraits< Var >::Merit MeritFunction
Corresponding merit function.
Definition: var.hpp:62
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
Rnd rnd(void) const
Return random number generator.
Definition: var.hpp:178
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
double decay(void) const
Return decay factor.
Definition: var.hpp:184
MeritFunction merit(void) const
Return merit function.
Definition: var.hpp:226
Exception: uninitialized CHB
Definition: exception.hpp:139
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: var.hpp:52
Exception: uninitialized random number generator
Definition: exception.hpp:146
Class for CHB management.
Definition: chb.hpp:50
Action action(void) const
Return action.
Definition: var.hpp:202
VarBranch(void)
Initialize.
Definition: var.hpp:120
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:769
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Variable branching information.
Definition: var.hpp:59
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
BranchTbl tbl(void) const
Return tie-break limit function.
Definition: var.hpp:172
CHB chb(void) const
Return CHB.
Definition: var.hpp:214
Gecode toplevel namespace
Class for action management.
Definition: action.hpp:46
Random number generator.
Definition: rnd.hpp:46
Rnd _rnd
Random number generator.
Definition: var.hpp:67
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition: branch.cpp:65
Traits for branching.
Definition: traits.hpp:59
MeritFunction _mf
Merit function.
Definition: var.hpp:77
double _decay
Decay information for AFC and action.
Definition: var.hpp:69