Generated on Wed Nov 1 15:04:30 2006 for Gecode by doxygen 1.4.5

select-val.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2002
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3512 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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 // STATISTICS: int-branch
00104