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