Generated on Fri Mar 20 15:55:59 2015 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  *  Last modified:
00010  *     $Date: 2013-02-19 13:26:08 +0100 (Tue, 19 Feb 2013) $ by $Author: schulte $
00011  *     $Revision: 13313 $
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   ViewSel<IntView>*
00043   viewselint(Space& home, const IntVarBranch& ivb) {
00044     switch (ivb.select()) {
00045     case IntVarBranch::SEL_NONE:
00046       return new (home) ViewSelNone<IntView>(home,ivb);
00047     case IntVarBranch::SEL_RND:
00048       return new (home) ViewSelRnd<IntView>(home,ivb);
00049     default: break;
00050     }
00051     if (ivb.tbl() != NULL) {
00052       switch (ivb.select()) {
00053       case IntVarBranch::SEL_MERIT_MIN:
00054         return new (home) ViewSelMinTbl<MeritFunction<IntView> >(home,ivb);
00055       case IntVarBranch::SEL_MERIT_MAX:
00056         return new (home) ViewSelMaxTbl<MeritFunction<IntView> >(home,ivb);
00057       case IntVarBranch::SEL_MIN_MIN:
00058         return new (home) ViewSelMinTbl<MeritMin<IntView> >(home,ivb);
00059       case IntVarBranch::SEL_MIN_MAX:
00060         return new (home) ViewSelMaxTbl<MeritMin<IntView> >(home,ivb);
00061       case IntVarBranch::SEL_MAX_MIN:
00062         return new (home) ViewSelMinTbl<MeritMax<IntView> >(home,ivb);
00063       case IntVarBranch::SEL_MAX_MAX:
00064         return new (home) ViewSelMaxTbl<MeritMax<IntView> >(home,ivb);
00065       case IntVarBranch::SEL_SIZE_MIN:
00066         return new (home) ViewSelMinTbl<MeritSize<IntView> >(home,ivb);
00067       case IntVarBranch::SEL_SIZE_MAX:
00068         return new (home) ViewSelMaxTbl<MeritSize<IntView> >(home,ivb);
00069       case IntVarBranch::SEL_DEGREE_MIN:
00070         return new (home) ViewSelMinTbl<MeritDegree<IntView> >(home,ivb);
00071       case IntVarBranch::SEL_DEGREE_MAX:
00072         return new (home) ViewSelMaxTbl<MeritDegree<IntView> >(home,ivb);
00073       case IntVarBranch::SEL_AFC_MIN:
00074         return new (home) ViewSelMinTbl<MeritAFC<IntView> >(home,ivb);
00075       case IntVarBranch::SEL_AFC_MAX:
00076         return new (home) ViewSelMaxTbl<MeritAFC<IntView> >(home,ivb);
00077       case IntVarBranch::SEL_ACTIVITY_MIN:
00078         return new (home) ViewSelMinTbl<MeritActivity<IntView> >(home,ivb);
00079       case IntVarBranch::SEL_ACTIVITY_MAX:
00080         return new (home) ViewSelMaxTbl<MeritActivity<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_ACTIVITY_SIZE_MIN:
00090         return new (home) ViewSelMinTbl<MeritActivitySize<IntView> >(home,ivb);
00091       case IntVarBranch::SEL_ACTIVITY_SIZE_MAX:
00092         return new (home) ViewSelMaxTbl<MeritActivitySize<IntView> >(home,ivb);
00093       case IntVarBranch::SEL_REGRET_MIN_MIN:
00094         return new (home) ViewSelMinTbl<MeritRegretMin<IntView> >(home,ivb);
00095       case IntVarBranch::SEL_REGRET_MIN_MAX:
00096         return new (home) ViewSelMaxTbl<MeritRegretMin<IntView> >(home,ivb);
00097       case IntVarBranch::SEL_REGRET_MAX_MIN:
00098         return new (home) ViewSelMinTbl<MeritRegretMax<IntView> >(home,ivb);
00099       case IntVarBranch::SEL_REGRET_MAX_MAX:
00100         return new (home) ViewSelMaxTbl<MeritRegretMax<IntView> >(home,ivb);
00101       default:
00102         throw UnknownBranching("Int::branch");
00103       }
00104     } else {
00105       switch (ivb.select()) {
00106       case IntVarBranch::SEL_MERIT_MIN:
00107         return new (home) ViewSelMin<MeritFunction<IntView> >(home,ivb);
00108       case IntVarBranch::SEL_MERIT_MAX:
00109         return new (home) ViewSelMax<MeritFunction<IntView> >(home,ivb);
00110       case IntVarBranch::SEL_MIN_MIN:
00111         return new (home) ViewSelMin<MeritMin<IntView> >(home,ivb);
00112       case IntVarBranch::SEL_MIN_MAX:
00113         return new (home) ViewSelMax<MeritMin<IntView> >(home,ivb);
00114       case IntVarBranch::SEL_MAX_MIN:
00115         return new (home) ViewSelMin<MeritMax<IntView> >(home,ivb);
00116       case IntVarBranch::SEL_MAX_MAX:
00117         return new (home) ViewSelMax<MeritMax<IntView> >(home,ivb);
00118       case IntVarBranch::SEL_SIZE_MIN:
00119         return new (home) ViewSelMin<MeritSize<IntView> >(home,ivb);
00120       case IntVarBranch::SEL_SIZE_MAX:
00121         return new (home) ViewSelMax<MeritSize<IntView> >(home,ivb);
00122       case IntVarBranch::SEL_DEGREE_MIN:
00123         return new (home) ViewSelMin<MeritDegree<IntView> >(home,ivb);
00124       case IntVarBranch::SEL_DEGREE_MAX:
00125         return new (home) ViewSelMax<MeritDegree<IntView> >(home,ivb);
00126       case IntVarBranch::SEL_AFC_MIN:
00127         return new (home) ViewSelMin<MeritAFC<IntView> >(home,ivb);
00128       case IntVarBranch::SEL_AFC_MAX:
00129         return new (home) ViewSelMax<MeritAFC<IntView> >(home,ivb);
00130       case IntVarBranch::SEL_ACTIVITY_MIN:
00131         return new (home) ViewSelMin<MeritActivity<IntView> >(home,ivb);
00132       case IntVarBranch::SEL_ACTIVITY_MAX:
00133         return new (home) ViewSelMax<MeritActivity<IntView> >(home,ivb);
00134       case IntVarBranch::SEL_DEGREE_SIZE_MIN:
00135         return new (home) ViewSelMin<MeritDegreeSize<IntView> >(home,ivb);
00136       case IntVarBranch::SEL_DEGREE_SIZE_MAX:
00137         return new (home) ViewSelMax<MeritDegreeSize<IntView> >(home,ivb);
00138       case IntVarBranch::SEL_AFC_SIZE_MIN:
00139         return new (home) ViewSelMin<MeritAFCSize<IntView> >(home,ivb);
00140       case IntVarBranch::SEL_AFC_SIZE_MAX:
00141         return new (home) ViewSelMax<MeritAFCSize<IntView> >(home,ivb);
00142       case IntVarBranch::SEL_ACTIVITY_SIZE_MIN:
00143         return new (home) ViewSelMin<MeritActivitySize<IntView> >(home,ivb);
00144       case IntVarBranch::SEL_ACTIVITY_SIZE_MAX:
00145         return new (home) ViewSelMax<MeritActivitySize<IntView> >(home,ivb);
00146       case IntVarBranch::SEL_REGRET_MIN_MIN:
00147         return new (home) ViewSelMin<MeritRegretMin<IntView> >(home,ivb);
00148       case IntVarBranch::SEL_REGRET_MIN_MAX:
00149         return new (home) ViewSelMax<MeritRegretMin<IntView> >(home,ivb);
00150       case IntVarBranch::SEL_REGRET_MAX_MIN:
00151         return new (home) ViewSelMin<MeritRegretMax<IntView> >(home,ivb);
00152       case IntVarBranch::SEL_REGRET_MAX_MAX:
00153         return new (home) ViewSelMax<MeritRegretMax<IntView> >(home,ivb);
00154       default:
00155         throw UnknownBranching("Int::branch");
00156       }
00157     }
00158     GECODE_NEVER;
00159     return NULL;
00160   }
00161 
00162   ViewSel<BoolView>*
00163   viewselbool(Space& home, const IntVarBranch& ivb) {
00164     switch (ivb.select()) {
00165     case IntVarBranch::SEL_NONE:
00166       return new (home) ViewSelNone<BoolView>(home,ivb);
00167     case IntVarBranch::SEL_RND:
00168       return new (home) ViewSelRnd<BoolView>(home,ivb);
00169     default: break;
00170     }
00171     if (ivb.tbl() != NULL) {
00172       switch (ivb.select()) {
00173       case IntVarBranch::SEL_MERIT_MIN:
00174         return new (home) ViewSelMinTbl<MeritFunction<BoolView> >(home,ivb);
00175       case IntVarBranch::SEL_MERIT_MAX:
00176         return new (home) ViewSelMaxTbl<MeritFunction<BoolView> >(home,ivb);
00177       case IntVarBranch::SEL_MIN_MIN:
00178       case IntVarBranch::SEL_MIN_MAX:
00179       case IntVarBranch::SEL_MAX_MIN:
00180       case IntVarBranch::SEL_MAX_MAX:
00181       case IntVarBranch::SEL_SIZE_MIN:
00182       case IntVarBranch::SEL_SIZE_MAX:
00183       case IntVarBranch::SEL_REGRET_MIN_MIN:
00184       case IntVarBranch::SEL_REGRET_MIN_MAX:
00185       case IntVarBranch::SEL_REGRET_MAX_MIN:
00186       case IntVarBranch::SEL_REGRET_MAX_MAX:
00187         return new (home) ViewSelNone<BoolView>(home,ivb);
00188       case IntVarBranch::SEL_DEGREE_MIN:
00189         return new (home) ViewSelMinTbl<MeritDegree<BoolView> >(home,ivb);
00190       case IntVarBranch::SEL_DEGREE_MAX:
00191         return new (home) ViewSelMaxTbl<MeritDegree<BoolView> >(home,ivb);
00192       case IntVarBranch::SEL_AFC_MIN:
00193         return new (home) ViewSelMinTbl<MeritAFC<BoolView> >(home,ivb);
00194       case IntVarBranch::SEL_AFC_MAX:
00195         return new (home) ViewSelMaxTbl<MeritAFC<BoolView> >(home,ivb);
00196       case IntVarBranch::SEL_ACTIVITY_MIN:
00197         return new (home) ViewSelMinTbl<MeritActivity<BoolView> >(home,ivb);
00198       case IntVarBranch::SEL_ACTIVITY_MAX:
00199         return new (home) ViewSelMaxTbl<MeritActivity<BoolView> >(home,ivb);
00200       case IntVarBranch::SEL_DEGREE_SIZE_MIN:
00201         return new (home) ViewSelMinTbl<MeritDegreeSize<BoolView> >(home,ivb);
00202       case IntVarBranch::SEL_DEGREE_SIZE_MAX:
00203         return new (home) ViewSelMaxTbl<MeritDegreeSize<BoolView> >(home,ivb);
00204       case IntVarBranch::SEL_AFC_SIZE_MIN:
00205         return new (home) ViewSelMinTbl<MeritAFCSize<BoolView> >(home,ivb);
00206       case IntVarBranch::SEL_AFC_SIZE_MAX:
00207         return new (home) ViewSelMaxTbl<MeritAFCSize<BoolView> >(home,ivb);
00208       case IntVarBranch::SEL_ACTIVITY_SIZE_MIN:
00209         return new (home) ViewSelMinTbl<MeritActivitySize<BoolView> >(home,ivb);
00210       case IntVarBranch::SEL_ACTIVITY_SIZE_MAX:
00211         return new (home) ViewSelMaxTbl<MeritActivitySize<BoolView> >(home,ivb);
00212       default:
00213         throw UnknownBranching("Int::branch");
00214       }
00215     } else {
00216       switch (ivb.select()) {
00217       case IntVarBranch::SEL_MERIT_MIN:
00218         return new (home) ViewSelMin<MeritFunction<BoolView> >(home,ivb);
00219       case IntVarBranch::SEL_MERIT_MAX:
00220         return new (home) ViewSelMax<MeritFunction<BoolView> >(home,ivb);
00221       case IntVarBranch::SEL_MIN_MIN:
00222       case IntVarBranch::SEL_MIN_MAX:
00223       case IntVarBranch::SEL_MAX_MIN:
00224       case IntVarBranch::SEL_MAX_MAX:
00225       case IntVarBranch::SEL_SIZE_MIN:
00226       case IntVarBranch::SEL_SIZE_MAX:
00227       case IntVarBranch::SEL_REGRET_MIN_MIN:
00228       case IntVarBranch::SEL_REGRET_MIN_MAX:
00229       case IntVarBranch::SEL_REGRET_MAX_MIN:
00230       case IntVarBranch::SEL_REGRET_MAX_MAX:
00231         return new (home) ViewSelNone<BoolView>(home,ivb);
00232       case IntVarBranch::SEL_DEGREE_MIN:
00233       case IntVarBranch::SEL_DEGREE_SIZE_MIN:
00234         return new (home) ViewSelMin<MeritDegree<BoolView> >(home,ivb);
00235       case IntVarBranch::SEL_DEGREE_MAX:
00236       case IntVarBranch::SEL_DEGREE_SIZE_MAX:
00237         return new (home) ViewSelMax<MeritDegree<BoolView> >(home,ivb);
00238       case IntVarBranch::SEL_AFC_MIN:
00239       case IntVarBranch::SEL_AFC_SIZE_MIN:
00240         return new (home) ViewSelMin<MeritAFC<BoolView> >(home,ivb);
00241       case IntVarBranch::SEL_AFC_MAX:
00242       case IntVarBranch::SEL_AFC_SIZE_MAX:
00243         return new (home) ViewSelMax<MeritAFC<BoolView> >(home,ivb);
00244       case IntVarBranch::SEL_ACTIVITY_MIN:
00245       case IntVarBranch::SEL_ACTIVITY_SIZE_MIN:
00246         return new (home) ViewSelMin<MeritActivity<BoolView> >(home,ivb);
00247       case IntVarBranch::SEL_ACTIVITY_MAX:
00248       case IntVarBranch::SEL_ACTIVITY_SIZE_MAX:
00249         return new (home) ViewSelMax<MeritActivity<BoolView> >(home,ivb);
00250       default:
00251         throw UnknownBranching("Int::branch");
00252       }
00253     }
00254     GECODE_NEVER;
00255     return NULL;
00256   }
00257 
00258 }}}
00259 
00260 
00261 // STATISTICS: int-branch
00262