Generated on Fri Oct 19 11:24:54 2018 for Gecode by doxygen 1.6.3

view-sel.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   ViewSel<IntView>*
00039   viewsel(Space& home, const IntVarBranch& ivb) {
00040     switch (ivb.select()) {
00041     case IntVarBranch::SEL_NONE:
00042       return new (home) ViewSelNone<IntView>(home,ivb);
00043     case IntVarBranch::SEL_RND:
00044       return new (home) ViewSelRnd<IntView>(home,ivb);
00045     default: break;
00046     }
00047     if (ivb.tbl() != NULL) {
00048       switch (ivb.select()) {
00049       case IntVarBranch::SEL_MERIT_MIN:
00050         return new (home) ViewSelMinTbl<MeritFunction<IntView>>(home,ivb);
00051       case IntVarBranch::SEL_MERIT_MAX:
00052         return new (home) ViewSelMaxTbl<MeritFunction<IntView>>(home,ivb);
00053       case IntVarBranch::SEL_MIN_MIN:
00054         return new (home) ViewSelMinTbl<MeritMin<IntView>>(home,ivb);
00055       case IntVarBranch::SEL_MIN_MAX:
00056         return new (home) ViewSelMaxTbl<MeritMin<IntView>>(home,ivb);
00057       case IntVarBranch::SEL_MAX_MIN:
00058         return new (home) ViewSelMinTbl<MeritMax<IntView>>(home,ivb);
00059       case IntVarBranch::SEL_MAX_MAX:
00060         return new (home) ViewSelMaxTbl<MeritMax<IntView>>(home,ivb);
00061       case IntVarBranch::SEL_SIZE_MIN:
00062         return new (home) ViewSelMinTbl<MeritSize<IntView>>(home,ivb);
00063       case IntVarBranch::SEL_SIZE_MAX:
00064         return new (home) ViewSelMaxTbl<MeritSize<IntView>>(home,ivb);
00065       case IntVarBranch::SEL_DEGREE_MIN:
00066         return new (home) ViewSelMinTbl<MeritDegree<IntView>>(home,ivb);
00067       case IntVarBranch::SEL_DEGREE_MAX:
00068         return new (home) ViewSelMaxTbl<MeritDegree<IntView>>(home,ivb);
00069       case IntVarBranch::SEL_AFC_MIN:
00070         return new (home) ViewSelMinTbl<MeritAFC<IntView>>(home,ivb);
00071       case IntVarBranch::SEL_AFC_MAX:
00072         return new (home) ViewSelMaxTbl<MeritAFC<IntView>>(home,ivb);
00073       case IntVarBranch::SEL_ACTION_MIN:
00074         return new (home) ViewSelMinTbl<MeritAction<IntView>>(home,ivb);
00075       case IntVarBranch::SEL_ACTION_MAX:
00076         return new (home) ViewSelMaxTbl<MeritAction<IntView>>(home,ivb);
00077       case IntVarBranch::SEL_CHB_MIN:
00078         return new (home) ViewSelMinTbl<MeritCHB<IntView>>(home,ivb);
00079       case IntVarBranch::SEL_CHB_MAX:
00080         return new (home) ViewSelMaxTbl<MeritCHB<IntView>>(home,ivb);
00081       case IntVarBranch::SEL_DEGREE_SIZE_MIN:
00082         return new (home) ViewSelMinTbl<MeritDegreeSize<IntView>>(home,ivb);
00083       case IntVarBranch::SEL_DEGREE_SIZE_MAX:
00084         return new (home) ViewSelMaxTbl<MeritDegreeSize<IntView>>(home,ivb);
00085       case IntVarBranch::SEL_AFC_SIZE_MIN:
00086         return new (home) ViewSelMinTbl<MeritAFCSize<IntView>>(home,ivb);
00087       case IntVarBranch::SEL_AFC_SIZE_MAX:
00088         return new (home) ViewSelMaxTbl<MeritAFCSize<IntView>>(home,ivb);
00089       case IntVarBranch::SEL_ACTION_SIZE_MIN:
00090         return new (home) ViewSelMinTbl<MeritActionSize<IntView>>(home,ivb);
00091       case IntVarBranch::SEL_ACTION_SIZE_MAX:
00092         return new (home) ViewSelMaxTbl<MeritActionSize<IntView>>(home,ivb);
00093       case IntVarBranch::SEL_CHB_SIZE_MIN:
00094         return new (home) ViewSelMinTbl<MeritCHBSize<IntView>>(home,ivb);
00095       case IntVarBranch::SEL_CHB_SIZE_MAX:
00096         return new (home) ViewSelMaxTbl<MeritCHBSize<IntView>>(home,ivb);
00097       case IntVarBranch::SEL_REGRET_MIN_MIN:
00098         return new (home) ViewSelMinTbl<MeritRegretMin<IntView>>(home,ivb);
00099       case IntVarBranch::SEL_REGRET_MIN_MAX:
00100         return new (home) ViewSelMaxTbl<MeritRegretMin<IntView>>(home,ivb);
00101       case IntVarBranch::SEL_REGRET_MAX_MIN:
00102         return new (home) ViewSelMinTbl<MeritRegretMax<IntView>>(home,ivb);
00103       case IntVarBranch::SEL_REGRET_MAX_MAX:
00104         return new (home) ViewSelMaxTbl<MeritRegretMax<IntView>>(home,ivb);
00105       default:
00106         throw UnknownBranching("Int::branch");
00107       }
00108     } else {
00109       switch (ivb.select()) {
00110       case IntVarBranch::SEL_MERIT_MIN:
00111         return new (home) ViewSelMin<MeritFunction<IntView>>(home,ivb);
00112       case IntVarBranch::SEL_MERIT_MAX:
00113         return new (home) ViewSelMax<MeritFunction<IntView>>(home,ivb);
00114       case IntVarBranch::SEL_MIN_MIN:
00115         return new (home) ViewSelMin<MeritMin<IntView>>(home,ivb);
00116       case IntVarBranch::SEL_MIN_MAX:
00117         return new (home) ViewSelMax<MeritMin<IntView>>(home,ivb);
00118       case IntVarBranch::SEL_MAX_MIN:
00119         return new (home) ViewSelMin<MeritMax<IntView>>(home,ivb);
00120       case IntVarBranch::SEL_MAX_MAX:
00121         return new (home) ViewSelMax<MeritMax<IntView>>(home,ivb);
00122       case IntVarBranch::SEL_SIZE_MIN:
00123         return new (home) ViewSelMin<MeritSize<IntView>>(home,ivb);
00124       case IntVarBranch::SEL_SIZE_MAX:
00125         return new (home) ViewSelMax<MeritSize<IntView>>(home,ivb);
00126       case IntVarBranch::SEL_DEGREE_MIN:
00127         return new (home) ViewSelMin<MeritDegree<IntView>>(home,ivb);
00128       case IntVarBranch::SEL_DEGREE_MAX:
00129         return new (home) ViewSelMax<MeritDegree<IntView>>(home,ivb);
00130       case IntVarBranch::SEL_AFC_MIN:
00131         return new (home) ViewSelMin<MeritAFC<IntView>>(home,ivb);
00132       case IntVarBranch::SEL_AFC_MAX:
00133         return new (home) ViewSelMax<MeritAFC<IntView>>(home,ivb);
00134       case IntVarBranch::SEL_ACTION_MIN:
00135         return new (home) ViewSelMin<MeritAction<IntView>>(home,ivb);
00136       case IntVarBranch::SEL_ACTION_MAX:
00137         return new (home) ViewSelMax<MeritAction<IntView>>(home,ivb);
00138       case IntVarBranch::SEL_CHB_MIN:
00139         return new (home) ViewSelMin<MeritCHB<IntView>>(home,ivb);
00140       case IntVarBranch::SEL_CHB_MAX:
00141         return new (home) ViewSelMax<MeritCHB<IntView>>(home,ivb);
00142       case IntVarBranch::SEL_DEGREE_SIZE_MIN:
00143         return new (home) ViewSelMin<MeritDegreeSize<IntView>>(home,ivb);
00144       case IntVarBranch::SEL_DEGREE_SIZE_MAX:
00145         return new (home) ViewSelMax<MeritDegreeSize<IntView>>(home,ivb);
00146       case IntVarBranch::SEL_AFC_SIZE_MIN:
00147         return new (home) ViewSelMin<MeritAFCSize<IntView>>(home,ivb);
00148       case IntVarBranch::SEL_AFC_SIZE_MAX:
00149         return new (home) ViewSelMax<MeritAFCSize<IntView>>(home,ivb);
00150       case IntVarBranch::SEL_ACTION_SIZE_MIN:
00151         return new (home) ViewSelMin<MeritActionSize<IntView>>(home,ivb);
00152       case IntVarBranch::SEL_ACTION_SIZE_MAX:
00153         return new (home) ViewSelMax<MeritActionSize<IntView>>(home,ivb);
00154       case IntVarBranch::SEL_CHB_SIZE_MIN:
00155         return new (home) ViewSelMin<MeritCHBSize<IntView>>(home,ivb);
00156       case IntVarBranch::SEL_CHB_SIZE_MAX:
00157         return new (home) ViewSelMax<MeritCHBSize<IntView>>(home,ivb);
00158       case IntVarBranch::SEL_REGRET_MIN_MIN:
00159         return new (home) ViewSelMin<MeritRegretMin<IntView>>(home,ivb);
00160       case IntVarBranch::SEL_REGRET_MIN_MAX:
00161         return new (home) ViewSelMax<MeritRegretMin<IntView>>(home,ivb);
00162       case IntVarBranch::SEL_REGRET_MAX_MIN:
00163         return new (home) ViewSelMin<MeritRegretMax<IntView>>(home,ivb);
00164       case IntVarBranch::SEL_REGRET_MAX_MAX:
00165         return new (home) ViewSelMax<MeritRegretMax<IntView>>(home,ivb);
00166       default:
00167         throw UnknownBranching("Int::branch");
00168       }
00169     }
00170     GECODE_NEVER;
00171     return NULL;
00172   }
00173 
00174   ViewSel<BoolView>*
00175   viewsel(Space& home, const BoolVarBranch& bvb) {
00176     switch (bvb.select()) {
00177     case BoolVarBranch::SEL_NONE:
00178       return new (home) ViewSelNone<BoolView>(home,bvb);
00179     case BoolVarBranch::SEL_RND:
00180       return new (home) ViewSelRnd<BoolView>(home,bvb);
00181     default: break;
00182     }
00183     if (bvb.tbl() != NULL) {
00184       switch (bvb.select()) {
00185       case BoolVarBranch::SEL_MERIT_MIN:
00186         return new (home) ViewSelMinTbl<MeritFunction<BoolView>>(home,bvb);
00187       case BoolVarBranch::SEL_MERIT_MAX:
00188         return new (home) ViewSelMaxTbl<MeritFunction<BoolView>>(home,bvb);
00189       case BoolVarBranch::SEL_DEGREE_MIN:
00190         return new (home) ViewSelMinTbl<MeritDegree<BoolView>>(home,bvb);
00191       case BoolVarBranch::SEL_DEGREE_MAX:
00192         return new (home) ViewSelMaxTbl<MeritDegree<BoolView>>(home,bvb);
00193       case BoolVarBranch::SEL_AFC_MIN:
00194         return new (home) ViewSelMinTbl<MeritAFC<BoolView>>(home,bvb);
00195       case BoolVarBranch::SEL_AFC_MAX:
00196         return new (home) ViewSelMaxTbl<MeritAFC<BoolView>>(home,bvb);
00197       case BoolVarBranch::SEL_ACTION_MIN:
00198         return new (home) ViewSelMinTbl<MeritAction<BoolView>>(home,bvb);
00199       case BoolVarBranch::SEL_ACTION_MAX:
00200         return new (home) ViewSelMaxTbl<MeritAction<BoolView>>(home,bvb);
00201       case BoolVarBranch::SEL_CHB_MIN:
00202         return new (home) ViewSelMinTbl<MeritCHB<BoolView>>(home,bvb);
00203       case BoolVarBranch::SEL_CHB_MAX:
00204         return new (home) ViewSelMaxTbl<MeritCHB<BoolView>>(home,bvb);
00205       default:
00206         throw UnknownBranching("Int::branch");
00207       }
00208     } else {
00209       switch (bvb.select()) {
00210       case BoolVarBranch::SEL_MERIT_MIN:
00211         return new (home) ViewSelMin<MeritFunction<BoolView>>(home,bvb);
00212       case BoolVarBranch::SEL_MERIT_MAX:
00213         return new (home) ViewSelMax<MeritFunction<BoolView>>(home,bvb);
00214       case BoolVarBranch::SEL_DEGREE_MIN:
00215         return new (home) ViewSelMin<MeritDegree<BoolView>>(home,bvb);
00216       case BoolVarBranch::SEL_DEGREE_MAX:
00217         return new (home) ViewSelMax<MeritDegree<BoolView>>(home,bvb);
00218       case BoolVarBranch::SEL_AFC_MIN:
00219         return new (home) ViewSelMin<MeritAFC<BoolView>>(home,bvb);
00220       case BoolVarBranch::SEL_AFC_MAX:
00221         return new (home) ViewSelMax<MeritAFC<BoolView>>(home,bvb);
00222       case BoolVarBranch::SEL_ACTION_MIN:
00223         return new (home) ViewSelMin<MeritAction<BoolView>>(home,bvb);
00224       case BoolVarBranch::SEL_ACTION_MAX:
00225         return new (home) ViewSelMax<MeritAction<BoolView>>(home,bvb);
00226       case BoolVarBranch::SEL_CHB_MIN:
00227         return new (home) ViewSelMin<MeritCHB<BoolView>>(home,bvb);
00228       case BoolVarBranch::SEL_CHB_MAX:
00229         return new (home) ViewSelMax<MeritCHB<BoolView>>(home,bvb);
00230       default:
00231         throw UnknownBranching("Int::branch");
00232       }
00233     }
00234     GECODE_NEVER;
00235     return NULL;
00236   }
00237 
00238 }}}
00239 
00240 
00241 // STATISTICS: int-branch
00242