return possibleReachabilities.iterator();
}
-
+
public int size() {
return possibleReachabilities.size();
}
+ public boolean isEmpty() {
+ return possibleReachabilities.isEmpty();
+ }
public boolean contains(TokenTupleSet tts) {
assert tts != null;
return false;
}
- public ReachabilitySet increaseArity(Integer token) {
- assert token != null;
-
- HashSet<TokenTupleSet> possibleReachabilitiesNew = new HashSet<TokenTupleSet>();
-
- Iterator itr = iterator();
- while( itr.hasNext() ) {
- TokenTupleSet tts = (TokenTupleSet) itr.next();
- possibleReachabilitiesNew.add(tts.increaseArity(token) );
- }
-
- return new ReachabilitySet(possibleReachabilitiesNew).makeCanonical();
- }
-
-
public ReachabilitySet union(ReachabilitySet rsIn) {
assert rsIn != null;
while( itrR.hasNext() ) {
TokenTupleSet r = (TokenTupleSet) itrR.next();
- TokenTupleSet theUnion = new TokenTupleSet();
+ TokenTupleSet theUnion = new TokenTupleSet().makeCanonical();
Iterator itrRelement = r.iterator();
while( itrRelement.hasNext() ) {
- TokenTuple e = (TokenTuple) itrRelement.next();
+ TokenTuple ttR = (TokenTuple) itrRelement.next();
+ TokenTuple ttO = o.containsToken(ttR.getToken() );
- if( o.containsToken(e.getToken() ) ) {
- theUnion = theUnion.union(new TokenTupleSet(e.increaseArity() ) ).makeCanonical();
+ if( ttO != null ) {
+ theUnion = theUnion.union(new TokenTupleSet(ttR.unionArity(ttO) ) ).makeCanonical();
} else {
- theUnion = theUnion.union(new TokenTupleSet(e) ).makeCanonical();
+ theUnion = theUnion.union(new TokenTupleSet(ttR) ).makeCanonical();
}
}
Iterator itrOelement = o.iterator();
while( itrOelement.hasNext() ) {
- TokenTuple e = (TokenTuple) itrOelement.next();
+ TokenTuple ttO = (TokenTuple) itrOelement.next();
+ TokenTuple ttR = theUnion.containsToken(ttO.getToken() );
- if( !theUnion.containsToken(e.getToken() ) ) {
- theUnion = theUnion.union(new TokenTupleSet(e) ).makeCanonical();
+ if( ttR == null ) {
+ theUnion = theUnion.union(new TokenTupleSet(ttO) ).makeCanonical();
}
}
if( !theUnion.isEmpty() ) {
- ctsOut = ctsOut.union(
- new ChangeTupleSet(new ChangeTuple(o, theUnion) )
- );
+ ctsOut = ctsOut.union(new ChangeTupleSet(new ChangeTuple(o, theUnion) ) );
}
}
}
int numDimensions = this.possibleReachabilities.size();
- if( numDimensions > 10 ) {
- System.out.println( " exhaustiveArityCombinations numDimensions = "+numDimensions );
- System.out.println( this );
+ if( numDimensions > 1 ) {
+ // for problems that are too big, punt and use less
+ // precise arity for reachability information
+ TokenTupleSet ttsImprecise = new TokenTupleSet().makeCanonical();
+
+ Iterator<TokenTupleSet> itrThis = this.iterator();
+ while( itrThis.hasNext() ) {
+ TokenTupleSet ttsUnit = itrThis.next();
+ ttsImprecise = ttsImprecise.unionUpArity(ttsUnit.makeArityZeroOrMore() );
+ }
+
+ //rsOut = this.union( ttsImprecise );
+ rsOut = rsOut.union(ttsImprecise);
+ return rsOut;
}
// add an extra digit to detect termination
while( digits[numDimensions] == minArity ) {
// spit out a "coordinate" made from these digits
- TokenTupleSet ttsCoordinate = new TokenTupleSet();
+ TokenTupleSet ttsCoordinate = new TokenTupleSet().makeCanonical();
Iterator<TokenTupleSet> ttsItr = this.iterator();
for( int i = 0; i < numDimensions; ++i ) {
assert ttsItr.hasNext();
for( int i = 0; i < numDimensions+1; ++i ) {
digits[i]++;
-
- if( i == 11 ) {
- System.out.print( "x" );
- }
-
- if( i == 15 ) {
- System.out.print( "@" );
- }
-
- if( i == 17 ) {
- System.out.print( "#" );
- }
-
if( digits[i] > maxArity ) {
// this axis reached its max, so roll it back to min and increment next higher digit
digits[i] = minArity;
}
}
- if( numDimensions > 10 ) {
- System.out.println( "" );
- }
-
return rsOut.makeCanonical();
}
return possibleReachabilities.equals(rs.possibleReachabilities);
}
+
+ private boolean oldHashSet = false;
+ private int oldHash = 0;
public int hashCode() {
- return possibleReachabilities.hashCode();
+ int currentHash = possibleReachabilities.hashCode();
+
+ if( oldHashSet == false ) {
+ oldHash = currentHash;
+ oldHashSet = true;
+ } else {
+ if( oldHash != currentHash ) {
+ System.out.println("IF YOU SEE THIS A CANONICAL ReachabilitySet CHANGED");
+ Integer x = null;
+ x.toString();
+ }
+ }
+
+ return currentHash;
}