Package kodkod.util.ints

Examples of kodkod.util.ints.IntSet


   * @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

   * {@inheritDoc}
   * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace)
   */
  public IntSet next(ResolutionTrace trace) {
    if (topVars.isEmpty()) return Ints.EMPTY_SET; // tried everything
    final IntSet core = trace.core();
   
    for(Iterator<Clause> iter = trace.iterator(core); iter.hasNext();) {
      Clause clause = iter.next();
      int maxVar = clause.maxVariable();
      if (topVars.remove(maxVar)) {
        // get all core clauses with the given maximum variable
        IntSet exclude = coreClausesWithMaxVar(trace, maxVar);
        assert !exclude.isEmpty();
        //  get all clauses reachable from the conflict clause
        IntSet next = trace.reachable(Ints.singleton(trace.size()-1));
        // remove all clauses backward reachable from the clauses with the given maxVar
        next.removeAll(trace.backwardReachable(exclude));
        if (!next.isEmpty()) {
          return next;
        }
      }
    }
   
View Full Code Here

   * Returns the indices of the clauses in the unsatisfiable core of the
   * 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

   * @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

   * @requires {@inheritDoc}
   * @effects {@inheritDoc}
   * @return  last(this.nexts')
   */
  public final IntSet next(final ResolutionTrace trace) {
    final IntSet core = trace.core();
    if (excluded==null) { // the first time this method is called
      excluded = new HashSet<Clause>((int)(StrictMath.round(core.size()*.75)));
    }
   
    for(IntIterator iter = core.iterator(Integer.MAX_VALUE, Integer.MIN_VALUE); iter.hasNext();) {
      int index = iter.next();
      if (excluded.add(trace.get(index))) { // haven't tried excluding this one
        // get all clauses reachable from the conflict clause
        IntSet next = trace.reachable(Ints.singleton(trace.size()-1));
        // remove all clauses backward reachable from the excluded clause
        next.removeAll(trace.backwardReachable(Ints.singleton(index)));
        return next;
      }
    }
   
    return Ints.EMPTY_SET;
View Full Code Here

    final TupleFactory f = bounds.universe().factory();
    final Instance instance = new Instance(bounds.universe());
//    System.out.println(varUsage);
    for(Relation r : bounds.relations()) {
      TupleSet lower = bounds.lowerBound(r);
      IntSet indeces = Ints.bestSet(lower.capacity());
      indeces.addAll(lower.indexView());
      IntSet vars = primaryVarUsage.get(r);
      if (vars!=null) {
        int lit = vars.min();
        for(IntIterator iter = bounds.upperBound(r).indexView().iterator(); iter.hasNext();) {
          final int index = iter.next();
          if (!indeces.contains(index) && solver.valueOf(lit++))
            indeces.add(index);
        }
View Full Code Here

   */
  LazyTrace(int[][] trace, int axioms) {
    this.axioms = axioms;
   
    // find all the clauses that are reachable from the conflict
    final IntSet reachable = reachable(trace, axioms);
   
    // get the core clauses
    this.core = core(reachable, axioms);
   
    // trim the trace so that it contains all axioms but only those resolvents that are reachable from the conflict
View Full Code Here

   */
  LazyTrace(LazyTrace original, IntSet indices, int[][] partial) {
    this.axioms = reconstruct(original, indices, partial);
   
    // find all the clauses that are reachable from the conflict
    final IntSet reachable = reachable(partial, axioms);
   
    // get the core clauses
    this.core = core(reachable, axioms);
   
    // trim the trace so that it contains all axioms but only those resolvents that are reachable from the conflict
View Full Code Here

TOP

Related Classes of kodkod.util.ints.IntSet

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.