Generated on Thu Mar 22 10:39:34 2012 for Gecode by doxygen 1.6.3

post-view-bool.cpp

Go to the documentation of this file.
00001 /*
00002  *  CAUTION:
00003  *    This file has been automatically generated. Do not edit,
00004  *    edit the specification file
00005  *      gecode/int/branch/post-view-bool.bs
00006  *    instead.
00007  *
00008  *  This file contains generated code fragments which are
00009  *  copyrighted as follows:
00010  *
00011  *  Main author:
00012  *     Christian Schulte <schulte@gecode.org>
00013  *
00014  *  Copyright:
00015  *     Christian Schulte, 2008
00016  *
00017  *  The generated code fragments are part of Gecode, the generic
00018  *  constraint development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #include <gecode/int/branch.hh>
00043 
00044 namespace Gecode { namespace Int { namespace Branch {
00045 
00047   void
00048   virtualize(Gecode::Home home, IntVarBranch vars,
00049              const Gecode::VarBranchOptions& o_vars,
00050              Gecode::ViewSelVirtualBase<BoolView>*& v) {
00051     switch (vars) {
00052     case INT_VAR_RND:
00053       v = new (home) ViewSelVirtual<ViewSelRnd<BoolView> >(home,o_vars);
00054       break;
00055     case INT_VAR_MIN_MIN:
00056       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00057       break;
00058     case INT_VAR_MIN_MAX:
00059       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00060       break;
00061     case INT_VAR_MAX_MIN:
00062       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00063       break;
00064     case INT_VAR_MAX_MAX:
00065       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00066       break;
00067     case INT_VAR_SIZE_MIN:
00068       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00069       break;
00070     case INT_VAR_SIZE_MAX:
00071       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00072       break;
00073     case INT_VAR_DEGREE_MIN:
00074       v = new (home) ViewSelVirtual<ViewSelDegreeMin<BoolView> >(home,o_vars);
00075       break;
00076     case INT_VAR_DEGREE_MAX:
00077       v = new (home) ViewSelVirtual<ViewSelDegreeMax<BoolView> >(home,o_vars);
00078       break;
00079     case INT_VAR_AFC_MIN:
00080       v = new (home) ViewSelVirtual<ViewSelAfcMin<BoolView> >(home,o_vars);
00081       break;
00082     case INT_VAR_AFC_MAX:
00083       v = new (home) ViewSelVirtual<ViewSelAfcMax<BoolView> >(home,o_vars);
00084       break;
00085     case INT_VAR_SIZE_DEGREE_MIN:
00086       v = new (home) ViewSelVirtual<ViewSelDegreeMax<BoolView> >(home,o_vars);
00087       break;
00088     case INT_VAR_SIZE_DEGREE_MAX:
00089       v = new (home) ViewSelVirtual<ViewSelDegreeMin<BoolView> >(home,o_vars);
00090       break;
00091     case INT_VAR_SIZE_AFC_MIN:
00092       v = new (home) ViewSelVirtual<ViewSelAfcMax<BoolView> >(home,o_vars);
00093       break;
00094     case INT_VAR_SIZE_AFC_MAX:
00095       v = new (home) ViewSelVirtual<ViewSelAfcMin<BoolView> >(home,o_vars);
00096       break;
00097     case INT_VAR_REGRET_MIN_MIN:
00098       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00099       break;
00100     case INT_VAR_REGRET_MIN_MAX:
00101       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00102       break;
00103     case INT_VAR_REGRET_MAX_MIN:
00104       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00105       break;
00106     case INT_VAR_REGRET_MAX_MAX:
00107       v = new (home) ViewSelVirtual<ViewSelNone<BoolView> >(home,o_vars);
00108       break;
00109     default:
00110       throw UnknownBranching("Int::branch");
00111     }
00112   }
00113 
00114 }}}
00115 
00116 namespace Gecode {
00117 
00118   void
00119   branch(Gecode::Home home, const BoolVarArgs& x,
00120          IntVarBranch vars, IntValBranch vals,
00121          const Gecode::VarBranchOptions& o_vars,
00122          const Gecode::ValBranchOptions& o_vals) {
00123     using namespace Gecode;
00124     using namespace Gecode::Int;
00125     using namespace Gecode::Int::Branch;
00126 
00127 
00128     if (home.failed()) return;
00129     ViewArray<BoolView> xv(home,x);
00130     switch (vars) {
00131     case INT_VAR_NONE:
00132       {
00133         ViewSelNone<BoolView> v(home,o_vars);
00134         post(home,xv,v,vals,o_vals,o_vars.bf);
00135       }
00136       break;
00137     case INT_VAR_RND:
00138       {
00139         ViewSelRnd<BoolView> v(home,o_vars);
00140         post(home,xv,v,vals,o_vals,o_vars.bf);
00141       }
00142       break;
00143     case INT_VAR_MIN_MIN:
00144       {
00145         ViewSelNone<BoolView> v(home,o_vars);
00146         post(home,xv,v,vals,o_vals,o_vars.bf);
00147       }
00148       break;
00149     case INT_VAR_MIN_MAX:
00150       {
00151         ViewSelNone<BoolView> v(home,o_vars);
00152         post(home,xv,v,vals,o_vals,o_vars.bf);
00153       }
00154       break;
00155     case INT_VAR_MAX_MIN:
00156       {
00157         ViewSelNone<BoolView> v(home,o_vars);
00158         post(home,xv,v,vals,o_vals,o_vars.bf);
00159       }
00160       break;
00161     case INT_VAR_MAX_MAX:
00162       {
00163         ViewSelNone<BoolView> v(home,o_vars);
00164         post(home,xv,v,vals,o_vals,o_vars.bf);
00165       }
00166       break;
00167     case INT_VAR_SIZE_MIN:
00168       {
00169         ViewSelNone<BoolView> v(home,o_vars);
00170         post(home,xv,v,vals,o_vals,o_vars.bf);
00171       }
00172       break;
00173     case INT_VAR_SIZE_MAX:
00174       {
00175         ViewSelNone<BoolView> v(home,o_vars);
00176         post(home,xv,v,vals,o_vals,o_vars.bf);
00177       }
00178       break;
00179     case INT_VAR_DEGREE_MIN:
00180       {
00181         ViewSelDegreeMin<BoolView> v(home,o_vars);
00182         post(home,xv,v,vals,o_vals,o_vars.bf);
00183       }
00184       break;
00185     case INT_VAR_DEGREE_MAX:
00186       {
00187         ViewSelDegreeMax<BoolView> v(home,o_vars);
00188         post(home,xv,v,vals,o_vals,o_vars.bf);
00189       }
00190       break;
00191     case INT_VAR_AFC_MIN:
00192       {
00193         ViewSelAfcMin<BoolView> v(home,o_vars);
00194         post(home,xv,v,vals,o_vals,o_vars.bf);
00195       }
00196       break;
00197     case INT_VAR_AFC_MAX:
00198       {
00199         ViewSelAfcMax<BoolView> v(home,o_vars);
00200         post(home,xv,v,vals,o_vals,o_vars.bf);
00201       }
00202       break;
00203     case INT_VAR_SIZE_DEGREE_MIN:
00204       {
00205         ViewSelDegreeMax<BoolView> v(home,o_vars);
00206         post(home,xv,v,vals,o_vals,o_vars.bf);
00207       }
00208       break;
00209     case INT_VAR_SIZE_DEGREE_MAX:
00210       {
00211         ViewSelDegreeMin<BoolView> v(home,o_vars);
00212         post(home,xv,v,vals,o_vals,o_vars.bf);
00213       }
00214       break;
00215     case INT_VAR_SIZE_AFC_MIN:
00216       {
00217         ViewSelAfcMax<BoolView> v(home,o_vars);
00218         post(home,xv,v,vals,o_vals,o_vars.bf);
00219       }
00220       break;
00221     case INT_VAR_SIZE_AFC_MAX:
00222       {
00223         ViewSelAfcMin<BoolView> v(home,o_vars);
00224         post(home,xv,v,vals,o_vals,o_vars.bf);
00225       }
00226       break;
00227     case INT_VAR_REGRET_MIN_MIN:
00228       {
00229         ViewSelNone<BoolView> v(home,o_vars);
00230         post(home,xv,v,vals,o_vals,o_vars.bf);
00231       }
00232       break;
00233     case INT_VAR_REGRET_MIN_MAX:
00234       {
00235         ViewSelNone<BoolView> v(home,o_vars);
00236         post(home,xv,v,vals,o_vals,o_vars.bf);
00237       }
00238       break;
00239     case INT_VAR_REGRET_MAX_MIN:
00240       {
00241         ViewSelNone<BoolView> v(home,o_vars);
00242         post(home,xv,v,vals,o_vals,o_vars.bf);
00243       }
00244       break;
00245     case INT_VAR_REGRET_MAX_MAX:
00246       {
00247         ViewSelNone<BoolView> v(home,o_vars);
00248         post(home,xv,v,vals,o_vals,o_vars.bf);
00249       }
00250       break;
00251     default:
00252       throw UnknownBranching("Int::branch");
00253     }
00254   }
00255 
00256   void
00257   branch(Gecode::Home home, const BoolVarArgs& x,
00258          const Gecode::TieBreakVarBranch<IntVarBranch>& vars,
00259          IntValBranch vals,
00260          const Gecode::TieBreakVarBranchOptions& o_vars,
00261          const Gecode::ValBranchOptions& o_vals) {
00262     using namespace Gecode;
00263     using namespace Gecode::Int;
00264     using namespace Gecode::Int::Branch;
00265 
00266 
00267     if (home.failed()) return;
00268     if ((vars.a == INT_VAR_NONE) || (vars.a == INT_VAR_RND) ||
00269         ((vars.b == INT_VAR_NONE) && (vars.c == INT_VAR_NONE) && (vars.d == INT_VAR_NONE))) {
00270       branch(home,x,vars.a,vals,o_vars.a,o_vals);
00271       return;
00272     }
00273     ViewArray<BoolView> xv(home,x);
00274     Gecode::ViewSelVirtualBase<BoolView>* tb[3];
00275     int n=0;
00276     if (vars.b != INT_VAR_NONE)
00277       virtualize(home,vars.b,o_vars.b,tb[n++]);
00278     if (vars.c != INT_VAR_NONE)
00279       virtualize(home,vars.c,o_vars.c,tb[n++]);
00280     if (vars.d != INT_VAR_NONE)
00281       virtualize(home,vars.d,o_vars.d,tb[n++]);
00282     assert(n > 0);
00283     ViewSelTieBreakDynamic<BoolView> vbcd(home,tb,n);
00284     switch (vars.a) {
00285     case INT_VAR_MIN_MIN:
00286       {
00287         ViewSelNone<BoolView> va(home,o_vars.a);
00288         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00289           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00290         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00291       }
00292       break;
00293     case INT_VAR_MIN_MAX:
00294       {
00295         ViewSelNone<BoolView> va(home,o_vars.a);
00296         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00297           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00298         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00299       }
00300       break;
00301     case INT_VAR_MAX_MIN:
00302       {
00303         ViewSelNone<BoolView> va(home,o_vars.a);
00304         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00305           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00306         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00307       }
00308       break;
00309     case INT_VAR_MAX_MAX:
00310       {
00311         ViewSelNone<BoolView> va(home,o_vars.a);
00312         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00313           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00314         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00315       }
00316       break;
00317     case INT_VAR_SIZE_MIN:
00318       {
00319         ViewSelNone<BoolView> va(home,o_vars.a);
00320         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00321           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00322         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00323       }
00324       break;
00325     case INT_VAR_SIZE_MAX:
00326       {
00327         ViewSelNone<BoolView> va(home,o_vars.a);
00328         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00329           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00330         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00331       }
00332       break;
00333     case INT_VAR_DEGREE_MIN:
00334       {
00335         ViewSelDegreeMin<BoolView> va(home,o_vars.a);
00336         ViewSelTieBreakStatic<ViewSelDegreeMin<BoolView>,
00337           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00338         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00339       }
00340       break;
00341     case INT_VAR_DEGREE_MAX:
00342       {
00343         ViewSelDegreeMax<BoolView> va(home,o_vars.a);
00344         ViewSelTieBreakStatic<ViewSelDegreeMax<BoolView>,
00345           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00346         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00347       }
00348       break;
00349     case INT_VAR_AFC_MIN:
00350       {
00351         ViewSelAfcMin<BoolView> va(home,o_vars.a);
00352         ViewSelTieBreakStatic<ViewSelAfcMin<BoolView>,
00353           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00354         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00355       }
00356       break;
00357     case INT_VAR_AFC_MAX:
00358       {
00359         ViewSelAfcMax<BoolView> va(home,o_vars.a);
00360         ViewSelTieBreakStatic<ViewSelAfcMax<BoolView>,
00361           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00362         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00363       }
00364       break;
00365     case INT_VAR_SIZE_DEGREE_MIN:
00366       {
00367         ViewSelDegreeMax<BoolView> va(home,o_vars.a);
00368         ViewSelTieBreakStatic<ViewSelDegreeMax<BoolView>,
00369           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00370         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00371       }
00372       break;
00373     case INT_VAR_SIZE_DEGREE_MAX:
00374       {
00375         ViewSelDegreeMin<BoolView> va(home,o_vars.a);
00376         ViewSelTieBreakStatic<ViewSelDegreeMin<BoolView>,
00377           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00378         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00379       }
00380       break;
00381     case INT_VAR_SIZE_AFC_MIN:
00382       {
00383         ViewSelAfcMax<BoolView> va(home,o_vars.a);
00384         ViewSelTieBreakStatic<ViewSelAfcMax<BoolView>,
00385           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00386         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00387       }
00388       break;
00389     case INT_VAR_SIZE_AFC_MAX:
00390       {
00391         ViewSelAfcMin<BoolView> va(home,o_vars.a);
00392         ViewSelTieBreakStatic<ViewSelAfcMin<BoolView>,
00393           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00394         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00395       }
00396       break;
00397     case INT_VAR_REGRET_MIN_MIN:
00398       {
00399         ViewSelNone<BoolView> va(home,o_vars.a);
00400         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00401           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00402         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00403       }
00404       break;
00405     case INT_VAR_REGRET_MIN_MAX:
00406       {
00407         ViewSelNone<BoolView> va(home,o_vars.a);
00408         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00409           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00410         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00411       }
00412       break;
00413     case INT_VAR_REGRET_MAX_MIN:
00414       {
00415         ViewSelNone<BoolView> va(home,o_vars.a);
00416         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00417           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00418         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00419       }
00420       break;
00421     case INT_VAR_REGRET_MAX_MAX:
00422       {
00423         ViewSelNone<BoolView> va(home,o_vars.a);
00424         ViewSelTieBreakStatic<ViewSelNone<BoolView>,
00425           ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd);
00426         post(home,xv,v,vals,o_vals,o_vars.a.bf);
00427       }
00428       break;
00429     default:
00430       throw UnknownBranching("Int::branch");
00431     }
00432   }
00433 
00434 }
00435 
00436 
00437 // STATISTICS: int-branch
00438