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  * Contributing authors:
7  * Gabor Szokoli <szokoli@gecode.org>
8  * Guido Tack <tack@gecode.org>
9  *
10  * Copyright:
11  * Christian Schulte, 2012
12  * Gabor Szokoli, 2004
13  * Guido Tack, 2004
14  *
15  * Last modified:
16  * $Date: 2013-07-01 09:17:01 +0200 (Mon, 01 Jul 2013) $ by $Author: tack $
17  * $Revision: 13742 $
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 namespace Gecode { namespace Set { namespace Branch {
45 
46  // Minimum merit
49  : MeritBase<SetView,int>(home,vb) {}
52  : MeritBase<SetView,int>(home,shared,m) {}
53  forceinline int
56  return u.min();
57  }
58 
59  // Maximum merit
62  : MeritBase<SetView,int>(home,vb) {}
65  : MeritBase<SetView,int>(home,shared,m) {}
66  forceinline int
68  int max = Limits::max;
69  for (UnknownRanges<SetView> u(x); u(); ++u)
70  max = u.max();
71  return max;
72  }
73 
74  // Size merit
77  : MeritBase<SetView,unsigned int>(home,vb) {}
80  : MeritBase<SetView,unsigned int>(home,shared,m) {}
81  forceinline unsigned int
83  return x.unknownSize();
84  }
85 
86  // Size over degree merit
89  : MeritBase<SetView,double>(home,vb) {}
92  MeritDegreeSize& m)
93  : MeritBase<SetView,double>(home,shared,m) {}
94  forceinline double
96  return static_cast<double>(x.unknownSize()) /
97  static_cast<double>(x.degree());
98  }
99 
100  // Size over AFC merit
103  : MeritBase<SetView,double>(home,vb), afc(vb.afc()) {}
106  : MeritBase<SetView,double>(home,shared,m) {
107  afc.update(home,shared,m.afc);
108  }
109  forceinline double
111  return static_cast<double>(x.unknownSize()) / x.afc(home);
112  }
113  forceinline bool
114  MeritAFCSize::notice(void) const {
115  return true;
116  }
117  forceinline void
119  afc.~AFC();
120  }
121 
122  // Size over activity merit
125  const VarBranch& vb)
126  : MeritBase<SetView,double>(home,vb), activity(vb.activity()) {}
130  : MeritBase<SetView,double>(home,shared,m) {
131  activity.update(home, shared, m.activity);
132  }
133  forceinline double
135  return activity[i] / static_cast<double>(x.unknownSize());
136  }
137  forceinline bool
139  return true;
140  }
141  forceinline void
144  }
145 
146 }}}
147 
148 // STATISTICS: set-branch