void branch(Gecode::Home home, const SetVarArgs& x, const Gecode::TieBreakVarBranch<SetVarBranch>& vars, SetValBranch vals, const Gecode::TieBreakVarBranchOptions& o_vars, const Gecode::ValBranchOptions& o_vals) { using namespace Gecode; using namespace Gecode::Set; using namespace Gecode::Set::Branch; if (home.failed()) return; if ((vars.a == SET_VAR_NONE) || (vars.a == SET_VAR_RND) || ((vars.b == SET_VAR_NONE) && (vars.c == SET_VAR_NONE) && (vars.d == SET_VAR_NONE))) { branch(home,x,vars.a,vals,o_vars.a,o_vals); return; } if (o_vars.a.activity.initialized() && (o_vars.a.activity.size() != x.size())) throw ActivityWrongArity("branch (option a)"); if (o_vars.b.activity.initialized() && (o_vars.b.activity.size() != x.size())) throw ActivityWrongArity("branch (option b)"); if (o_vars.c.activity.initialized() && (o_vars.c.activity.size() != x.size())) throw ActivityWrongArity("branch (option c)"); if (o_vars.d.activity.initialized() && (o_vars.d.activity.size() != x.size())) throw ActivityWrongArity("branch (option d)"); ViewArray<SetView> xv(home,x); Gecode::ViewSelVirtualBase<SetView>* tb[3]; int n=0; if (vars.b != SET_VAR_NONE) virtualize(home,vars.b,o_vars.b,tb[n++]); if (vars.c != SET_VAR_NONE) virtualize(home,vars.c,o_vars.c,tb[n++]); if (vars.d != SET_VAR_NONE) virtualize(home,vars.d,o_vars.d,tb[n++]); assert(n > 0); ViewSelTieBreakDynamic<SetView> vbcd(home,tb,n); switch (vars.a) { case SET_VAR_DEGREE_MIN: { ViewSelDegreeMin<SetView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelDegreeMin<SetView>, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_DEGREE_MAX: { ViewSelDegreeMax<SetView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelDegreeMax<SetView>, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_AFC_MIN: { ViewSelAfcMin<SetView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelAfcMin<SetView>, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_AFC_MAX: { ViewSelAfcMax<SetView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelAfcMax<SetView>, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_ACTIVITY_MIN: { ViewSelActivityMin<SetView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelActivityMin<SetView>, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_ACTIVITY_MAX: { ViewSelActivityMax<SetView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelActivityMax<SetView>, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_MIN_MIN: { ByMinMin va(home,o_vars.a); ViewSelTieBreakStatic<ByMinMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_MIN_MAX: { ByMinMin va(home,o_vars.a); ViewSelTieBreakStatic<ByMinMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_MAX_MIN: { ByMaxMin va(home,o_vars.a); ViewSelTieBreakStatic<ByMaxMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_MAX_MAX: { ByMaxMax va(home,o_vars.a); ViewSelTieBreakStatic<ByMaxMax, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_MIN: { BySizeMin va(home,o_vars.a); ViewSelTieBreakStatic<BySizeMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_MAX: { BySizeMax va(home,o_vars.a); ViewSelTieBreakStatic<BySizeMax, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_DEGREE_MIN: { BySizeDegreeMin va(home,o_vars.a); ViewSelTieBreakStatic<BySizeDegreeMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_DEGREE_MAX: { BySizeDegreeMax va(home,o_vars.a); ViewSelTieBreakStatic<BySizeDegreeMax, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_AFC_MIN: { BySizeAfcMin va(home,o_vars.a); ViewSelTieBreakStatic<BySizeAfcMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_AFC_MAX: { BySizeAfcMax va(home,o_vars.a); ViewSelTieBreakStatic<BySizeAfcMax, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_ACTIVITY_MIN: { BySizeActivityMin va(home,o_vars.a); ViewSelTieBreakStatic<BySizeActivityMin, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case SET_VAR_SIZE_ACTIVITY_MAX: { BySizeActivityMax va(home,o_vars.a); ViewSelTieBreakStatic<BySizeActivityMax, ViewSelTieBreakDynamic<SetView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; default: throw UnknownBranching("Set::branch"); } }
void branch(Gecode::Home home, const BoolVarArgs& x, const Gecode::TieBreakVarBranch<IntVarBranch>& vars, IntValBranch vals, const Gecode::TieBreakVarBranchOptions& o_vars, const Gecode::ValBranchOptions& o_vals) { using namespace Gecode; using namespace Gecode::Int; using namespace Gecode::Int::Branch; if (home.failed()) return; if ((vars.a == INT_VAR_NONE) || (vars.a == INT_VAR_RND) || ((vars.b == INT_VAR_NONE) && (vars.c == INT_VAR_NONE) && (vars.d == INT_VAR_NONE))) { branch(home,x,vars.a,vals,o_vars.a,o_vals); return; } ViewArray<BoolView> xv(home,x); Gecode::ViewSelVirtualBase<BoolView>* tb[3]; int n=0; if (vars.b != INT_VAR_NONE) virtualize(home,vars.b,o_vars.b,tb[n++]); if (vars.c != INT_VAR_NONE) virtualize(home,vars.c,o_vars.c,tb[n++]); if (vars.d != INT_VAR_NONE) virtualize(home,vars.d,o_vars.d,tb[n++]); assert(n > 0); ViewSelTieBreakDynamic<BoolView> vbcd(home,tb,n); switch (vars.a) { case INT_VAR_MIN_MIN: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_MIN_MAX: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_MAX_MIN: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_MAX_MAX: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_SIZE_MIN: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_SIZE_MAX: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_DEGREE_MIN: { ViewSelDegreeMin<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelDegreeMin<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_DEGREE_MAX: { ViewSelDegreeMax<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelDegreeMax<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_AFC_MIN: { ViewSelAfcMin<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelAfcMin<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_AFC_MAX: { ViewSelAfcMax<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelAfcMax<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_SIZE_DEGREE_MIN: { ViewSelDegreeMax<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelDegreeMax<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_SIZE_DEGREE_MAX: { ViewSelDegreeMin<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelDegreeMin<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_SIZE_AFC_MIN: { ViewSelAfcMax<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelAfcMax<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_SIZE_AFC_MAX: { ViewSelAfcMin<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelAfcMin<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_REGRET_MIN_MIN: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_REGRET_MIN_MAX: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_REGRET_MAX_MIN: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; case INT_VAR_REGRET_MAX_MAX: { ViewSelNone<BoolView> va(home,o_vars.a); ViewSelTieBreakStatic<ViewSelNone<BoolView>, ViewSelTieBreakDynamic<BoolView> > v(home,va,vbcd); post(home,xv,v,vals,o_vals,o_vars.a.bf); } break; default: throw UnknownBranching("Int::branch"); } }
void branch(Gecode::Home home, const SetVarArgs& x, SetVarBranch vars, SetValBranch vals, const Gecode::VarBranchOptions& o_vars, const Gecode::ValBranchOptions& o_vals) { using namespace Gecode; using namespace Gecode::Set; using namespace Gecode::Set::Branch; if (home.failed()) return; if (o_vars.activity.initialized() && (o_vars.activity.size() != x.size())) throw ActivityWrongArity("branch"); ViewArray<SetView> xv(home,x); switch (vars) { case SET_VAR_NONE: { ViewSelNone<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_RND: { ViewSelRnd<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_DEGREE_MIN: { ViewSelDegreeMin<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_DEGREE_MAX: { ViewSelDegreeMax<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_AFC_MIN: { ViewSelAfcMin<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_AFC_MAX: { ViewSelAfcMax<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_ACTIVITY_MIN: { ViewSelActivityMin<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_ACTIVITY_MAX: { ViewSelActivityMax<SetView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_MIN_MIN: { ByMinMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_MIN_MAX: { ByMinMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_MAX_MIN: { ByMaxMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_MAX_MAX: { ByMaxMax v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_MIN: { BySizeMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_MAX: { BySizeMax v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_DEGREE_MIN: { BySizeDegreeMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_DEGREE_MAX: { BySizeDegreeMax v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_AFC_MIN: { BySizeAfcMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_AFC_MAX: { BySizeAfcMax v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_ACTIVITY_MIN: { BySizeActivityMin v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case SET_VAR_SIZE_ACTIVITY_MAX: { BySizeActivityMax v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; default: throw UnknownBranching("Set::branch"); } }
void branch(Gecode::Home home, const BoolVarArgs& x, IntVarBranch vars, IntValBranch vals, const Gecode::VarBranchOptions& o_vars, const Gecode::ValBranchOptions& o_vals) { using namespace Gecode; using namespace Gecode::Int; using namespace Gecode::Int::Branch; if (home.failed()) return; ViewArray<BoolView> xv(home,x); switch (vars) { case INT_VAR_NONE: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_RND: { ViewSelRnd<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_MIN_MIN: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_MIN_MAX: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_MAX_MIN: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_MAX_MAX: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_SIZE_MIN: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_SIZE_MAX: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_DEGREE_MIN: { ViewSelDegreeMin<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_DEGREE_MAX: { ViewSelDegreeMax<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_AFC_MIN: { ViewSelAfcMin<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_AFC_MAX: { ViewSelAfcMax<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_SIZE_DEGREE_MIN: { ViewSelDegreeMax<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_SIZE_DEGREE_MAX: { ViewSelDegreeMin<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_SIZE_AFC_MIN: { ViewSelAfcMax<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_SIZE_AFC_MAX: { ViewSelAfcMin<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_REGRET_MIN_MIN: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_REGRET_MIN_MAX: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_REGRET_MAX_MIN: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; case INT_VAR_REGRET_MAX_MAX: { ViewSelNone<BoolView> v(home,o_vars); post(home,xv,v,vals,o_vals,o_vars.bf); } break; default: throw UnknownBranching("Int::branch"); } }