Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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$ 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 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,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,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,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  : MeritBase<View,double>(home,m) {}
94  template<class View>
95  forceinline double
97  return static_cast<double>(x.degree()) / static_cast<double>(x.size());
98  }
99 
100  // AFC over size merit
101  template<class View>
104  : MeritBase<View,double>(home,vb), afc(vb.afc()) {}
105  template<class View>
108  : MeritBase<View,double>(home,m), afc(m.afc) {}
109  template<class View>
110  forceinline double
112  return x.afc() / static_cast<double>(x.size());
113  }
114  template<class View>
115  forceinline bool
117  return false;
118  }
119  template<class View>
120  forceinline void
122  // Not needed
123  afc.~AFC();
124  }
125 
126  // Action over size merit
127  template<class View>
130  const VarBranch<Var>& vb)
131  : MeritBase<View,double>(home,vb), action(vb.action()) {}
132  template<class View>
135  : MeritBase<View,double>(home,m), action(m.action) {}
136  template<class View>
137  forceinline double
139  return action[i] / static_cast<double>(x.size());
140  }
141  template<class View>
142  forceinline bool
144  return true;
145  }
146  template<class View>
147  forceinline void
149  action.~Action();
150  }
151 
152  // CHB over size merit
153  template<class View>
156  const VarBranch<Var>& vb)
157  : MeritBase<View,double>(home,vb), chb(vb.chb()) {}
158  template<class View>
161  : MeritBase<View,double>(home,m), chb(m.chb) {}
162  template<class View>
163  forceinline double
165  return chb[i] / static_cast<double>(x.size());
166  }
167  template<class View>
168  forceinline bool
170  return true;
171  }
172  template<class View>
173  forceinline void
175  chb.~CHB();
176  }
177 
178  // Minimum regret merit
179  template<class View>
182  : MeritBase<View,unsigned int>(home,vb) {}
183  template<class View>
186  : MeritBase<View,unsigned int>(home,m) {}
187  template<class View>
188  forceinline unsigned int
190  return x.regret_min();
191  }
192 
193  // Maximum regret merit
194  template<class View>
197  : MeritBase<View,unsigned int>(home,vb) {}
198  template<class View>
201  : MeritBase<View,unsigned int>(home,m) {}
202  template<class View>
203  forceinline unsigned int
205  return x.regret_max();
206  }
207 
208 }}}
209 
210 // STATISTICS: int-branch
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:169
Action action
Action information.
Definition: branch.hh:170
MeritRegretMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:196
~Action(void)
Destructor.
Definition: action.cpp:59
double operator()(const Space &home, View x, int i)
Return action over size as merit for view x at position i.
Definition: merit.hpp:138
AFC afc
Definition: afc.cpp:139
Merit class for CHB over size.
Definition: branch.hh:191
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:58
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.
Definition: merit.hpp:50
~AFC(void)
Destructor.
Definition: afc.hpp:161
Merit class for degree over size.
Definition: branch.hh:123
AFC afc
AFC information.
Definition: branch.hh:145
#define forceinline
Definition: config.hpp:182
Computation spaces.
Definition: core.hpp:1668
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:148
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:121
Gecode::IntArgs i(4, 1, 2, 3, 4)
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:116
Merit class for action over size.
Definition: branch.hh:166
double operator()(const Space &home, View x, int i)
Return degree over size as merit for view x at position i.
Definition: merit.hpp:96
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:88
Merit class for mimimum of integer views.
Definition: branch.hh:69
~CHB(void)
Destructor.
Definition: chb.cpp:59
CHB chb
CHB information.
Definition: branch.hh:195
double operator()(const Space &home, View x, int i)
Return AFC over size as merit for view x at position i.
Definition: merit.hpp:111
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:143
Merit class for minimum regret.
Definition: branch.hh:216
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:155
MeritRegretMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:181
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:174
Merit class for AFC over size.
Definition: branch.hh:141
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:103
Merit class for size.
Definition: branch.hh:105
Variable branching information.
Definition: var.hpp:59
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:129
int operator()(const Space &home, View x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:66
unsigned int operator()(const Space &home, View x, int i)
Return maximum regret as merit for view x at position i.
Definition: merit.hpp:204
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:43
Merit class for maximum regret.
Definition: branch.hh:234
Merit class for maximum.
Definition: branch.hh:87
Post propagator for SetVar x
Definition: set.hh:769
View View
View type.
Definition: merit.hpp:53
Gecode toplevel namespace
double operator()(const Space &home, View x, int i)
Return size over action as merit for view x at position i.
Definition: merit.hpp:164
unsigned int operator()(const Space &home, View x, int i)
Return minimum regret as merit for view x at position i.
Definition: merit.hpp:189
MeritSize(Space &home, const VarBranch< Var > &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