Java Code Examples for kodkod.ast.Relation#isAtom()

The following examples show how to use kodkod.ast.Relation#isAtom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SymmetryDetector.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an array that contains unique non-empty tuplesets in the given
 * bounds, sorted in the order of increasing size.
 *
 * @return unique non-empty tuplesets in the given bounds, sorted in the order
 *         of increasing size.
 */
private TupleSet[] sort(Bounds bounds) {
    final List<TupleSet> sets = new ArrayList<TupleSet>(bounds.relations().size());
    for (Relation r : bounds.relations()) {
        if (r.isAtom() && ignoreAllAtomRelsExcept != null && !ignoreAllAtomRelsExcept.contains(r))
            continue;
        if (ignoreRels != null && ignoreRels.contains(r))
            continue;
        final TupleSet lower = bounds.lowerBound(r);
        final TupleSet upper = bounds.upperBound(r);
        if (!lower.isEmpty() && lower.size() < upper.size()) {
            sets.add(lower);
        }
        if (!upper.isEmpty()) {
            sets.add(upper);
        }
    }
    final TupleSet[] sorted = sets.toArray(new TupleSet[sets.size()]);
    Arrays.sort(sorted, new Comparator<TupleSet>() {

        @Override
        public int compare(TupleSet o1, TupleSet o2) {
            return o1.size() - o2.size();
        }
    });
    return sorted;
}
 
Example 2
Source File: AnnotatedNode.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
public final Set<Relation> atomRelations() {
    final Set<Relation> ans = new IdentityHashSet<Relation>();
    for (Relation r : relations())
        if (r.isAtom())
            ans.add(r);
    return ans;
}
 
Example 3
Source File: Bounds.java    From org.alloytools.alloy with Apache License 2.0 4 votes vote down vote up
private void putBound(Map<Relation,TupleSet> map, Relation r, TupleSet tset) {
    map.put(r, tset);
    if (r.isAtom() && System.identityHashCode(map) == System.identityHashCode(uppers))
        addAtomRel(r, tset);
}