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: 2010-03-11 22:16:29 +0100 (Thu, 11 Mar 2010) $ by $Author: schulte $ 00011 * $Revision: 10418 $ 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 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValMin<true> > 00054 ::post(home,xv,v,a); 00055 } 00056 break; 00057 case SET_ASSIGN_MIN_EXC: 00058 { 00059 Branch::AssignValMin<false> a(home,o_vals); 00060 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValMin<false> > 00061 ::post(home,xv,v,a); 00062 } 00063 break; 00064 case SET_ASSIGN_MED_INC: 00065 { 00066 Branch::AssignValMed<true> a(home,o_vals); 00067 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValMed<true> > 00068 ::post(home,xv,v,a); 00069 } 00070 break; 00071 case SET_ASSIGN_MED_EXC: 00072 { 00073 Branch::AssignValMed<false> a(home,o_vals); 00074 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValMed<false> > 00075 ::post(home,xv,v,a); 00076 } 00077 break; 00078 case SET_ASSIGN_MAX_INC: 00079 { 00080 Branch::AssignValMax<true> a(home,o_vals); 00081 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValMax<true> > 00082 ::post(home,xv,v,a); 00083 } 00084 break; 00085 case SET_ASSIGN_MAX_EXC: 00086 { 00087 Branch::AssignValMax<false> a(home,o_vals); 00088 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValMax<false> > 00089 ::post(home,xv,v,a); 00090 } 00091 break; 00092 case SET_ASSIGN_RND_INC: 00093 { 00094 Branch::AssignValRnd<true> a(home,o_vals); 00095 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValRnd<true> > 00096 ::post(home,xv,v,a); 00097 } 00098 break; 00099 case SET_ASSIGN_RND_EXC: 00100 { 00101 Branch::AssignValRnd<false> a(home,o_vals); 00102 ViewValBrancher<ViewSelNone<SetView>,Branch::AssignValRnd<false> > 00103 ::post(home,xv,v,a); 00104 } 00105 break; 00106 default: 00107 throw UnknownBranching("Set::assign"); 00108 } 00109 } 00110 00111 void 00112 branch(Home home, SetVar x, SetValBranch vals, 00113 const ValBranchOptions& o_vals) { 00114 SetVarArgs xv(1); xv[0]=x; 00115 branch(home, xv, SET_VAR_NONE, vals, VarBranchOptions::def, o_vals); 00116 } 00117 00118 void 00119 assign(Home home, SetVar x, SetAssign vals, 00120 const ValBranchOptions& o_vals) { 00121 SetVarArgs xv(1); xv[0]=x; 00122 assign(home, xv, vals, o_vals); 00123 } 00124 00125 } 00126 00127 // STATISTICS: set-branch 00128