Package kodkod.util.ints

Examples of kodkod.util.ints.IntBitSet


   * of one of the ArrayTrace constructors.
   * @return trace
   */
  private int[][] format(int[][] trace) {
    final int length = trace.length;
    final IntSet resolvents = new IntBitSet(length);
    final int offset = numberOfVariables() + 1;
    for(int i = 0; i < length; i++) {
      int[] clause = trace[i];
      if (clause!=null && clause[0]>=offset) {
        clause[0] -= offset;
        resolvents.add(i);
      }
    }
       
    final int axioms = length - resolvents.size();
    if (resolvents.min()<axioms) {
      final int[] position = new int[length];
      for(int i = 0, axiomIndex = 0, resolventIndex = axioms; i < length; i++) {
        if (resolvents.contains(i)) {
          position[i] = resolventIndex++;
          int[] resolvent = trace[i];
          for(int j = 0, resLength = resolvent.length; j < resLength; j++) {
            resolvent[j] = position[resolvent[j]];
          }
        } else {
          position[i] = axiomIndex++;
        }
      }

      for(IntIterator itr = resolvents.iterator(length, 0); itr.hasNext(); ) {
        int i = itr.next();
        int pos = position[i];
        if (i==pos) continue; // correctly positioned, do nothing
        int[] resolvent = trace[i];
        System.arraycopy(trace, i+1, trace, i, pos-i);
View Full Code Here


    hits.indices().retainAll(relevantVars);
   
    if (hits.get(hits.indices().min())==null) { // first call, initialize the hits
      for(IntIterator varItr = relevantVars.iterator(); varItr.hasNext(); ) {
        final int var = varItr.next();
        final IntSet varReachable = new IntBitSet(var+1);
        varReachable.add(var);
        hits.put(var, varReachable);
      }
      for(Iterator<Clause> clauseItr = trace.reverseIterator(trace.axioms()); clauseItr.hasNext();) {
        final Clause clause = clauseItr.next();
        final int maxVar = clause.maxVariable();
View Full Code Here

   
    // trim the trace so that it contains all axioms but only those resolvents that are reachable from the conflict
    this.trace = compress(trace, axioms, reachable, core);
   
    // we haven't computed any resolvent literals yet ...
    this.resolved = new IntBitSet(this.trace.length-axioms);
  }
View Full Code Here

   
    // trim the trace so that it contains all axioms but only those resolvents that are reachable from the conflict
    this.trace = compress(partial, axioms, reachable, core);
   
    // we haven't computed any resolvent literals yet ...
    this.resolved = new IntBitSet(this.trace.length-axioms);
  }
View Full Code Here

   * @return indices of all clauses in the given trace that are
   * reachable from the conflict clause through the resolvents in
   * trace[roots..trace.length-1]
   */
  private static IntSet reachable(int[][] trace, int roots) {
    final IntSet reachable = new IntBitSet(trace.length);
    reachable.add(trace.length-1);
    for(int i = trace.length-1; i >= roots; i--) {
      if (reachable.contains(i)) {
        int[] resolvent = trace[i];
        for(int j = 0; j < resolvent.length; j++) {
          reachable.add(resolvent[j]);
        }
      }
    }
    return reachable;
  }
View Full Code Here

   * reachable between 0, inclusive, and axioms, exclusive.
   * @return a set that contains the elements from the given
   * reachable between 0, inclusive, and axioms, exclusive.
   */
  private static IntSet core(IntSet reachable, int axioms) {
    final IntSet core = new IntBitSet(axioms);
    for(IntIterator itr = reachable.iterator(0, axioms-1); itr.hasNext(); ) {
      core.add(itr.next());
    }
    return Ints.unmodifiableIntSet(core);
  }
View Full Code Here

   * @see kodkod.engine.satlab.ResolutionTrace#implicants(kodkod.util.ints.IntSet)
   */
  public IntSet reachable(IntSet indices) {
    if (indices.isEmpty()) return Ints.EMPTY_SET;
    else if (valid(indices)) {
      final IntSet ret = new IntBitSet(trace.length);
      ret.addAll(indices);
      for(int i = indices.max(); i >= axioms; i--) {
        if (ret.contains(i)) {
          int[] resolvent = trace[i];
          if (resolved(i)) {
            for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
              ret.add(resolvent[j]);
            }
          } else {
            for(int j = 0; j < resolvent.length; j++) {
              ret.add(resolvent[j]);
            }
          }
        }
      }
      return ret;
View Full Code Here

   * @see kodkod.engine.satlab.ResolutionTrace#backwardReachable(kodkod.util.ints.IntSet)
   */
  public IntSet backwardReachable(IntSet indices) {
    if (indices.isEmpty()) return Ints.EMPTY_SET;
    else if (valid(indices)) {
      final IntSet ret = new IntBitSet(trace.length);
      ret.addAll(indices);
      for(int i = axioms, length = trace.length; i < length; i++) {
        int[] resolvent = trace[i];
        if (resolved(i)) {
          for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
            if (ret.contains(resolvent[j])) {
              ret.add(i);
              break;
            }
          }
        } else {
          for(int j = 0; j < resolvent.length; j++) {
            if (ret.contains(resolvent[j])) {
              ret.add(i);
              break;
            }
          }
        }
      }
View Full Code Here

   * @see kodkod.engine.satlab.ResolutionTrace#learnable(kodkod.util.ints.IntSet)
   */
  public IntSet learnable(IntSet indices) {
    if (indices.isEmpty()) return Ints.EMPTY_SET;
    else if (valid(indices)) {
      final IntSet ret = new IntBitSet(trace.length);
      ret.addAll(indices);
      TOP: for(int i = axioms, length = trace.length; i < length; i++) {
        int[] resolvent = trace[i];
        if (resolved(i)) {
          for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
            if (!ret.contains(resolvent[j])) {
              continue TOP;
            }
          }
        } else {
          for(int j = 0; j < resolvent.length; j++) {
            if (!ret.contains(resolvent[j])) {
              continue TOP;
            }
          }
        }
        ret.add(i);
      }
      return ret;
    }
    else throw new IndexOutOfBoundsException("invalid indices: " + indices);
  }
View Full Code Here

   * @see kodkod.engine.satlab.ResolutionTrace#directlyLearnable(kodkod.util.ints.IntSet)
   */
  public IntSet directlyLearnable(IntSet indices) {
    if (indices.isEmpty()) return Ints.EMPTY_SET;
    else if (valid(indices)) {
      final IntSet ret = new IntBitSet(trace.length);
      ret.addAll(indices);
      TOP: for(int i = axioms, length = trace.length; i < length; i++) {
        int[] resolvent = trace[i];
        if (resolved(i)) {
          for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
            if (!indices.contains(resolvent[j])) {
              continue TOP;
            }
          }
        } else {
          for(int j = 0; j < resolvent.length; j++) {
            if (!indices.contains(resolvent[j])) {
              continue TOP;
            }
          }
        }
        ret.add(i);
      }
      return ret;
    }
   
    else throw new IndexOutOfBoundsException("invalid indices: " + indices);
View Full Code Here

TOP

Related Classes of kodkod.util.ints.IntBitSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.