Generated on Sat Oct 20 2018 12:43:45 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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 namespace Gecode { namespace Int { namespace Branch {
35 
36  // Minimum merit
37  template<class View>
40  : MeritBase<View,int>(home,vb) {}
41  template<class View>
44  : MeritBase<View,int>(home,m) {}
45  template<class View>
46  forceinline int
48  return x.min();
49  }
50 
51  // Maximum merit
52  template<class View>
55  : MeritBase<View,int>(home,vb) {}
56  template<class View>
59  : MeritBase<View,int>(home,m) {}
60  template<class View>
61  forceinline int
63  return x.max();
64  }
65 
66  // Size merit
67  template<class View>
70  : MeritBase<View,unsigned int>(home,vb) {}
71  template<class View>
74  : MeritBase<View,unsigned int>(home,m) {}
75  template<class View>
76  forceinline unsigned int
78  return x.size();
79  }
80 
81  // Degree over size merit
82  template<class View>
85  : MeritBase<View,double>(home,vb) {}
86  template<class View>
89  : MeritBase<View,double>(home,m) {}
90  template<class View>
91  forceinline double
93  return static_cast<double>(x.degree()) / static_cast<double>(x.size());
94  }
95 
96  // AFC over size merit
97  template<class View>
100  : MeritBase<View,double>(home,vb), afc(vb.afc()) {}
101  template<class View>
104  : MeritBase<View,double>(home,m), afc(m.afc) {}
105  template<class View>
106  forceinline double
108  return x.afc() / static_cast<double>(x.size());
109  }
110  template<class View>
111  forceinline bool
113  return false;
114  }
115  template<class View>
116  forceinline void
118  // Not needed
119  afc.~AFC();
120  }
121 
122  // Action over size merit
123  template<class View>
126  const VarBranch<Var>& vb)
127  : MeritBase<View,double>(home,vb), action(vb.action()) {}
128  template<class View>
131  : MeritBase<View,double>(home,m), action(m.action) {}
132  template<class View>
133  forceinline double
135  return action[i] / static_cast<double>(x.size());
136  }
137  template<class View>
138  forceinline bool
140  return true;
141  }
142  template<class View>
143  forceinline void
145  action.~Action();
146  }
147 
148  // CHB over size merit
149  template<class View>
152  const VarBranch<Var>& vb)
153  : MeritBase<View,double>(home,vb), chb(vb.chb()) {}
154  template<class View>
157  : MeritBase<View,double>(home,m), chb(m.chb) {}
158  template<class View>
159  forceinline double
161  return chb[i] / static_cast<double>(x.size());
162  }
163  template<class View>
164  forceinline bool
166  return true;
167  }
168  template<class View>
169  forceinline void
171  chb.~CHB();
172  }
173 
174  // Minimum regret merit
175  template<class View>
178  : MeritBase<View,unsigned int>(home,vb) {}
179  template<class View>
182  : MeritBase<View,unsigned int>(home,m) {}
183  template<class View>
184  forceinline unsigned int
186  return x.regret_min();
187  }
188 
189  // Maximum regret merit
190  template<class View>
193  : MeritBase<View,unsigned int>(home,vb) {}
194  template<class View>
197  : MeritBase<View,unsigned int>(home,m) {}
198  template<class View>
199  forceinline unsigned int
201  return x.regret_max();
202  }
203 
204 }}}
205 
206 // STATISTICS: int-branch
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:165
Action action
Action information.
Definition: branch.hh:170
MeritRegretMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:192
~Action(void)
Destructor.
Definition: action.cpp:55
double operator()(const Space &home, View x, int i)
Return action over size as merit for view x at position i.
Definition: merit.hpp:134
AFC afc
Definition: afc.cpp:135
Merit class for CHB over size.
Definition: branch.hh:191
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:54
unsigned int operator()(const Space &home, View x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:77
Base-class for merit class.
Definition: merit.hpp:46
~AFC(void)
Destructor.
Definition: afc.hpp:157
Merit class for degree over size.
Definition: branch.hh:123
AFC afc
AFC information.
Definition: branch.hh:145
#define forceinline
Definition: config.hpp:185
Computation spaces.
Definition: core.hpp:1701
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:144
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:117
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:112
Gecode::IntArgs i({1, 2, 3, 4})
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:92
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:84
Merit class for mimimum of integer views.
Definition: branch.hh:69
~CHB(void)
Destructor.
Definition: chb.cpp:55
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:107
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:139
Merit class for minimum regret.
Definition: branch.hh:216
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:151
MeritRegretMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:177
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:170
Merit class for AFC over size.
Definition: branch.hh:141
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:99
Merit class for size.
Definition: branch.hh:105
Variable branching information.
Definition: var.hpp:55
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:125
int operator()(const Space &home, View x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:62
unsigned int operator()(const Space &home, View x, int i)
Return maximum regret as merit for view x at position i.
Definition: merit.hpp:200
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:39
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:767
View View
View type.
Definition: merit.hpp:49
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:160
unsigned int operator()(const Space &home, View x, int i)
Return minimum regret as merit for view x at position i.
Definition: merit.hpp:185
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:69
int operator()(const Space &home, View x, int i)
Return minimum as merit for view x at position i.
Definition: merit.hpp:47