00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 namespace Gecode { namespace Int { namespace Branch {
00023
00024 forceinline int
00025 ValMin::val(const Space*, IntView x) const {
00026 return x.min();
00027 }
00028 forceinline ModEvent
00029 ValMin::tell(Space* home, unsigned int a, IntView x, int n) {
00030 return (a == 0) ? x.eq(home,n) : x.gr(home,n);
00031 }
00032
00033
00034 forceinline int
00035 ValMed::val(const Space*, IntView x) const {
00036 return x.med();
00037 }
00038 forceinline ModEvent
00039 ValMed::tell(Space* home, unsigned int a, IntView x, int n) {
00040 return (a == 0) ? x.eq(home,n) : x.nq(home,n);
00041 }
00042
00043
00044 forceinline int
00045 ValMax::val(const Space*, IntView x) const {
00046 return x.max();
00047 }
00048 forceinline ModEvent
00049 ValMax::tell(Space* home, unsigned int a, IntView x, int n) {
00050 return (a == 0) ? x.eq(home,n) : x.le(home,n);
00051 }
00052
00053
00054 forceinline int
00055 ValSplitMin::val(const Space*, IntView x) const {
00056 return (x.width() == 2) ? x.min() : ((x.min()+x.max()) / 2);
00057 }
00058 forceinline ModEvent
00059 ValSplitMin::tell(Space* home, unsigned int a, IntView x, int n) {
00060 return (a == 0) ? x.lq(home,n) : x.gr(home,n);
00061 }
00062
00063
00064 forceinline int
00065 ValSplitMax::val(const Space*, IntView x) const {
00066 return (x.width() == 2) ? x.min() : ((x.min()+x.max()) / 2);
00067 }
00068 forceinline ModEvent
00069 ValSplitMax::tell(Space* home, unsigned int a, IntView x, int n) {
00070 return (a == 0) ? x.gr(home,n) : x.lq(home,n);
00071 }
00072
00073
00074 template <class SelView>
00075 void
00076 create(Space* home, ViewArray<IntView>& x, BvalSel vals) {
00077 switch (vals) {
00078 case BVAL_MIN:
00079 (void) new (home) ViewValBranching<IntView,int,SelView,ValMin>(home,x);
00080 break;
00081 case BVAL_MED:
00082 (void) new (home) ViewValBranching<IntView,int,SelView,ValMed>(home,x);
00083 break;
00084 case BVAL_MAX:
00085 (void) new (home) ViewValBranching<IntView,int,SelView,ValMax>(home,x);
00086 break;
00087 case BVAL_SPLIT_MIN:
00088 (void) new (home)
00089 ViewValBranching<IntView,int,SelView,ValSplitMin>(home,x);
00090 break;
00091 case BVAL_SPLIT_MAX:
00092 (void) new (home)
00093 ViewValBranching<IntView,int,SelView,ValSplitMax>(home,x);
00094 break;
00095 default:
00096 throw UnknownBranching("Int::branch");
00097 }
00098 }
00099
00100 }}}
00101
00102
00103
00104