Generated on Sun Feb 17 15:24:07 2019 for Gecode by doxygen 1.6.3

var.hpp

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 namespace Gecode {
00035 
00036   forceinline
00037   IntVarBranch::IntVarBranch(void)
00038     : s(SEL_NONE) {}
00039 
00040   forceinline
00041   IntVarBranch::IntVarBranch(Select s0, BranchTbl t)
00042     : VarBranch<IntVar>(t), s(s0) {}
00043 
00044   forceinline
00045   IntVarBranch::IntVarBranch(Rnd r)
00046     : VarBranch<IntVar>(r), s(SEL_RND) {}
00047 
00048   forceinline
00049   IntVarBranch::IntVarBranch(Select s0, double d, BranchTbl t)
00050     : VarBranch<IntVar>(d,t), s(s0) {}
00051 
00052   forceinline
00053   IntVarBranch::IntVarBranch(Select s0, IntAFC a, BranchTbl t)
00054     : VarBranch<IntVar>(a,t), s(s0) {}
00055 
00056   forceinline
00057   IntVarBranch::IntVarBranch(Select s0, IntAction a, BranchTbl t)
00058     : VarBranch<IntVar>(a,t), s(s0) {}
00059 
00060   forceinline
00061   IntVarBranch::IntVarBranch(Select s0, IntCHB c, BranchTbl t)
00062     : VarBranch<IntVar>(c,t), s(s0) {}
00063 
00064   forceinline
00065   IntVarBranch::IntVarBranch(Select s0, IntBranchMerit mf, BranchTbl t)
00066     : VarBranch<IntVar>(mf,t), s(s0) {}
00067 
00068   forceinline IntVarBranch::Select
00069   IntVarBranch::select(void) const {
00070     return s;
00071   }
00072 
00073   forceinline void
00074   IntVarBranch::expand(Home home, const IntVarArgs& x) {
00075     switch (select()) {
00076     case SEL_AFC_MIN: case SEL_AFC_MAX:
00077     case SEL_AFC_SIZE_MIN: case SEL_AFC_SIZE_MAX:
00078       if (!_afc)
00079         _afc = IntAFC(home,x,decay());
00080       break;
00081     case SEL_ACTION_MIN: case SEL_ACTION_MAX:
00082     case SEL_ACTION_SIZE_MIN: case SEL_ACTION_SIZE_MAX:
00083       if (!_act)
00084         _act = IntAction(home,x,decay());
00085       break;
00086     case SEL_CHB_MIN: case SEL_CHB_MAX:
00087     case SEL_CHB_SIZE_MIN: case SEL_CHB_SIZE_MAX:
00088       if (!_chb)
00089         _chb = IntCHB(home,x);
00090       break;
00091     default: ;
00092     }
00093   }
00094 
00095   inline IntVarBranch
00096   INT_VAR_NONE(void) {
00097     return IntVarBranch(IntVarBranch::SEL_NONE,nullptr);
00098   }
00099 
00100   inline IntVarBranch
00101   INT_VAR_RND(Rnd r) {
00102     return IntVarBranch(r);
00103   }
00104 
00105   inline IntVarBranch
00106   INT_VAR_MERIT_MIN(IntBranchMerit bm, BranchTbl tbl) {
00107     return IntVarBranch(IntVarBranch::SEL_MERIT_MIN,bm,tbl);
00108   }
00109 
00110   inline IntVarBranch
00111   INT_VAR_MERIT_MAX(IntBranchMerit bm, BranchTbl tbl) {
00112     return IntVarBranch(IntVarBranch::SEL_MERIT_MAX,bm,tbl);
00113   }
00114 
00115   inline IntVarBranch
00116   INT_VAR_DEGREE_MIN(BranchTbl tbl) {
00117     return IntVarBranch(IntVarBranch::SEL_DEGREE_MIN,tbl);
00118   }
00119 
00120   inline IntVarBranch
00121   INT_VAR_DEGREE_MAX(BranchTbl tbl) {
00122     return IntVarBranch(IntVarBranch::SEL_DEGREE_MAX,tbl);
00123   }
00124 
00125   inline IntVarBranch
00126   INT_VAR_AFC_MIN(double d, BranchTbl tbl) {
00127     return IntVarBranch(IntVarBranch::SEL_AFC_MIN,d,tbl);
00128   }
00129 
00130   inline IntVarBranch
00131   INT_VAR_AFC_MIN(IntAFC a, BranchTbl tbl) {
00132     return IntVarBranch(IntVarBranch::SEL_AFC_MIN,a,tbl);
00133   }
00134 
00135   inline IntVarBranch
00136   INT_VAR_AFC_MAX(double d, BranchTbl tbl) {
00137     return IntVarBranch(IntVarBranch::SEL_AFC_MAX,d,tbl);
00138   }
00139 
00140   inline IntVarBranch
00141   INT_VAR_AFC_MAX(IntAFC a, BranchTbl tbl) {
00142     return IntVarBranch(IntVarBranch::SEL_AFC_MAX,a,tbl);
00143   }
00144 
00145   inline IntVarBranch
00146   INT_VAR_ACTION_MIN(double d, BranchTbl tbl) {
00147     return IntVarBranch(IntVarBranch::SEL_ACTION_MIN,d,tbl);
00148   }
00149 
00150   inline IntVarBranch
00151   INT_VAR_ACTION_MIN(IntAction a, BranchTbl tbl) {
00152     return IntVarBranch(IntVarBranch::SEL_ACTION_MIN,a,tbl);
00153   }
00154 
00155   inline IntVarBranch
00156   INT_VAR_ACTION_MAX(double d, BranchTbl tbl) {
00157     return IntVarBranch(IntVarBranch::SEL_ACTION_MAX,d,tbl);
00158   }
00159 
00160   inline IntVarBranch
00161   INT_VAR_ACTION_MAX(IntAction a, BranchTbl tbl) {
00162     return IntVarBranch(IntVarBranch::SEL_ACTION_MAX,a,tbl);
00163   }
00164 
00165   inline IntVarBranch
00166   INT_VAR_CHB_MIN(IntCHB c, BranchTbl tbl) {
00167     return IntVarBranch(IntVarBranch::SEL_CHB_MIN,c,tbl);
00168   }
00169 
00170   inline IntVarBranch
00171   INT_VAR_CHB_MIN(BranchTbl tbl) {
00172     return IntVarBranch(IntVarBranch::SEL_CHB_MIN,tbl);
00173   }
00174 
00175   inline IntVarBranch
00176   INT_VAR_CHB_MAX(IntCHB c, BranchTbl tbl) {
00177     return IntVarBranch(IntVarBranch::SEL_CHB_MAX,c,tbl);
00178   }
00179 
00180   inline IntVarBranch
00181   INT_VAR_CHB_MAX(BranchTbl tbl) {
00182     return IntVarBranch(IntVarBranch::SEL_CHB_MAX,tbl);
00183   }
00184 
00185   inline IntVarBranch
00186   INT_VAR_MIN_MIN(BranchTbl tbl) {
00187     return IntVarBranch(IntVarBranch::SEL_MIN_MIN,tbl);
00188   }
00189 
00190   inline IntVarBranch
00191   INT_VAR_MIN_MAX(BranchTbl tbl) {
00192     return IntVarBranch(IntVarBranch::SEL_MIN_MAX,tbl);
00193   }
00194 
00195   inline IntVarBranch
00196   INT_VAR_MAX_MIN(BranchTbl tbl) {
00197     return IntVarBranch(IntVarBranch::SEL_MAX_MIN,tbl);
00198   }
00199 
00200   inline IntVarBranch
00201   INT_VAR_MAX_MAX(BranchTbl tbl) {
00202     return IntVarBranch(IntVarBranch::SEL_MAX_MAX,tbl);
00203   }
00204 
00205   inline IntVarBranch
00206   INT_VAR_SIZE_MIN(BranchTbl tbl) {
00207     return IntVarBranch(IntVarBranch::SEL_SIZE_MIN,tbl);
00208   }
00209 
00210   inline IntVarBranch
00211   INT_VAR_SIZE_MAX(BranchTbl tbl) {
00212     return IntVarBranch(IntVarBranch::SEL_SIZE_MAX,tbl);
00213   }
00214 
00215   inline IntVarBranch
00216   INT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl) {
00217     return IntVarBranch(IntVarBranch::SEL_DEGREE_SIZE_MIN,tbl);
00218   }
00219 
00220   inline IntVarBranch
00221   INT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl) {
00222     return IntVarBranch(IntVarBranch::SEL_DEGREE_SIZE_MAX,tbl);
00223   }
00224 
00225   inline IntVarBranch
00226   INT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl) {
00227     return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MIN,d,tbl);
00228   }
00229 
00230   inline IntVarBranch
00231   INT_VAR_AFC_SIZE_MIN(IntAFC a, BranchTbl tbl) {
00232     return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MIN,a,tbl);
00233   }
00234 
00235   inline IntVarBranch
00236   INT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl) {
00237     return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MAX,d,tbl);
00238   }
00239 
00240   inline IntVarBranch
00241   INT_VAR_AFC_SIZE_MAX(IntAFC a, BranchTbl tbl) {
00242     return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MAX,a,tbl);
00243   }
00244 
00245   inline IntVarBranch
00246   INT_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl) {
00247     return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MIN,d,tbl);
00248   }
00249 
00250   inline IntVarBranch
00251   INT_VAR_ACTION_SIZE_MIN(IntAction a, BranchTbl tbl) {
00252     return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MIN,a,tbl);
00253   }
00254 
00255   inline IntVarBranch
00256   INT_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl) {
00257     return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MAX,d,tbl);
00258   }
00259 
00260   inline IntVarBranch
00261   INT_VAR_ACTION_SIZE_MAX(IntAction a, BranchTbl tbl) {
00262     return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MAX,a,tbl);
00263   }
00264 
00265   inline IntVarBranch
00266   INT_VAR_CHB_SIZE_MIN(IntCHB c, BranchTbl tbl) {
00267     return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MIN,c,tbl);
00268   }
00269 
00270   inline IntVarBranch
00271   INT_VAR_CHB_SIZE_MIN(BranchTbl tbl) {
00272     return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MIN,tbl);
00273   }
00274 
00275   inline IntVarBranch
00276   INT_VAR_CHB_SIZE_MAX(IntCHB c, BranchTbl tbl) {
00277     return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MAX,c,tbl);
00278   }
00279 
00280   inline IntVarBranch
00281   INT_VAR_CHB_SIZE_MAX(BranchTbl tbl) {
00282     return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MAX,tbl);
00283   }
00284 
00285   inline IntVarBranch
00286   INT_VAR_REGRET_MIN_MIN(BranchTbl tbl) {
00287     return IntVarBranch(IntVarBranch::SEL_REGRET_MIN_MIN,tbl);
00288   }
00289 
00290   inline IntVarBranch
00291   INT_VAR_REGRET_MIN_MAX(BranchTbl tbl) {
00292     return IntVarBranch(IntVarBranch::SEL_REGRET_MIN_MAX,tbl);
00293   }
00294 
00295   inline IntVarBranch
00296   INT_VAR_REGRET_MAX_MIN(BranchTbl tbl) {
00297     return IntVarBranch(IntVarBranch::SEL_REGRET_MAX_MIN,tbl);
00298   }
00299 
00300   inline IntVarBranch
00301   INT_VAR_REGRET_MAX_MAX(BranchTbl tbl) {
00302     return IntVarBranch(IntVarBranch::SEL_REGRET_MAX_MAX,tbl);
00303   }
00304 
00305 
00306 
00307   forceinline
00308   BoolVarBranch::BoolVarBranch(void)
00309     : s(SEL_NONE) {}
00310 
00311   forceinline
00312   BoolVarBranch::BoolVarBranch(Select s0, BranchTbl t)
00313     : VarBranch<BoolVar>(t), s(s0) {}
00314 
00315   forceinline
00316   BoolVarBranch::BoolVarBranch(Rnd r)
00317     : VarBranch<BoolVar>(r), s(SEL_RND) {}
00318 
00319   forceinline
00320   BoolVarBranch::BoolVarBranch(Select s0, double d, BranchTbl t)
00321     : VarBranch<BoolVar>(d,t), s(s0) {}
00322 
00323   forceinline
00324   BoolVarBranch::BoolVarBranch(Select s0, BoolAFC a, BranchTbl t)
00325     : VarBranch<BoolVar>(a,t), s(s0) {}
00326 
00327   forceinline
00328   BoolVarBranch::BoolVarBranch(Select s0, BoolAction a, BranchTbl t)
00329     : VarBranch<BoolVar>(a,t), s(s0) {}
00330 
00331   forceinline
00332   BoolVarBranch::BoolVarBranch(Select s0, BoolCHB c, BranchTbl t)
00333     : VarBranch<BoolVar>(c,t), s(s0) {}
00334 
00335   forceinline
00336   BoolVarBranch::BoolVarBranch(Select s0, BoolBranchMerit mf, BranchTbl t)
00337     : VarBranch<BoolVar>(mf,t), s(s0) {}
00338 
00339   forceinline BoolVarBranch::Select
00340   BoolVarBranch::select(void) const {
00341     return s;
00342   }
00343 
00344   forceinline void
00345   BoolVarBranch::expand(Home home, const BoolVarArgs& x) {
00346     switch (select()) {
00347     case SEL_AFC_MIN: case SEL_AFC_MAX:
00348       if (!_afc)
00349         _afc = BoolAFC(home,x,decay());
00350       break;
00351     case SEL_ACTION_MIN: case SEL_ACTION_MAX:
00352       if (!_act)
00353         _act = BoolAction(home,x,decay());
00354       break;
00355     case SEL_CHB_MIN: case SEL_CHB_MAX:
00356       if (!_chb)
00357         _chb = BoolCHB(home,x);
00358       break;
00359     default: ;
00360     }
00361   }
00362 
00363   inline BoolVarBranch
00364   BOOL_VAR_NONE(void) {
00365     return BoolVarBranch(BoolVarBranch::SEL_NONE,nullptr);
00366   }
00367 
00368   inline BoolVarBranch
00369   BOOL_VAR_RND(Rnd r) {
00370     return BoolVarBranch(r);
00371   }
00372 
00373   inline BoolVarBranch
00374   BOOL_VAR_MERIT_MIN(BoolBranchMerit bm, BranchTbl tbl) {
00375     return BoolVarBranch(BoolVarBranch::SEL_MERIT_MIN,bm,tbl);
00376   }
00377 
00378   inline BoolVarBranch
00379   BOOL_VAR_MERIT_MAX(BoolBranchMerit bm, BranchTbl tbl) {
00380     return BoolVarBranch(BoolVarBranch::SEL_MERIT_MAX,bm,tbl);
00381   }
00382 
00383   inline BoolVarBranch
00384   BOOL_VAR_DEGREE_MIN(BranchTbl tbl) {
00385     return BoolVarBranch(BoolVarBranch::SEL_DEGREE_MIN,tbl);
00386   }
00387 
00388   inline BoolVarBranch
00389   BOOL_VAR_DEGREE_MAX(BranchTbl tbl) {
00390     return BoolVarBranch(BoolVarBranch::SEL_DEGREE_MAX,tbl);
00391   }
00392 
00393   inline BoolVarBranch
00394   BOOL_VAR_AFC_MIN(double d, BranchTbl tbl) {
00395     return BoolVarBranch(BoolVarBranch::SEL_AFC_MIN,d,tbl);
00396   }
00397 
00398   inline BoolVarBranch
00399   BOOL_VAR_AFC_MIN(BoolAFC a, BranchTbl tbl) {
00400     return BoolVarBranch(BoolVarBranch::SEL_AFC_MIN,a,tbl);
00401   }
00402 
00403   inline BoolVarBranch
00404   BOOL_VAR_AFC_MAX(double d, BranchTbl tbl) {
00405     return BoolVarBranch(BoolVarBranch::SEL_AFC_MAX,d,tbl);
00406   }
00407 
00408   inline BoolVarBranch
00409   BOOL_VAR_AFC_MAX(BoolAFC a, BranchTbl tbl) {
00410     return BoolVarBranch(BoolVarBranch::SEL_AFC_MAX,a,tbl);
00411   }
00412 
00413   inline BoolVarBranch
00414   BOOL_VAR_ACTION_MIN(double d, BranchTbl tbl) {
00415     return BoolVarBranch(BoolVarBranch::SEL_ACTION_MIN,d,tbl);
00416   }
00417 
00418   inline BoolVarBranch
00419   BOOL_VAR_ACTION_MIN(BoolAction a, BranchTbl tbl) {
00420     return BoolVarBranch(BoolVarBranch::SEL_ACTION_MIN,a,tbl);
00421   }
00422 
00423   inline BoolVarBranch
00424   BOOL_VAR_ACTION_MAX(double d, BranchTbl tbl) {
00425     return BoolVarBranch(BoolVarBranch::SEL_ACTION_MAX,d,tbl);
00426   }
00427 
00428   inline BoolVarBranch
00429   BOOL_VAR_ACTION_MAX(BoolAction a, BranchTbl tbl) {
00430     return BoolVarBranch(BoolVarBranch::SEL_ACTION_MAX,a,tbl);
00431   }
00432 
00433   inline BoolVarBranch
00434   BOOL_VAR_CHB_MIN(BoolCHB c, BranchTbl tbl) {
00435     return BoolVarBranch(BoolVarBranch::SEL_CHB_MIN,c,tbl);
00436   }
00437 
00438   inline BoolVarBranch
00439   BOOL_VAR_CHB_MIN(BranchTbl tbl) {
00440     return BoolVarBranch(BoolVarBranch::SEL_CHB_MIN,tbl);
00441   }
00442 
00443   inline BoolVarBranch
00444   BOOL_VAR_CHB_MAX(BoolCHB c, BranchTbl tbl) {
00445     return BoolVarBranch(BoolVarBranch::SEL_CHB_MAX,c,tbl);
00446   }
00447 
00448   inline BoolVarBranch
00449   BOOL_VAR_CHB_MAX(BranchTbl tbl) {
00450     return BoolVarBranch(BoolVarBranch::SEL_CHB_MAX,tbl);
00451   }
00452 
00453 }
00454 
00455 // STATISTICS: int-branch