Generated on Sat Feb 7 2015 02:01:15 for Gecode by doxygen 1.8.9.1
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
void update(int i)
Update activity value at position i.
Definition: activity.hpp:303
double operator()(const Space &home, View x, int i)
Return size over activity as merit for view x at position i.
Definition: merit.hpp:143
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:148
MeritMin(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:43
Activity activity
Activity information.
Definition: branch.hh:164
MeritMax(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:58
AFC afc
Definition: afc.cpp:139
MeritAFCSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:104
unsigned int operator()(const Space &home, View x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:81
Base-class for merit class.
Merit class for size over degree.
Definition: branch.hh:120
Merit class for size over activity.
Definition: branch.hh:161
AFC afc
AFC information.
Definition: branch.hh:140
Computation spaces.
Definition: core.hpp:1362
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:124
Gecode::IntArgs i(4, 1, 2, 3, 4)
double operator()(const Space &home, View x, int i)
Return size over degree as merit for view x at position i.
Definition: merit.hpp:97
Merit class for mimimum of integer views.
Definition: branch.hh:69
double operator()(const Space &home, View x, int i)
Return size over AFC as merit for view x at position i.
Definition: merit.hpp:114
Merit class for minimum regret.
Definition: branch.hh:185
MeritActivitySize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:131
Merit class for size over afc.
Definition: branch.hh:137
MeritDegreeSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:88
MeritRegretMax(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:175
Merit class for size.
Definition: branch.hh:103
Variable branching information.
Definition: branch-var.hpp:55
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
int operator()(const Space &home, View x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:66
#define forceinline
Definition: config.hpp:132
unsigned int operator()(const Space &home, View x, int i)
Return maximum regret as merit for view x at position i.
Definition: merit.hpp:183
Merit class for maximum regret.
Definition: branch.hh:202
Merit class for maximum.
Definition: branch.hh:86
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:662
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:153
Gecode toplevel namespace
void update(Space &home, bool share, AFC &a)
Updating during cloning.
Definition: afc.hpp:157
unsigned int operator()(const Space &home, View x, int i)
Return minimum regret as merit for view x at position i.
Definition: merit.hpp:168
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:119
MeritSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:73
int operator()(const Space &home, View x, int i)
Return minimum as merit for view x at position i.
Definition: merit.hpp:51
MeritRegretMin(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:160