Package kodkod.util.ints

Examples of kodkod.util.ints.IntTreeSet


          return roots.contains(translated) && coreUnits.contains(Math.abs(literal));
        }
       
      };
      coreRoots = new LinkedHashMap<Formula, Node>();
      final IntSet seenUnits = new IntTreeSet();
      for(Iterator<TranslationRecord> itr = log().replay(unitFilter); itr.hasNext(); ) {
        // it is possible that two top-level formulas have identical meaning,
        // and are represented with the same core unit; in that case, we want only
        // one of them in the core.
        final TranslationRecord rec = itr.next();
        if (seenUnits.add(rec.literal())) {
          coreRoots.put(rec.translated(), rec.node());
       
      }
      coreRoots = Collections.unmodifiableMap(coreRoots);
    }
View Full Code Here


   *   v = abs(r.literal) and
   *   no r': log.records | r'.node = r.node && log.replay.r' > log.replay.r }
   * </pre>
   */
  public static IntSet rootVars(TranslationLog log) {
    final IntSet rootVars = new IntTreeSet();
    final Set<Formula> roots = log.roots();
    final Map<Formula,int[]> maxRootVar = new LinkedHashMap<Formula,int[]>(roots.size());
    final RecordFilter filter = new RecordFilter() {
      public boolean accept(Node node, Formula translated, int literal, Map<Variable, TupleSet> env) {
        return roots.contains(translated) && env.isEmpty();
      }
    };
    for(Iterator<TranslationRecord> itr = log.replay(filter); itr.hasNext();) {
      TranslationRecord record = itr.next();
      int[] var = maxRootVar.get(record.translated());
      if (var==null) {
        var = new int[1];
        maxRootVar.put(record.translated(), var);
      }
      var[0] = StrictMath.abs(record.literal());
    }
   
    for(int[] var : maxRootVar.values()) {
      int topVar = var[0];
      if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE
        rootVars.add(var[0]);
    }
   
//    for(Map.Entry<Formula,int[]> entry : maxRootVar.entrySet()) {
//      final int topVar = entry.getValue()[0];
//      if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE
View Full Code Here

   * negative phase in trace.core.
   * @return { v: [1..) | (some p, n: trace.core | v in trace.elts[p].literals and -v in trace.elts[n].literals) }
   */
  public static IntSet coreVars(ResolutionTrace trace) {

    final IntSet posVars = new IntTreeSet(), negVars = new IntTreeSet();
   
    for(Iterator<Clause> iter = trace.iterator(trace.core()); iter.hasNext();) {
      Clause clause = iter.next();
      for(IntIterator lits = clause.literals(); lits.hasNext(); ) {
        int lit = lits.next();
        if (lit > 0) posVars.add(lit);
        else negVars.add(-lit);
      }
    }
   
    posVars.retainAll(negVars);
   
View Full Code Here

   * Returns the set of all variables in the core of the given trace
   * that form unit clauses.
   * @return { v: [1..) | some c: trace.core | c.size() = 1 and c.maxVariable() = v }
   */
  public static IntSet coreUnits(ResolutionTrace trace) {
    final IntSet units = new IntTreeSet();
   
    for(Iterator<Clause> itr = trace.reverseIterator(trace.core()); itr.hasNext(); ) {  
      Clause c = itr.next();
      if (c.size()==1) {
        units.add(c.maxVariable());
      }
    }
   
    if (units.isEmpty()) return Ints.EMPTY_SET;
   
    return Ints.asSet(units.toArray());
  }
View Full Code Here

   * that form unit clauses. 
   * @return the consecutive variables at the tail of the core of the given trace
   * that form unit clauses
   */
  static IntSet coreTailUnits(ResolutionTrace trace) {
    final IntSet units = new IntTreeSet();
   
    for(Iterator<Clause> itr = trace.reverseIterator(trace.core()); itr.hasNext(); ) {  
      Clause c = itr.next();
      if (c.size()==1) {
        units.add(c.maxVariable());
      } else {
        break;
      }
    }
   
View Full Code Here

   * log to relate the cnf clauses back to the logic constraints from
   * which they were generated.
   */
  public NCEStrategy(final TranslationLog log) {
    varsToTry = StrategyUtils.rootVars(log);
    coreVars = new IntTreeSet();//new IntTreeSet(varsToTry);
    coreVars.addAll(varsToTry);
  }
View Full Code Here

TOP

Related Classes of kodkod.util.ints.IntTreeSet

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.