00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 namespace Gecode { namespace Int { namespace Branch {
00039
00040
00041 template<class View>
00042 forceinline
00043 MeritMin<View>::MeritMin(Space& home, const VarBranch<Var>& vb)
00044 : MeritBase<View,int>(home,vb) {}
00045 template<class View>
00046 forceinline
00047 MeritMin<View>::MeritMin(Space& home, bool shared, MeritMin& m)
00048 : MeritBase<View,int>(home,shared,m) {}
00049 template<class View>
00050 forceinline int
00051 MeritMin<View>::operator ()(const Space&, View x, int) {
00052 return x.min();
00053 }
00054
00055
00056 template<class View>
00057 forceinline
00058 MeritMax<View>::MeritMax(Space& home, const VarBranch<Var>& vb)
00059 : MeritBase<View,int>(home,vb) {}
00060 template<class View>
00061 forceinline
00062 MeritMax<View>::MeritMax(Space& home, bool shared, MeritMax& m)
00063 : MeritBase<View,int>(home,shared,m) {}
00064 template<class View>
00065 forceinline int
00066 MeritMax<View>::operator ()(const Space&, View x, int) {
00067 return x.max();
00068 }
00069
00070
00071 template<class View>
00072 forceinline
00073 MeritSize<View>::MeritSize(Space& home, const VarBranch<Var>& vb)
00074 : MeritBase<View,unsigned int>(home,vb) {}
00075 template<class View>
00076 forceinline
00077 MeritSize<View>::MeritSize(Space& home, bool shared, MeritSize& m)
00078 : MeritBase<View,unsigned int>(home,shared,m) {}
00079 template<class View>
00080 forceinline unsigned int
00081 MeritSize<View>::operator ()(const Space&, View x, int) {
00082 return x.size();
00083 }
00084
00085
00086 template<class View>
00087 forceinline
00088 MeritDegreeSize<View>::MeritDegreeSize(Space& home, const VarBranch<Var>& vb)
00089 : MeritBase<View,double>(home,vb) {}
00090 template<class View>
00091 forceinline
00092 MeritDegreeSize<View>::MeritDegreeSize(Space& home, bool shared,
00093 MeritDegreeSize& m)
00094 : MeritBase<View,double>(home,shared,m) {}
00095 template<class View>
00096 forceinline double
00097 MeritDegreeSize<View>::operator ()(const Space&, View x, int) {
00098 return static_cast<double>(x.degree()) / static_cast<double>(x.size());
00099 }
00100
00101
00102 template<class View>
00103 forceinline
00104 MeritAFCSize<View>::MeritAFCSize(Space& home, const VarBranch<Var>& vb)
00105 : MeritBase<View,double>(home,vb), afc(vb.afc()) {}
00106 template<class View>
00107 forceinline
00108 MeritAFCSize<View>::MeritAFCSize(Space& home, bool shared, MeritAFCSize& m)
00109 : MeritBase<View,double>(home,shared,m) {
00110 afc.update(home,shared,m.afc);
00111 }
00112 template<class View>
00113 forceinline double
00114 MeritAFCSize<View>::operator ()(const Space&, View x, int) {
00115 return x.afc() / static_cast<double>(x.size());
00116 }
00117 template<class View>
00118 forceinline bool
00119 MeritAFCSize<View>::notice(void) const {
00120 return true;
00121 }
00122 template<class View>
00123 forceinline void
00124 MeritAFCSize<View>::dispose(Space&) {
00125 afc.~AFC();
00126 }
00127
00128
00129 template<class View>
00130 forceinline
00131 MeritActionSize<View>::MeritActionSize(Space& home,
00132 const VarBranch<Var>& vb)
00133 : MeritBase<View,double>(home,vb), action(vb.action()) {}
00134 template<class View>
00135 forceinline
00136 MeritActionSize<View>::MeritActionSize(Space& home, bool shared,
00137 MeritActionSize& m)
00138 : MeritBase<View,double>(home,shared,m) {
00139 action.update(home, shared, m.action);
00140 }
00141 template<class View>
00142 forceinline double
00143 MeritActionSize<View>::operator ()(const Space&, View x, int i) {
00144 return action[i] / static_cast<double>(x.size());
00145 }
00146 template<class View>
00147 forceinline bool
00148 MeritActionSize<View>::notice(void) const {
00149 return true;
00150 }
00151 template<class View>
00152 forceinline void
00153 MeritActionSize<View>::dispose(Space&) {
00154 action.~Action();
00155 }
00156
00157
00158 template<class View>
00159 forceinline
00160 MeritCHBSize<View>::MeritCHBSize(Space& home,
00161 const VarBranch<Var>& vb)
00162 : MeritBase<View,double>(home,vb), chb(vb.chb()) {}
00163 template<class View>
00164 forceinline
00165 MeritCHBSize<View>::MeritCHBSize(Space& home, bool shared,
00166 MeritCHBSize& m)
00167 : MeritBase<View,double>(home,shared,m) {
00168 chb.update(home, shared, m.chb);
00169 }
00170 template<class View>
00171 forceinline double
00172 MeritCHBSize<View>::operator ()(const Space&, View x, int i) {
00173 return chb[i] / static_cast<double>(x.size());
00174 }
00175 template<class View>
00176 forceinline bool
00177 MeritCHBSize<View>::notice(void) const {
00178 return true;
00179 }
00180 template<class View>
00181 forceinline void
00182 MeritCHBSize<View>::dispose(Space&) {
00183 chb.~CHB();
00184 }
00185
00186
00187 template<class View>
00188 forceinline
00189 MeritRegretMin<View>::MeritRegretMin(Space& home, const VarBranch<Var>& vb)
00190 : MeritBase<View,unsigned int>(home,vb) {}
00191 template<class View>
00192 forceinline
00193 MeritRegretMin<View>::MeritRegretMin(Space& home, bool shared, MeritRegretMin& m)
00194 : MeritBase<View,unsigned int>(home,shared,m) {}
00195 template<class View>
00196 forceinline unsigned int
00197 MeritRegretMin<View>::operator ()(const Space&, View x, int) {
00198 return x.regret_min();
00199 }
00200
00201
00202 template<class View>
00203 forceinline
00204 MeritRegretMax<View>::MeritRegretMax(Space& home, const VarBranch<Var>& vb)
00205 : MeritBase<View,unsigned int>(home,vb) {}
00206 template<class View>
00207 forceinline
00208 MeritRegretMax<View>::MeritRegretMax(Space& home, bool shared, MeritRegretMax& m)
00209 : MeritBase<View,unsigned int>(home,shared,m) {}
00210 template<class View>
00211 forceinline unsigned int
00212 MeritRegretMax<View>::operator ()(const Space&, View x, int) {
00213 return x.regret_max();
00214 }
00215
00216 }}}
00217
00218