Exemple #1
0
  BrancherHandle
  branch(Home home, const SetVarArgs& x,
         SetVarBranch vars, SetValBranch vals,
         const Symmetries& syms,
         SetBranchFilter bf, SetVarValPrint vvp) {
    using namespace Set;
    if (home.failed()) return BrancherHandle();
    vars.expand(home,x);
    ViewArray<SetView> xv(home,x);
    ViewSel<SetView>* vs[1] = { 
      Branch::viewsel(home,vars) 
    };

    // Construct mapping from each variable in the array to its index
    // in the array.
    VariableMap variableMap;
    for (int i = 0 ; i < x.size() ; i++)
      variableMap[x[i].varimp()] = i;
    
    // Convert the modelling-level Symmetries object into an array of
    // SymmetryImp objects.
    int n = syms.size();
    SymmetryImp<SetView>** array = 
      static_cast<Space&>(home).alloc<SymmetryImp<SetView>* >(n);
    for (int i = 0 ; i < n ; i++) {
      array[i] = createSetSym(home, syms[i], variableMap);
    }

    return LDSBSetBrancher<SetView,1,int,2>::post
      (home,xv,vs,Branch::valselcommit(home,vals),array,n,bf,vvp);
  }
Exemple #2
0
 void
 branch(Home home, const SetVarArgs& x,
        SetVarBranch vars, SetValBranch vals,
        SetBranchFilter bf, SetVarValPrint vvp) {
   using namespace Set;
   if (home.failed()) return;
   vars.expand(home,x);
   ViewArray<SetView> xv(home,x);
   ViewSel<SetView>* vs[1] = {
     Branch::viewsel(home,vars)
   };
   ViewValBrancher<SetView,1,int,2>::post
     (home,xv,vs,Branch::valselcommit(home,vals),bf,vvp);
 }