@Test public static void testMergeZone2(){ ZoneType z = zone3.mergeZones(zone4); System.out.println("Merging zones 3 and 4 :"); System.out.println(z); }
public ZoneType mergeZones(Zone otherZone) { Zone mergedZone = new Zone(); ZoneTriple[] zoneAndIndex = mergeTimers(otherZone); mergedZone._indexToTimer = new int[zoneAndIndex.length]; for(int i=0; i<zoneAndIndex.length; i++) { mergedZone._indexToTimer[i] = zoneAndIndex[i]._timer; } mergedZone._matrix = new int[mergedZone.matrixSize()][mergedZone.matrixSize()]; for(int i=0; i<mergedZone.dbmSize(); i++) { for(int j=0; j<mergedZone.dbmSize(); j++) { if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[j]._zone2 != null) { int value1 = this.getDbmEntry(zoneAndIndex[i]._index1, zoneAndIndex[j]._index1); int value2 = otherZone.getDbmEntry(zoneAndIndex[i]._index2, zoneAndIndex[j]._index2); if(value1 != value2) { throw new IncompatibleZoneException("The common timers do not agree."); } mergedZone.setDbmEntry(i, j, value1); } else { int iIndex = 0; int jIndex = 0; ZoneType z; if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone1) { z = zoneAndIndex[i]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone2) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index2; } else if(zoneAndIndex[j]._zone2 != null && zoneAndIndex[j]._zone1 == zoneAndIndex[i]._zone1) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index2; jIndex = zoneAndIndex[j]._index1; } mergedZone.setDbmEntry(iIndex, j, z.getDbmEntry(iIndex, jIndex)); } } } return mergedZone; }
Zone extends ZoneType { public ZoneType mergeZones(Zone otherZone) { Zone mergedZone = new Zone(); ZoneTriple[] zoneAndIndex = mergeTimers(otherZone); mergedZone._indexToTimer = new int[zoneAndIndex.length]; for(int i=0; i<zoneAndIndex.length; i++) { mergedZone._indexToTimer[i] = zoneAndIndex[i]._timer; } mergedZone._matrix = new int[mergedZone.matrixSize()][mergedZone.matrixSize()]; for(int i=0; i<mergedZone.dbmSize(); i++) { for(int j=0; j<mergedZone.dbmSize(); j++) { if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[j]._zone2 != null) { int value1 = this.getDbmEntry(zoneAndIndex[i]._index1, zoneAndIndex[j]._index1); int value2 = otherZone.getDbmEntry(zoneAndIndex[i]._index2, zoneAndIndex[j]._index2); if(value1 != value2) { throw new IncompatibleZoneException("The common timers do not agree."); } mergedZone.setDbmEntry(i, j, value1); } else { int iIndex = 0; int jIndex = 0; ZoneType z; if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone1) { z = zoneAndIndex[i]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone2) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index2; } else if(zoneAndIndex[j]._zone2 != null && zoneAndIndex[j]._zone1 == zoneAndIndex[i]._zone1) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index2; jIndex = zoneAndIndex[j]._index1; } mergedZone.setDbmEntry(iIndex, j, z.getDbmEntry(iIndex, jIndex)); } } } return mergedZone; } }
Zone extends ZoneType { public ZoneType mergeZones(Zone otherZone) { Zone mergedZone = new Zone(); ZoneTriple[] zoneAndIndex = mergeTimers(otherZone); mergedZone._indexToTimer = new int[zoneAndIndex.length]; for(int i=0; i<zoneAndIndex.length; i++) { mergedZone._indexToTimer[i] = zoneAndIndex[i]._timer; } mergedZone._matrix = new int[mergedZone.matrixSize()][mergedZone.matrixSize()]; for(int i=0; i<mergedZone.dbmSize(); i++) { for(int j=0; j<mergedZone.dbmSize(); j++) { if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[j]._zone2 != null) { int value1 = this.getDbmEntry(zoneAndIndex[i]._index1, zoneAndIndex[j]._index1); int value2 = otherZone.getDbmEntry(zoneAndIndex[i]._index2, zoneAndIndex[j]._index2); if(value1 != value2) { throw new IncompatibleZoneException("The common timers do not agree."); } mergedZone.setDbmEntry(i, j, value1); } else { int iIndex = 0; int jIndex = 0; ZoneType z; if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone1) { z = zoneAndIndex[i]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone2) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index2; } else if(zoneAndIndex[j]._zone2 != null && zoneAndIndex[j]._zone1 == zoneAndIndex[i]._zone1) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index2; jIndex = zoneAndIndex[j]._index1; } mergedZone.setDbmEntry(iIndex, j, z.getDbmEntry(iIndex, jIndex)); } } } return mergedZone; } Zone(int[] timers, int[][] matrix);  Zone(State initialState); private  Zone(); }
Zone extends ZoneType { public ZoneType mergeZones(Zone otherZone) { Zone mergedZone = new Zone(); ZoneTriple[] zoneAndIndex = mergeTimers(otherZone); mergedZone._indexToTimer = new int[zoneAndIndex.length]; for(int i=0; i<zoneAndIndex.length; i++) { mergedZone._indexToTimer[i] = zoneAndIndex[i]._timer; } mergedZone._matrix = new int[mergedZone.matrixSize()][mergedZone.matrixSize()]; for(int i=0; i<mergedZone.dbmSize(); i++) { for(int j=0; j<mergedZone.dbmSize(); j++) { if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[j]._zone2 != null) { int value1 = this.getDbmEntry(zoneAndIndex[i]._index1, zoneAndIndex[j]._index1); int value2 = otherZone.getDbmEntry(zoneAndIndex[i]._index2, zoneAndIndex[j]._index2); if(value1 != value2) { throw new IncompatibleZoneException("The common timers do not agree."); } mergedZone.setDbmEntry(i, j, value1); } else { int iIndex = 0; int jIndex = 0; ZoneType z; if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone1) { z = zoneAndIndex[i]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone2) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index2; } else if(zoneAndIndex[j]._zone2 != null && zoneAndIndex[j]._zone1 == zoneAndIndex[i]._zone1) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index2; jIndex = zoneAndIndex[j]._index1; } mergedZone.setDbmEntry(iIndex, j, z.getDbmEntry(iIndex, jIndex)); } } } return mergedZone; } Zone(int[] timers, int[][] matrix);  Zone(State initialState); private  Zone(); @Override int getUpperBoundbyTransitionIndex(int timer); @Override int getUpperBoundbydbmIndex(int index); void setUpperBoundbyTransitionIndex(int timer, int value); void setUpperBoundbydbmIndex(int index, int value); @Override int getLowerBoundbyTransitionIndex(int timer); @Override int getLowerBoundbydbmIndex(int index); void setLowerBoundbyTransitionIndex(int timer, int value); void setLowerBoundbydbmIndex(int index, int value); @Override int getDbmEntry(int i, int j); @Override String toString(); @Override boolean equals(Object o); boolean equals(Zone otherZone); @Override boolean subset(ZoneType otherZone); @Override int hashCode(); @Override boolean exceedsLowerBoundbyTransitionIndex(int timer); @Override boolean exceedsLowerBoundbydbmIndex(int index); @Override ZoneType fireTransitionbyTransitionIndex(int timer, int[] enabledTimers, 
			State state); @Override ZoneType fireTransitionbydbmIndex(int index, int[] enabledTimers,
			State state); ZoneType mergeZones(Zone otherZone); static ZoneType mergeZones(Zone firstZone, Zone secondZone); @Override Zone clone(); @Override List<Transition> getEnabledTransitions(); @Override HashMap<Integer, Transition> getLexicon(); static void setLexicon(HashMap<Integer, Transition> lexicon); int[] getIndexToTimer(); static void testZoneGraphMinimization(Zone z, boolean popUp); void toDot(PrintStream writer); static void clearLexicon(); }
