Generated on Sat Nov 9 2013 19:18:25 for Gecode by doxygen 1.8.4
merit.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-02-19 13:26:08 +0100 (Tue, 19 Feb 2013) $ by $Author: schulte $
11  * $Revision: 13313 $
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 { namespace Int { namespace Branch {
39 
40  // Minimum merit
41  template<class View>
44  : MeritBase<View,int>(home,vb) {}
45  template<class View>
48  : MeritBase<View,int>(home,shared,m) {}
49  template<class View>
50  forceinline int
52  return x.min();
53  }
54 
55  // Maximum merit
56  template<class View>
59  : MeritBase<View,int>(home,vb) {}
60  template<class View>
63  : MeritBase<View,int>(home,shared,m) {}
64  template<class View>
65  forceinline int
67  return x.max();
68  }
69 
70  // Size merit
71  template<class View>
74  : MeritBase<View,unsigned int>(home,vb) {}
75  template<class View>
78  : MeritBase<View,unsigned int>(home,shared,m) {}
79  template<class View>
80  forceinline unsigned int
82  return x.size();
83  }
84 
85  // Degree over size merit
86  template<class View>
89  : MeritBase<View,double>(home,vb) {}
90  template<class View>
93  MeritDegreeSize& m)
94  : MeritBase<View,double>(home,shared,m) {}
95  template<class View>
96  forceinline double
98  return static_cast<double>(x.degree()) / static_cast<double>(x.size());
99  }
100 
101  // AFC over size merit
102  template<class View>
105  : MeritBase<View,double>(home,vb), afc(vb.afc()) {}
106  template<class View>
109  : MeritBase<View,double>(home,shared,m) {
110  afc.update(home,shared,m.afc);
111  }
112  template<class View>
113  forceinline double
115  return x.afc(home) / static_cast<double>(x.size());
116  }
117  template<class View>
118  forceinline bool
120  return true;
121  }
122  template<class View>
123  forceinline void
125  afc.~AFC();
126  }
127 
128  // Activity over size merit
129  template<class View>
132  const VarBranch& vb)
133  : MeritBase<View,double>(home,vb), activity(vb.activity()) {}
134  template<class View>
138  : MeritBase<View,double>(home,shared,m) {
139  activity.update(home, shared, m.activity);
140  }
141  template<class View>
142  forceinline double
144  return activity[i] / static_cast<double>(x.size());
145  }
146  template<class View>
147  forceinline bool
149  return true;
150  }
151  template<class View>
152  forceinline void
154  activity.~Activity();
155  }
156 
157  // Minimum regret merit
158  template<class View>
161  : MeritBase<View,unsigned int>(home,vb) {}
162  template<class View>
165  : MeritBase<View,unsigned int>(home,shared,m) {}
166  template<class View>
167  forceinline unsigned int
169  return x.regret_min();
170  }
171 
172  // Maximum regret merit
173  template<class View>
176  : MeritBase<View,unsigned int>(home,vb) {}
177  template<class View>
180  : MeritBase<View,unsigned int>(home,shared,m) {}
181  template<class View>
182  forceinline unsigned int
184  return x.regret_max();
185  }
186 
187 }}}
188 
189 // STATISTICS: int-branch