Generated on Mon Aug 25 11:35:33 2008 for Gecode by doxygen 1.5.6

branch.cc

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, 2002
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-07-11 10:10:11 +0200 (Fri, 11 Jul 2008) $ by $Author: tack $
00011  *     $Revision: 7310 $
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 {
00041 
00042   using namespace Int;
00043 
00044   void
00045   branch(Space* home, const IntVarArgs& x,
00046          IntVarBranch vars, IntValBranch vals) {
00047     Branch::createBranch<ViewValBranching>(home,x,vars,vals);
00048   }
00049 
00050   void
00051   branch(Space* home, const BoolVarArgs& x,
00052          IntVarBranch vars, IntValBranch vals) {
00053     Branch::createBranch<ViewValBranching>(home,x,vars,vals);
00054   }
00055 
00056   void
00057   assign(Space* home, const IntVarArgs& x, IntAssign vals) {
00058     ViewArray<IntView> xv(home,x);
00059     switch (vals) {
00060     case INT_ASSIGN_MIN:
00061       if (home->failed()) return;
00062       (void) new (home) 
00063         ViewValAssignment<IntView,int,
00064                           Branch::ValMin<IntView> >(home,xv);
00065       break;
00066     case INT_ASSIGN_MED:
00067       if (home->failed()) return;
00068       (void) new (home) 
00069         ViewValAssignment<IntView,int,
00070                           Branch::ValMed<IntView> >(home,xv);
00071       break;
00072     case INT_ASSIGN_MAX:
00073       if (home->failed()) return;
00074       (void) new (home) 
00075         ViewValAssignment<IntView,int,
00076                           Branch::ValMax<IntView> >(home,xv);
00077       break;
00078     default:
00079       throw UnknownBranching("Int::assign");
00080     }
00081   }
00082 
00083   void
00084   assign(Space* home, const BoolVarArgs& x, IntAssign vals) {
00085     ViewArray<BoolView> xv(home,x);
00086     switch (vals) {
00087     case INT_ASSIGN_MIN:
00088     case INT_ASSIGN_MED:
00089       if (home->failed()) return;
00090       (void) new (home) 
00091         ViewValAssignment<BoolView,Branch::NoValue,
00092                           Branch::ValZeroOne<BoolView> >(home,xv);
00093       break;
00094     case INT_ASSIGN_MAX:
00095       if (home->failed()) return;
00096       (void) new (home) 
00097         ViewValAssignment<BoolView,Branch::NoValue,
00098                           Branch::ValOneZero<BoolView> >(home,xv);
00099       break;
00100     default:
00101       throw UnknownBranching("Int::assign");
00102     }
00103   }
00104 
00105   namespace Int { namespace Branch {
00106 
00107     template<class View, class Val, template <class> class SelView>
00109     class Creator {
00110     public:
00111       Reflection::ActorRegistrar<ViewValBranching<View,Val,SelView<View>,
00112         Branch::ValMin<View> > > r1;
00113       Reflection::ActorRegistrar<ViewValBranching<View,Val,SelView<View>,
00114         ValMed<View> > > r2;
00115       Reflection::ActorRegistrar<ViewValBranching<View,Val,SelView<View>,
00116         ValMax<View> > > r3;
00117       Reflection::ActorRegistrar<ViewValBranching<View,Val,SelView<View>,
00118         ValSplitMin<View> > > r4;
00119       Reflection::ActorRegistrar<ViewValBranching<View,Val,SelView<View>,
00120         ValSplitMax<View> > > r5;
00121     };
00122 
00123     Creator<IntView,int,BySizeMin> c1;
00124     Creator<IntView,int,BySizeMax> c2;
00125     Creator<IntView,int,ByMinMin> c3;
00126     Creator<IntView,int,ByMinMax> c4;
00127     Creator<IntView,int,ByMaxMin> c5;
00128     Creator<IntView,int,ByMaxMax> c6;
00129     Creator<IntView,int,ByNone> c7;
00130     Creator<IntView,int,ByRegretMinMin> c8;
00131     Creator<IntView,int,ByRegretMinMax> c9;
00132     Creator<IntView,int,ByRegretMaxMin> c10;
00133     Creator<IntView,int,ByRegretMaxMax> c11;
00134     Creator<IntView,int,ByDegreeMin> c12;
00135     Creator<IntView,int,ByDegreeMax> c13;
00136 
00137     Reflection::ActorRegistrar<ViewValBranching<BoolView,NoValue,
00138       ByDegreeMaxNoTies<BoolView>,ValOneZero<BoolView> > > r1;
00139     Reflection::ActorRegistrar<ViewValBranching<BoolView,NoValue,
00140       ByDegreeMaxNoTies<BoolView>,ValZeroOne<BoolView> > > r2;
00141     Reflection::ActorRegistrar<ViewValBranching<BoolView,NoValue,
00142       ByDegreeMinNoTies<BoolView>,ValOneZero<BoolView> > > r3;
00143     Reflection::ActorRegistrar<ViewValBranching<BoolView,NoValue,
00144       ByDegreeMinNoTies<BoolView>,ValZeroOne<BoolView> > > r4;
00145     Reflection::ActorRegistrar<ViewValBranching<BoolView,NoValue,
00146       ByNone<BoolView>,ValOneZero<BoolView> > > r5;
00147     Reflection::ActorRegistrar<ViewValBranching<BoolView,NoValue,
00148       ByNone<BoolView>,ValZeroOne<BoolView> > > r6;
00149 
00150     Reflection::ActorRegistrar<ViewValAssignment<IntView,int,
00151       ValMax<IntView> > > r7;
00152     Reflection::ActorRegistrar<ViewValAssignment<IntView,int,
00153       ValMed<IntView> > > r8;
00154     Reflection::ActorRegistrar<ViewValAssignment<IntView,int,
00155       ValMin<IntView> > > r9;
00156     Reflection::ActorRegistrar<ViewValAssignment<BoolView,NoValue,
00157       ValOneZero<BoolView> > > r10;
00158     Reflection::ActorRegistrar<ViewValAssignment<BoolView,NoValue,
00159       ValZeroOne<BoolView> > > r11;
00160 
00161   }}
00162 
00163 }
00164 
00165 
00166 // STATISTICS: int-post
00167