Exemple #1
0
  @Override
  public DisposableValueIterator getValueIterator(boolean bottomUp) {
    if (_viterator == null || !_viterator.isReusable()) {
      _viterator =
          new DisposableValueIterator() {

            DisposableValueIterator vit;

            @Override
            public void bottomUpInit() {
              super.bottomUpInit();
              vit = var.getValueIterator(true);
            }

            @Override
            public void topDownInit() {
              super.topDownInit();
              vit = var.getValueIterator(false);
            }

            @Override
            public boolean hasNext() {
              return vit.hasNext();
            }

            @Override
            public boolean hasPrevious() {
              return vit.hasPrevious();
            }

            @Override
            public int next() {
              return vit.next() + cste;
            }

            @Override
            public int previous() {
              return vit.previous() + cste;
            }

            @Override
            public void dispose() {
              super.dispose();
              vit.dispose();
            }
          };
    }
    if (bottomUp) {
      _viterator.bottomUpInit();
    } else {
      _viterator.topDownInit();
    }
    return _viterator;
  }
Exemple #2
0
  @Override
  public DisposableValueIterator getValueIterator(boolean bottomUp) {
    if (_viterator == null || !_viterator.isReusable()) {
      _viterator =
          new DisposableValueIterator() {

            int value;

            @Override
            public void bottomUpInit() {
              super.bottomUpInit();
              this.value = LB.get();
            }

            @Override
            public void topDownInit() {
              super.topDownInit();
              this.value = UB.get();
            }

            @Override
            public boolean hasNext() {
              return this.value != -1;
            }

            @Override
            public boolean hasPrevious() {
              return this.value != -1;
            }

            @Override
            public int next() {
              int old = this.value;
              this.value = VALUES.nextSetBit(this.value + 1);
              return old + OFFSET;
            }

            @Override
            public int previous() {
              int old = this.value;
              this.value = VALUES.prevSetBit(this.value - 1);
              return old + OFFSET;
            }
          };
    }
    if (bottomUp) {
      _viterator.bottomUpInit();
    } else {
      _viterator.topDownInit();
    }
    return _viterator;
  }
Exemple #3
0
  public Explanation explain(VariableState what) {
    Explanation expl = new Explanation(null, null);
    OffsetIStateBitset invdom = solver.getExplainer().getRemovedValues(this);
    DisposableValueIterator it = invdom.getValueIterator();
    while (it.hasNext()) {
      int val = it.next();
      if ((what == VariableState.LB && val < this.getLB())
          || (what == VariableState.UB && val > this.getUB())
          || (what == VariableState.DOM)) {
        //                System.out.println("solver.explainer.explain(this,"+ val +") = " +
        // solver.explainer.explain(this, val));
        expl.add(solver.getExplainer().explain(this, val));
      }
    }

    //        System.out.println("BitsetIntVarImpl.explain " + this + invdom +  " expl: " + expl);
    return expl;
  }