Generated on Tue Apr 18 10:21:37 2017 for Gecode by doxygen 1.6.3

val-sel-commit.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2012
00008  *
00009  *  Last modified:
00010  *     $Date: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
00011  *     $Revision: 15623 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include <gecode/int/branch.hh>
00039 
00040 namespace Gecode { namespace Int { namespace Branch {
00041 
00042   ValSelCommitBase<IntView,int>*
00043   valselcommit(Space& home, const IntValBranch& ivb) {
00044     assert((ivb.select() != IntValBranch::SEL_VALUES_MIN) &&
00045            (ivb.select() != IntValBranch::SEL_VALUES_MAX));
00046     switch (ivb.select()) {
00047     case IntValBranch::SEL_MIN:
00048       return new (home)
00049         ValSelCommit<ValSelMin<IntView>,ValCommitEq<IntView> >(home,ivb);
00050     case IntValBranch::SEL_MED:
00051       return new (home)
00052         ValSelCommit<ValSelMed<IntView>,ValCommitEq<IntView> >(home,ivb);
00053     case IntValBranch::SEL_MAX:
00054       return new (home)
00055         ValSelCommit<ValSelMax<IntView>,ValCommitEq<IntView> >(home,ivb);
00056     case IntValBranch::SEL_RND:
00057       return new (home)
00058         ValSelCommit<ValSelRnd<IntView>,ValCommitEq<IntView> >(home,ivb);
00059     case IntValBranch::SEL_SPLIT_MIN:
00060       return new (home)
00061         ValSelCommit<ValSelAvg<IntView>,ValCommitLq<IntView> >(home,ivb);
00062     case IntValBranch::SEL_SPLIT_MAX:
00063       return new (home)
00064         ValSelCommit<ValSelAvg<IntView>,ValCommitGr<IntView> >(home,ivb);
00065     case IntValBranch::SEL_RANGE_MIN:
00066       return new (home)
00067         ValSelCommit<ValSelRangeMin,ValCommitLq<IntView> >(home,ivb);
00068     case IntValBranch::SEL_RANGE_MAX:
00069       return new (home)
00070         ValSelCommit<ValSelRangeMax,ValCommitGq<IntView> >(home,ivb);
00071     case IntValBranch::SEL_VAL_COMMIT:
00072       if (!ivb.commit()) {
00073         return new (home)
00074           ValSelCommit<ValSelFunction<IntView>,ValCommitEq<IntView> >(home,ivb);
00075       } else {
00076         return new (home)
00077           ValSelCommit<ValSelFunction<IntView>,ValCommitFunction<IntView> >(home,ivb);
00078       }
00079     default:
00080       throw UnknownBranching("Int::branch");
00081     }
00082   }
00083 
00084   ValSelCommitBase<IntView,int>*
00085   valselcommit(Space& home, const IntAssign& ia) {
00086     switch (ia.select()) {
00087     case IntAssign::SEL_MIN:
00088       return new (home)
00089         ValSelCommit<ValSelMin<IntView>,ValCommitEq<IntView> >(home,ia);
00090     case IntAssign::SEL_MED:
00091       return new (home)
00092         ValSelCommit<ValSelMed<IntView>,ValCommitEq<IntView> >(home,ia);
00093     case IntAssign::SEL_MAX:
00094       return new (home)
00095         ValSelCommit<ValSelMax<IntView>,ValCommitEq<IntView> >(home,ia);
00096     case IntAssign::SEL_RND:
00097       return new (home)
00098         ValSelCommit<ValSelRnd<IntView>,ValCommitEq<IntView> >(home,ia);
00099     case IntAssign::SEL_VAL_COMMIT:
00100       if (!ia.commit()) {
00101         return new (home)
00102           ValSelCommit<ValSelFunction<IntView>,ValCommitEq<IntView> >(home,ia);
00103       } else {
00104         return new (home)
00105           ValSelCommit<ValSelFunction<IntView>,ValCommitFunction<IntView> >(home,ia);
00106       }
00107     default:
00108       throw UnknownBranching("Int::assign");
00109     }
00110   }
00111 
00112   ValSelCommitBase<BoolView,int>*
00113   valselcommit(Space& home, const BoolValBranch& bvb) {
00114     switch (bvb.select()) {
00115     case BoolValBranch::SEL_MIN:
00116       return new (home)
00117         ValSelCommit<ValSelMin<BoolView>,ValCommitEq<BoolView> >(home,bvb);
00118     case BoolValBranch::SEL_MAX:
00119       return new (home)
00120         ValSelCommit<ValSelMax<BoolView>,ValCommitEq<BoolView> >(home,bvb);
00121     case BoolValBranch::SEL_RND:
00122       return new (home)
00123         ValSelCommit<ValSelRnd<BoolView>,ValCommitEq<BoolView> >(home,bvb);
00124     case BoolValBranch::SEL_VAL_COMMIT:
00125       if (!bvb.commit()) {
00126         return new (home)
00127           ValSelCommit<ValSelFunction<BoolView>,ValCommitEq<BoolView> >(home,bvb);
00128       } else {
00129         return new (home)
00130           ValSelCommit<ValSelFunction<BoolView>,ValCommitFunction<BoolView> >(home,bvb);
00131       }
00132     default:
00133       throw UnknownBranching("Int::branch");
00134     }
00135   }
00136 
00137   ValSelCommitBase<BoolView,int>*
00138   valselcommit(Space& home, const BoolAssign& ba) {
00139     switch (ba.select()) {
00140     case BoolAssign::SEL_MIN:
00141       return new (home)
00142         ValSelCommit<ValSelMin<BoolView>,ValCommitEq<BoolView> >(home,ba);
00143     case BoolAssign::SEL_MAX:
00144       return new (home)
00145         ValSelCommit<ValSelMax<BoolView>,ValCommitEq<BoolView> >(home,ba);
00146     case BoolAssign::SEL_RND:
00147       return new (home)
00148         ValSelCommit<ValSelRnd<BoolView>,ValCommitEq<BoolView> >(home,ba);
00149     case BoolAssign::SEL_VAL_COMMIT:
00150       if (!ba.commit()) {
00151         return new (home)
00152           ValSelCommit<ValSelFunction<BoolView>,ValCommitEq<BoolView> >(home,ba);
00153       } else {
00154         return new (home)
00155           ValSelCommit<ValSelFunction<BoolView>,ValCommitFunction<BoolView> >(home,ba);
00156       }
00157     default:
00158       throw UnknownBranching("Int::assign");
00159     }
00160   }
00161 
00162 }}}
00163 
00164 
00165 // STATISTICS: int-branch
00166