Generated on Mon Nov 30 23:53:22 2009 for Gecode by doxygen 1.6.1

branch.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, 2002
00008  *
00009  *  Last modified:
00010  *     $Date: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00011  *     $Revision: 9878 $
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/set/branch.hh>
00039 
00040 namespace Gecode {
00041 
00042   void
00043   assign(Home home, const SetVarArgs& x, SetAssign vals,
00044          const ValBranchOptions& o_vals) {
00045     using namespace Set;
00046     if (home.failed()) return;
00047     ViewArray<SetView> xv(home,x);
00048     ViewSelNone<SetView> v(home,VarBranchOptions::def);
00049     switch (vals) {
00050     case SET_ASSIGN_MIN_INC:
00051       {
00052         Branch::AssignValMin<true> a(home,o_vals);
00053         (void) new (home) ViewValBrancher
00054           <ViewSelNone<SetView>,Branch::AssignValMin<true> >
00055           (home,xv,v,a);
00056       }
00057       break;
00058     case SET_ASSIGN_MIN_EXC:
00059       {
00060         Branch::AssignValMin<false> a(home,o_vals);
00061         (void) new (home) ViewValBrancher
00062           <ViewSelNone<SetView>,Branch::AssignValMin<false> >
00063           (home,xv,v,a);
00064       }
00065       break;
00066     case SET_ASSIGN_MED_INC:
00067       {
00068         Branch::AssignValMed<true> a(home,o_vals);
00069         (void) new (home) ViewValBrancher
00070           <ViewSelNone<SetView>,Branch::AssignValMed<true> >
00071           (home,xv,v,a);
00072       }
00073       break;
00074     case SET_ASSIGN_MED_EXC:
00075       {
00076         Branch::AssignValMed<false> a(home,o_vals);
00077         (void) new (home) ViewValBrancher
00078           <ViewSelNone<SetView>,Branch::AssignValMed<false> >
00079           (home,xv,v,a);
00080       }
00081       break;
00082     case SET_ASSIGN_MAX_INC:
00083       {
00084         Branch::AssignValMax<true> a(home,o_vals);
00085         (void) new (home) ViewValBrancher
00086           <ViewSelNone<SetView>,Branch::AssignValMax<true> >
00087           (home,xv,v,a);
00088       }
00089       break;
00090     case SET_ASSIGN_MAX_EXC:
00091       {
00092         Branch::AssignValMax<false> a(home,o_vals);
00093         (void) new (home) ViewValBrancher
00094           <ViewSelNone<SetView>,Branch::AssignValMax<false> >
00095           (home,xv,v,a);
00096       }
00097       break;
00098     case SET_ASSIGN_RND_INC:
00099       {
00100         Branch::AssignValRnd<true> a(home,o_vals);
00101         (void) new (home) ViewValBrancher
00102           <ViewSelNone<SetView>,Branch::AssignValRnd<true> >
00103           (home,xv,v,a);
00104       }
00105       break;
00106     case SET_ASSIGN_RND_EXC:
00107       {
00108         Branch::AssignValRnd<false> a(home,o_vals);
00109         (void) new (home) ViewValBrancher
00110           <ViewSelNone<SetView>,Branch::AssignValRnd<false> >
00111           (home,xv,v,a);
00112       }
00113       break;
00114     default:
00115       throw UnknownBranching("Set::assign");
00116     }
00117   }
00118 
00119   void
00120   branch(Home home, SetVar x, SetValBranch vals,
00121          const ValBranchOptions& o_vals) {
00122     SetVarArgs xv(1); xv[0]=x;
00123     branch(home, xv, SET_VAR_NONE, vals, VarBranchOptions::def, o_vals);
00124   }
00125   
00126   void
00127   assign(Home home, SetVar x, SetAssign vals,
00128          const ValBranchOptions& o_vals) {
00129     SetVarArgs xv(1); xv[0]=x;
00130     assign(home, xv, vals, o_vals);
00131   }
00132 
00133 }
00134 
00135 // STATISTICS: set-branch
00136