Generated on Sat Feb 7 2015 02:01:27 for Gecode by doxygen 1.8.9.1
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:
62  double _decay;
69  public:
73  VarBranch(Rnd r);
75  VarBranch(double d, 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
103  : _tbl(t), _decay(1.0) {}
104 
105  forceinline
107  : _tbl(t), _decay(d) {}
108 
109  forceinline
111  : _tbl(t), _decay(1.0), _afc(a) {
112  if (!_afc.initialized())
113  throw UninitializedAFC("VarBranch::VarBranch");
114  }
115 
116  forceinline
118  : _tbl(t), _decay(1.0), _act(a) {
119  if (!_act.initialized())
120  throw UninitializedActivity("VarBranch::VarBranch");
121  }
122 
123  forceinline
125  : _tbl(NULL), _rnd(r), _decay(1.0) {
126  if (!_rnd.initialized())
127  throw UninitializedRnd("VarBranch::VarBranch");
128  }
129 
130  forceinline
132  : _tbl(t), _decay(1.0), _mf(f) {}
133 
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
156  _afc=a;
157  }
158 
159  inline Activity
160  VarBranch::activity(void) const {
161  return _act;
162  }
163 
164  inline void
166  _act=a;
167  }
168 
170  VarBranch::merit(void) const {
171  return _mf;
172  }
173 
174 }
175 
176 // STATISTICS: kernel-branch
bool initialized(void) const
Test whether already initialized.
Definition: activity.hpp:338
NodeType t
Type of node.
Definition: bool-expr.cpp:234
double _decay
Decay information for AFC and activity.
Definition: branch-var.hpp:62
bool initialized(void) const
Test whether already initialized.
Definition: afc.hpp:123
Exception: uninitialized AFC
Definition: exception.hpp:97
AFC afc(void) const
Return AFC.
Definition: branch-var.hpp:150
Exception: uninitialized activity
Definition: exception.hpp:104
Rnd _rnd
Random number generator.
Definition: branch-var.hpp:60
BranchTbl tbl(void) const
Return tie-break limit function.
Definition: branch-var.hpp:135
Computation spaces.
Definition: core.hpp:1362
Activity _act
Activity information.
Definition: branch-var.hpp:66
AFC _afc
AFC information.
Definition: branch-var.hpp:64
Gecode::IntSet d(v, 7)
bool initialized(void) const
Test whether generator has been properly initialized.
Definition: rnd.hpp:114
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
double decay(void) const
Return decay factor.
Definition: branch-var.hpp:145
Exception: uninitialized random number generator
Definition: exception.hpp:111
Activity activity(void) const
Return activity.
Definition: branch-var.hpp:160
void(* VoidFunction)(void)
Base type for any function pointer.
Definition: cast.hpp:45
BranchTbl _tbl
Tie-breaking limit function.
Definition: branch-var.hpp:58
VoidFunction _mf
Merit function (generic function pointer)
Definition: branch-var.hpp:68
VarBranch(BranchTbl t)
Initialize with tie-break limit function t.
Definition: branch-var.hpp:102
VoidFunction merit(void) const
Return merit function.
Definition: branch-var.hpp:170
Rnd rnd(void) const
Return random number generator.
Definition: branch-var.hpp:140
Variable branching information.
Definition: branch-var.hpp:55
#define forceinline
Definition: config.hpp:132
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Random number generator.
Definition: rnd.hpp:46
Class for activity management.
Definition: activity.hpp:44
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
double(* BranchTbl)(const Space &home, double w, double b)
Tie-break limit function.
Definition: branch-var.hpp:49