Zone extends ZoneType { public ZoneType mergeZones(Zone otherZone) { Zone mergedZone = new Zone(); ZoneTriple[] zoneAndIndex = mergeTimers(otherZone); mergedZone._indexToTimer = new int[zoneAndIndex.length]; for(int i=0; i<zoneAndIndex.length; i++) { mergedZone._indexToTimer[i] = zoneAndIndex[i]._timer; } mergedZone._matrix = new int[mergedZone.matrixSize()][mergedZone.matrixSize()]; for(int i=0; i<mergedZone.dbmSize(); i++) { for(int j=0; j<mergedZone.dbmSize(); j++) { if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[j]._zone2 != null) { int value1 = this.getDbmEntry(zoneAndIndex[i]._index1, zoneAndIndex[j]._index1); int value2 = otherZone.getDbmEntry(zoneAndIndex[i]._index2, zoneAndIndex[j]._index2); if(value1 != value2) { throw new IncompatibleZoneException("The common timers do not agree."); } mergedZone.setDbmEntry(i, j, value1); } else { int iIndex = 0; int jIndex = 0; ZoneType z; if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone1) { z = zoneAndIndex[i]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else if(zoneAndIndex[i]._zone2 != null && zoneAndIndex[i]._zone1 == zoneAndIndex[j]._zone2) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index2; } else if(zoneAndIndex[j]._zone2 != null && zoneAndIndex[j]._zone1 == zoneAndIndex[i]._zone1) { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index1; jIndex = zoneAndIndex[j]._index1; } else { z = zoneAndIndex[j]._zone1; iIndex = zoneAndIndex[i]._index2; jIndex = zoneAndIndex[j]._index1; } mergedZone.setDbmEntry(iIndex, j, z.getDbmEntry(iIndex, jIndex)); } } } return mergedZone; } Zone(int[] timers, int[][] matrix);  Zone(State initialState); private  Zone(); @Override int getUpperBoundbyTransitionIndex(int timer); @Override int getUpperBoundbydbmIndex(int index); void setUpperBoundbyTransitionIndex(int timer, int value); void setUpperBoundbydbmIndex(int index, int value); @Override int getLowerBoundbyTransitionIndex(int timer); @Override int getLowerBoundbydbmIndex(int index); void setLowerBoundbyTransitionIndex(int timer, int value); void setLowerBoundbydbmIndex(int index, int value); @Override int getDbmEntry(int i, int j); @Override String toString(); @Override boolean equals(Object o); boolean equals(Zone otherZone); @Override boolean subset(ZoneType otherZone); @Override int hashCode(); @Override boolean exceedsLowerBoundbyTransitionIndex(int timer); @Override boolean exceedsLowerBoundbydbmIndex(int index); @Override ZoneType fireTransitionbyTransitionIndex(int timer, int[] enabledTimers, 
			State state); @Override ZoneType fireTransitionbydbmIndex(int index, int[] enabledTimers,
			State state); ZoneType mergeZones(Zone otherZone); static ZoneType mergeZones(Zone firstZone, Zone secondZone); @Override Zone clone(); @Override List<Transition> getEnabledTransitions(); @Override HashMap<Integer, Transition> getLexicon(); static void setLexicon(HashMap<Integer, Transition> lexicon); int[] getIndexToTimer(); static void testZoneGraphMinimization(Zone z, boolean popUp); void toDot(PrintStream writer); static void clearLexicon();  }