00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <gecode/set/branch.hh>
00039
00040 namespace Gecode {
00041
00042 void
00043 branch(Home home, const SetVarArgs& x,
00044 SetVarBranch vars, SetValBranch vals,
00045 SetBranchFilter bf,
00046 SetVarValPrint vvp) {
00047 using namespace Set;
00048 if (home.failed()) return;
00049 vars.expand(home,x);
00050 ViewArray<SetView> xv(home,x);
00051 ViewSel<SetView>* vs[1] = {
00052 Branch::viewsel(home,vars)
00053 };
00054 postviewvalbrancher<SetView,1,int,2>
00055 (home,xv,vs,Branch::valselcommit(home,vals),bf,vvp);
00056 }
00057
00058 void
00059 branch(Home home, const SetVarArgs& x,
00060 TieBreak<SetVarBranch> vars, SetValBranch vals,
00061 SetBranchFilter bf,
00062 SetVarValPrint vvp) {
00063 using namespace Set;
00064 if (home.failed()) return;
00065 vars.a.expand(home,x);
00066 if ((vars.a.select() == SetVarBranch::SEL_NONE) ||
00067 (vars.a.select() == SetVarBranch::SEL_RND))
00068 vars.b = SET_VAR_NONE();
00069 vars.b.expand(home,x);
00070 if ((vars.b.select() == SetVarBranch::SEL_NONE) ||
00071 (vars.b.select() == SetVarBranch::SEL_RND))
00072 vars.c = SET_VAR_NONE();
00073 vars.c.expand(home,x);
00074 if ((vars.c.select() == SetVarBranch::SEL_NONE) ||
00075 (vars.c.select() == SetVarBranch::SEL_RND))
00076 vars.d = SET_VAR_NONE();
00077 vars.d.expand(home,x);
00078 if (vars.b.select() == SetVarBranch::SEL_NONE) {
00079 branch(home,x,vars.a,vals,bf,vvp);
00080 } else {
00081 ViewArray<SetView> xv(home,x);
00082 ValSelCommitBase<SetView,int>* vsc = Branch::valselcommit(home,vals);
00083 if (vars.c.select() == SetVarBranch::SEL_NONE) {
00084 ViewSel<SetView>* vs[2] = {
00085 Branch::viewsel(home,vars.a),Branch::viewsel(home,vars.b)
00086 };
00087 postviewvalbrancher<SetView,2,int,2>(home,xv,vs,vsc,bf,vvp);
00088 } else if (vars.d.select() == SetVarBranch::SEL_NONE) {
00089 ViewSel<SetView>* vs[3] = {
00090 Branch::viewsel(home,vars.a),Branch::viewsel(home,vars.b),
00091 Branch::viewsel(home,vars.c)
00092 };
00093 postviewvalbrancher<SetView,3,int,2>(home,xv,vs,vsc,bf,vvp);
00094 } else {
00095 ViewSel<SetView>* vs[4] = {
00096 Branch::viewsel(home,vars.a),Branch::viewsel(home,vars.b),
00097 Branch::viewsel(home,vars.c),Branch::viewsel(home,vars.d)
00098 };
00099 postviewvalbrancher<SetView,4,int,2>(home,xv,vs,vsc,bf,vvp);
00100 }
00101 }
00102 }
00103
00104 void
00105 branch(Home home, SetVar x, SetValBranch vals, SetVarValPrint vvp) {
00106 SetVarArgs xv(1); xv[0]=x;
00107 branch(home, xv, SET_VAR_NONE(), vals, nullptr, vvp);
00108 }
00109
00110 void
00111 assign(Home home, const SetVarArgs& x, SetAssign sa,
00112 SetBranchFilter bf,
00113 SetVarValPrint vvp) {
00114 using namespace Set;
00115 if (home.failed()) return;
00116 ViewArray<SetView> xv(home,x);
00117 ViewSel<SetView>* vs[1] = {
00118 new (home) ViewSelNone<SetView>(home,SET_VAR_NONE())
00119 };
00120 postviewvalbrancher<SetView,1,int,1>
00121 (home,xv,vs,Branch::valselcommit(home,sa),bf,vvp);
00122 }
00123
00124 void
00125 assign(Home home, SetVar x, SetAssign sa, SetVarValPrint vvp) {
00126 SetVarArgs xv(1); xv[0]=x;
00127 assign(home, xv, sa, nullptr, vvp);
00128 }
00129
00130 }
00131
00132