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 #include <iostream>
00026 template <class View, class Val, class ViewSel, class ValSel>
00027 forceinline
00028 FirstSolBranching<View,Val,ViewSel,ValSel>::FirstSolBranching(Gecode::Space* home, Gecode::ViewArray<View>& x0)
00029 : Gecode::ViewValBranching<View,Val,ViewSel,ValSel>(home,x0), firstSolFound(false), myLvl(0)
00030 {
00031 solutionLvl = 0;
00032 }
00033
00034
00035 template <class View, class Val, class ViewSel, class ValSel>
00036 forceinline
00037 FirstSolBranching<View,Val,ViewSel,ValSel>::FirstSolBranching(Gecode::Space* home, bool share, FirstSolBranching& b)
00038 : Gecode::ViewValBranching<View,Val,ViewSel,ValSel>(home,share,b),
00039 firstSolFound(b.firstSolFound), myLvl(b.myLvl)
00040 {
00041 }
00042
00043 template <class View, class Val, class ViewSel, class ValSel>
00044 Gecode::Actor*
00045 FirstSolBranching<View,Val,ViewSel,ValSel>::copy(Gecode::Space* home, bool share) {
00046 return new (home)
00047 FirstSolBranching<View,Val,ViewSel,ValSel>(home,share,*this);
00048 }
00049
00050 template <class View, class Val, class ViewSel, class ValSel>
00051 bool
00052 FirstSolBranching<View,Val,ViewSel,ValSel>::status(const Gecode::Space *home) const {
00053
00054
00055
00056
00057
00058 bool still2branch = Gecode::ViewValBranching<View,Val,ViewSel,ValSel>::status(home);
00059 if ( ! still2branch)
00060 solutionLvl = myLvl;
00061 return still2branch;
00062
00063
00064 }
00065
00066 template <class View, class Val, class ViewSel, class ValSel>
00067 Gecode::ExecStatus
00068 FirstSolBranching<View,Val,ViewSel,ValSel>::commit(Gecode:: Space* home, const Gecode::BranchingDesc* d, unsigned int a) {
00069 if ( solutionLvl != 0 ) {
00070 if (myLvl == 0 )
00071 solutionLvl = 0;
00072 x[0].le(home, x[0].min());
00073 return Gecode::ES_FAILED;
00074 } else {
00075 myLvl++;
00076 return Gecode::ViewValBranching<View,Val,ViewSel,ValSel>::commit(home,d,a);
00077 }
00078 }