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(IntView x) {
00026 return x.min();
00027 }
00028 forceinline ModEvent
00029 ValMin::tell(Space* home, unsigned int a, IntView x, int n) {
00030 assert((a == 0) || (a == 1));
00031 return (a == 0) ? x.eq(home,n) : x.gr(home,n);
00032 }
00033
00034
00035 forceinline int
00036 ValMed::val(IntView x) {
00037 return x.med();
00038 }
00039 forceinline ModEvent
00040 ValMed::tell(Space* home, unsigned int a, IntView x, int n) {
00041 assert((a == 0) || (a == 1));
00042 return (a == 0) ? x.eq(home,n) : x.nq(home,n);
00043 }
00044
00045
00046 forceinline int
00047 ValMax::val(IntView x) {
00048 return x.max();
00049 }
00050 forceinline ModEvent
00051 ValMax::tell(Space* home, unsigned int a, IntView x, int n) {
00052 return (a == 0) ? x.eq(home,n) : x.le(home,n);
00053 }
00054
00055
00056 forceinline int
00057 ValSplitMin::val(IntView x) {
00058 return (x.width() == 2) ? x.min() : ((x.min()+x.max()) / 2);
00059 }
00060 forceinline ModEvent
00061 ValSplitMin::tell(Space* home, unsigned int a, IntView x, int n) {
00062 assert((a == 0) || (a == 1));
00063 return (a == 0) ? x.lq(home,n) : x.gr(home,n);
00064 }
00065
00066
00067 forceinline int
00068 ValSplitMax::val(IntView x) {
00069 return (x.width() == 2) ? x.min() : ((x.min()+x.max()) / 2);
00070 }
00071 forceinline ModEvent
00072 ValSplitMax::tell(Space* home, unsigned int a, IntView x, int n) {
00073 assert((a == 0) || (a == 1));
00074 return (a == 0) ? x.gr(home,n) : x.lq(home,n);
00075 }
00076
00077
00078 template <class SelView>
00079 void
00080 create(Space* home, ViewArray<IntView>& x, BvalSel vals) {
00081 switch (vals) {
00082 case BVAL_MIN:
00083 (void) new (home) ViewValBranching<IntView,int,SelView,ValMin>(home,x);
00084 break;
00085 case BVAL_MED:
00086 (void) new (home) ViewValBranching<IntView,int,SelView,ValMed>(home,x);
00087 break;
00088 case BVAL_MAX:
00089 (void) new (home) ViewValBranching<IntView,int,SelView,ValMax>(home,x);
00090 break;
00091 case BVAL_SPLIT_MIN:
00092 (void) new (home)
00093 ViewValBranching<IntView,int,SelView,ValSplitMin>(home,x);
00094 break;
00095 case BVAL_SPLIT_MAX:
00096 (void) new (home)
00097 ViewValBranching<IntView,int,SelView,ValSplitMax>(home,x);
00098 break;
00099 default:
00100 throw UnknownBranching("Int::branch");
00101 }
00102 }
00103
00104 }}}
00105
00106
00107
00108