Package kodkod.util.ints

Examples of kodkod.util.ints.IntBitSet$AscendingIterator


   * properties specified by the {@linkplain ArrayTrace#ArrayResolution(int[][], int)}
   * constructor.
   * @return the indices of the core clauses in the given trace
   */
  private static IntSet core(int[][] trace, int axioms) {
    final IntSet core = new IntBitSet(axioms);
    final IntSet reachable = new IntBitSet(trace.length);
    reachable.add(trace.length-1);
    for(int i = trace.length-1; i >= axioms; i--) {
      if (reachable.contains(i)) {
        int[] resolvent = trace[i];
        for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
          reachable.add(resolvent[j]);
        }
      }
    }
   
    for(IntIterator itr = reachable.iterator(0, axioms-1); itr.hasNext(); ) {
      core.add(itr.next());
    }
   
    return 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];
          for(int j = 1, antes = resolvent[0]; j <= antes; 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];
        for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
          if (ret.contains(resolvent[j])) {
            ret.add(i);
            break;
          }
        }
      }
      return ret;
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];
        for(int j = 1, antes = resolvent[0]; j <= antes; 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];
        for(int j = 1, antes = resolvent[0]; j <= antes; j++) {
          if (!indices.contains(resolvent[j])) {
            continue TOP;
          }
        }
        ret.add(i);
      }
      return ret;
    }
   
    else throw new IndexOutOfBoundsException("invalid indices: " + indices);
View Full Code Here

   * given trace that have the specified maximum variable.
   * @return { i: trace.core() | trace[i].maxVariable() = maxVariable }
   */
  private static IntSet coreClausesWithMaxVar(ResolutionTrace trace, int maxVariable) {
    final IntSet core = trace.core();
    final IntSet restricted = new IntBitSet(core.max()+1);
    final Iterator<Clause> clauses = trace.iterator(core);
    final IntIterator indices = core.iterator();
    while(clauses.hasNext()) {
      Clause clause = clauses.next();
      int index = indices.next();
      if (clause.maxVariable()==maxVariable)
        restricted.add(index);
    }
    return restricted;
  }
View Full Code Here

    }
   
    posVars.retainAll(negVars);
   
    assert !posVars.isEmpty();
    final IntSet ret = new IntBitSet(posVars.max()+1);
    ret.addAll(posVars);
   
    return ret;
  }
View Full Code Here

   */
  static IntSet clausesFor(ResolutionTrace trace, IntSet relevantVars) {
//    System.out.println("relevant: " + relevantVars);
    final IntSet axioms = trace.axioms();

    final IntSet reachableVars = new IntBitSet(relevantVars.max()+1);
    reachableVars.addAll(relevantVars);

    final IntSet relevantAxioms = new IntBitSet(axioms.size());
   
    final Iterator<Clause> itr = trace.reverseIterator(axioms);
    for(int i = axioms.max(); i >= 0; i--) {
      Clause clause = itr.next();
      int maxVar = clause.maxVariable();
      if (reachableVars.contains(maxVar)) {
        for(IntIterator lits = clause.literals(); lits.hasNext(); ) {
          reachableVars.add(StrictMath.abs(lits.next()));
        }
        relevantAxioms.add(i);
      }
    }
   
    return  relevantAxioms;
  }
View Full Code Here

TOP

Related Classes of kodkod.util.ints.IntBitSet$AscendingIterator

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.