Generated on Sat Jul 29 2017 12:41:24 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: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
11  * $Revision: 15623 $
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() / 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  // Action over size merit
129  template<class View>
132  const VarBranch<Var>& vb)
133  : MeritBase<View,double>(home,vb), action(vb.action()) {}
134  template<class View>
137  MeritActionSize& m)
138  : MeritBase<View,double>(home,shared,m) {
139  action.update(home, shared, m.action);
140  }
141  template<class View>
142  forceinline double
144  return action[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  action.~Action();
155  }
156 
157  // CHB over size merit
158  template<class View>
161  const VarBranch<Var>& vb)
162  : MeritBase<View,double>(home,vb), chb(vb.chb()) {}
163  template<class View>
166  MeritCHBSize& m)
167  : MeritBase<View,double>(home,shared,m) {
168  chb.update(home, shared, m.chb);
169  }
170  template<class View>
171  forceinline double
173  return chb[i] / static_cast<double>(x.size());
174  }
175  template<class View>
176  forceinline bool
178  return true;
179  }
180  template<class View>
181  forceinline void
183  chb.~CHB();
184  }
185 
186  // Minimum regret merit
187  template<class View>
190  : MeritBase<View,unsigned int>(home,vb) {}
191  template<class View>
194  : MeritBase<View,unsigned int>(home,shared,m) {}
195  template<class View>
196  forceinline unsigned int
198  return x.regret_min();
199  }
200 
201  // Maximum regret merit
202  template<class View>
205  : MeritBase<View,unsigned int>(home,vb) {}
206  template<class View>
209  : MeritBase<View,unsigned int>(home,shared,m) {}
210  template<class View>
211  forceinline unsigned int
213  return x.regret_max();
214  }
215 
216 }}}
217 
218 // STATISTICS: int-branch
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:177
Action action
Action information.
Definition: branch.hh:170
MeritRegretMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:204
~Action(void)
Destructor.
Definition: action.cpp:74
void update(int i)
Update chb value at position i.
double operator()(const Space &home, View x, int i)
Return action over size as merit for view x at position i.
Definition: merit.hpp:143
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.
~AFC(void)
Destructor.
Definition: afc.hpp:152
Merit class for degree over size.
Definition: branch.hh:123
AFC afc
AFC information.
Definition: branch.hh:145
Computation spaces.
Definition: core.hpp:1748
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:153
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:124
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:119
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:97
void update(int i)
Update action value at position i.
Definition: action.hpp:306
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:74
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:114
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:148
Merit class for minimum regret.
Definition: branch.hh:216
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:160
MeritRegretMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:189
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:182
Merit class for AFC over size.
Definition: branch.hh:141
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:104
Merit class for size.
Definition: branch.hh:105
Variable branching information.
Definition: branch-var.hpp:59
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:131
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:173
unsigned int operator()(const Space &home, View x, int i)
Return maximum regret as merit for view x at position i.
Definition: merit.hpp:212
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:784
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:702
Gecode toplevel namespace
void update(Space &home, bool share, AFC &a)
Updating during cloning.
Definition: afc.hpp:155
double operator()(const Space &home, View x, int i)
Return size over action as merit for view x at position i.
Definition: merit.hpp:172
unsigned int operator()(const Space &home, View x, int i)
Return minimum regret as merit for view x at position i.
Definition: merit.hpp:197
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