Esempio n. 1
0
 public void pruningPhase() throws ContradictionException {
   for (int i = futureVars.nextSetBit(0); i > -1; i = futureVars.nextSetBit(i + 1)) {
     IntVar v = vars[i];
     DisposableValueIterator it3 = v.getValueIterator(true);
     vrms.clear();
     try {
       while (it3.hasNext()) {
         int val = it3.next();
         if (!gacValues[i].get(val - offsets[i])) {
           vrms.add(val);
           //                        v.removeVal(val, this, false);
         }
       }
       v.removeValues(vrms, this);
     } finally {
       it3.dispose();
     }
   }
 }
Esempio n. 2
0
  private PropLargeGACSTRPos(IntVar[] vs, TuplesList relation) {
    super(vs, relation);
    this.arity = vs.length;
    this.futureVars = new BitSet(arity);
    this.gacValues = new BitSet[arity];
    this.nbGacValues = new int[arity];

    this.offsets = new int[arity];
    int min = Integer.MAX_VALUE;
    for (int i = 0; i < arity; i++) {
      this.offsets[i] = vs[i].getLB();
      this.gacValues[i] = new BitSet(vs[i].getDomainSize());
      min = Math.min(min, offsets[i]);
    }
    vrms = new IntIterableBitSet();
    vrms.setOffset(min);
    listuples = new int[this.relation.getTupleTable().length];
    for (int i = 0; i < listuples.length; i++) {
      listuples[i] = i;
    }
    last = solver.getEnvironment().makeInt(listuples.length - 1);

    int[][] tt = this.relation.getTupleTable();
    boolean fastBooleanValidCheckAllowed = true;
    // check if all tuples are within the range
    // of the domain and if so set up a faster validity checker
    // that avoids checking original bounds first
    loop:
    for (int i = 0; i < tt.length; i++) {
      for (int j = 0; j < tt[i].length; j++) {
        int lb = vs[j].getLB();
        int ub = vs[j].getUB();
        if (lb < 0 || ub > 1) {
          fastBooleanValidCheckAllowed = false;
          break loop;
        }
      }
    }
    if (fastBooleanValidCheckAllowed) {
      valcheck = new FastBooleanValidityChecker(arity, vars);
    } else valcheck = new ValidityChecker(arity, vars);
  }