Generated on Thu Jul 6 07:06:41 2006 for Gecode by doxygen 1.4.7

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: 2005-07-28 22:52:19 +0200 (Thu, 28 Jul 2005) $ by $Author: schulte $
00010  *     $Revision: 2072 $
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(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 // STATISTICS: int-branch
00108