Changeset 547 for trunk/quest-core-coverage
- Timestamp:
- 08/16/12 12:34:24 (12 years ago)
- Location:
- trunk/quest-core-coverage/src/main/java/de/ugoe/cs/quest/coverage
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-coverage/src/main/java/de/ugoe/cs/quest/coverage/CoverageCalculatorObserved.java
r518 r547 26 26 * </p> 27 27 */ 28 private final Collection<List< ? extends Event<?>>> sequences;28 private final Collection<List<Event>> sequences; 29 29 30 30 /** … … 33 33 * </p> 34 34 */ 35 private final Collection<List< ? extends Event<?>>> observedSequences;35 private final Collection<List<Event>> observedSequences; 36 36 37 37 /** … … 48 48 * </p> 49 49 */ 50 private Collection<List< ? extends Event<?>>> subSeqsGenerated = null;50 private Collection<List<Event>> subSeqsGenerated = null; 51 51 52 52 /** … … 55 55 * </p> 56 56 */ 57 private Collection<List< ? extends Event<?>>> subSeqsObserved = null;57 private Collection<List<Event>> subSeqsObserved = null; 58 58 59 59 /** … … 77 77 */ 78 78 public CoverageCalculatorObserved( 79 Collection<List< ? extends Event<?>>> observedSequences,80 Collection<List< ? extends Event<?>>> sequences, int length) {79 Collection<List<Event>> observedSequences, 80 Collection<List<Event>> sequences, int length) { 81 81 if (observedSequences == null) { 82 82 throw new InvalidParameterException( … … 105 105 public double getCoverageObserved() { 106 106 createSubSeqs(); 107 Collection<List< ? extends Event<?>>> subSeqsObservedCopy = new LinkedHashSet<List<? extends Event<?>>>(107 Collection<List<Event>> subSeqsObservedCopy = new LinkedHashSet<List<Event>>( 108 108 subSeqsObserved); 109 109 subSeqsObservedCopy.retainAll(subSeqsGenerated); … … 125 125 public double getCoverageObservedWeigth(IStochasticProcess process) { 126 126 createSubSeqs(); 127 Map<List< ? extends Event<?>>, Double> weightMap = SequenceTools127 Map<List<Event>, Double> weightMap = SequenceTools 128 128 .generateWeights(process, subSeqsObserved); 129 129 130 Collection<List< ? extends Event<?>>> subSeqsObservedCopy = new LinkedHashSet<List<? extends Event<?>>>(130 Collection<List<Event>> subSeqsObservedCopy = new LinkedHashSet<List<Event>>( 131 131 subSeqsObserved); 132 132 subSeqsObservedCopy.retainAll(subSeqsGenerated); 133 133 double weight = 0.0d; 134 for (List< ? extends Event<?>> subSeq : subSeqsObservedCopy) {134 for (List<Event> subSeq : subSeqsObservedCopy) { 135 135 weight += weightMap.get(subSeq); 136 136 } … … 149 149 public double getNewPercentage() { 150 150 createSubSeqs(); 151 Collection<List< ? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(151 Collection<List<Event>> subSeqsGeneratedCopy = new LinkedHashSet<List<Event>>( 152 152 subSeqsGenerated); 153 153 subSeqsGeneratedCopy.removeAll(subSeqsObserved); … … 174 174 } 175 175 createSubSeqs(); 176 Collection<List< ? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(177 subSeqsGenerated); 178 Collection<List< ? extends Event<?>>> subSeqsPossible = process176 Collection<List<Event>> subSeqsGeneratedCopy = new LinkedHashSet<List<Event>>( 177 subSeqsGenerated); 178 Collection<List<Event>> subSeqsPossible = process 179 179 .generateSequences(length); 180 180 subSeqsGeneratedCopy.removeAll(subSeqsObserved); … … 204 204 } 205 205 createSubSeqs(); 206 Collection<List< ? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(207 subSeqsGenerated); 208 Collection<List< ? extends Event<?>>> subSeqsPossible = process206 Collection<List<Event>> subSeqsGeneratedCopy = new LinkedHashSet<List<Event>>( 207 subSeqsGenerated); 208 Collection<List<Event>> subSeqsPossible = process 209 209 .generateSequences(length); 210 210 subSeqsGeneratedCopy.removeAll(subSeqsObserved); 211 211 subSeqsPossible.removeAll(subSeqsObserved); 212 Map<List< ? extends Event<?>>, Double> weightMap = SequenceTools212 Map<List<Event>, Double> weightMap = SequenceTools 213 213 .generateWeights(process, subSeqsPossible); 214 214 double weight = 0.0d; 215 for (List< ? extends Event<?>> subSeq : subSeqsGeneratedCopy) {215 for (List<Event> subSeq : subSeqsGeneratedCopy) { 216 216 Double currentWeight = weightMap.get(subSeq); 217 217 if( currentWeight!=null ) { … … 248 248 public int getNumNew() { 249 249 createSubSeqs(); 250 Collection<List< ? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(250 Collection<List<Event>> subSeqsGeneratedCopy = new LinkedHashSet<List<Event>>( 251 251 subSeqsGenerated); 252 252 subSeqsGeneratedCopy.removeAll(subSeqsObserved); -
trunk/quest-core-coverage/src/main/java/de/ugoe/cs/quest/coverage/CoverageCalculatorProcess.java
r518 r547 33 33 * </p> 34 34 */ 35 private Collection<List< ? extends Event<?>>> sequences;35 private Collection<List<Event>> sequences; 36 36 37 37 /** … … 48 48 * </p> 49 49 */ 50 private Collection<List< ? extends Event<?>>> containedSubSeqs = null;50 private Collection<List<Event>> containedSubSeqs = null; 51 51 52 52 /** … … 56 56 * </p> 57 57 */ 58 private Collection<List< ? extends Event<?>>> allPossibleSubSeqs = null;58 private Collection<List<Event>> allPossibleSubSeqs = null; 59 59 60 60 /** … … 64 64 * </p> 65 65 */ 66 private Map<List< ? extends Event<?>>, Double> subSeqWeights = null;66 private Map<List<Event>, Double> subSeqWeights = null; 67 67 68 68 /** … … 85 85 */ 86 86 public CoverageCalculatorProcess(IStochasticProcess process, 87 Collection<List< ? extends Event<?>>> sequences, int length) {87 Collection<List<Event>> sequences, int length) { 88 88 if (process == null) { 89 89 throw new InvalidParameterException("process must not be null"); … … 159 159 } 160 160 double weight = 0.0; 161 for (List< ? extends Event<?>> subSeq : containedSubSeqs) {161 for (List<Event> subSeq : containedSubSeqs) { 162 162 Double curWeight = subSeqWeights.get(subSeq); 163 163 if( curWeight!=null ) { … … 208 208 * thrown is newSequences is null 209 209 */ 210 public void setSequences(Collection<List< ? extends Event<?>>> newSequences) {210 public void setSequences(Collection<List<Event>> newSequences) { 211 211 if (newSequences == null) { 212 212 throw new InvalidParameterException("sequences must not be null"); -
trunk/quest-core-coverage/src/main/java/de/ugoe/cs/quest/coverage/SequenceTools.java
r518 r547 46 46 * @return {@link Map} of weights 47 47 */ 48 public static Map<List< ? extends Event<?>>, Double> generateWeights(48 public static Map<List<Event>, Double> generateWeights( 49 49 IStochasticProcess process, 50 Collection<List< ? extends Event<?>>> sequences) {51 Map<List< ? extends Event<?>>, Double> subSeqWeights = new LinkedHashMap<List<? extends Event<?>>, Double>();50 Collection<List<Event>> sequences) { 51 Map<List<Event>, Double> subSeqWeights = new LinkedHashMap<List<Event>, Double>(); 52 52 if (sequences != null && !sequences.isEmpty()) { 53 53 if (process != null) { 54 54 double sum = 0.0; 55 for (List< ? extends Event<?>> sequence : sequences) {55 for (List<Event> sequence : sequences) { 56 56 double prob = process.getProbability(sequence); 57 57 subSeqWeights.put(sequence, prob); … … 59 59 } 60 60 if (sum < 1.0) { 61 for (Map.Entry<List< ? extends Event<?>>, Double> entry : subSeqWeights61 for (Map.Entry<List<Event>, Double> entry : subSeqWeights 62 62 .entrySet()) { 63 63 entry.setValue(entry.getValue() / sum); … … 65 65 } 66 66 } else { 67 for( List< ? extends Event<?>> sequence : sequences ) {67 for( List<Event> sequence : sequences ) { 68 68 subSeqWeights.put(sequence, 0.0d); 69 69 } … … 114 114 * thrown if length less or equal to 0 115 115 */ 116 public static Set<List< ? extends Event<?>>> containedSubSequences(117 Collection<List< ? extends Event<?>>> sequences, int length) {116 public static Set<List<Event>> containedSubSequences( 117 Collection<List<Event>> sequences, int length) { 118 118 if (length <= 0) { 119 119 throw new InvalidParameterException( 120 120 "length must be a positive integer"); 121 121 } 122 Set<List< ? extends Event<?>>> containedSubSeqs = new LinkedHashSet<List<? extends Event<?>>>();122 Set<List<Event>> containedSubSeqs = new LinkedHashSet<List<Event>>(); 123 123 if (sequences != null) { 124 for (List< ? extends Event<?>> sequence : sequences) {125 List<Event <?>> subSeq = new LinkedList<Event<?>>();124 for (List<Event> sequence : sequences) { 125 List<Event> subSeq = new LinkedList<Event>(); 126 126 boolean minLengthReached = false; 127 for (Event <?>event : sequence) {127 for (Event event : sequence) { 128 128 subSeq.add(event); 129 129 if (!minLengthReached) { … … 136 136 if (minLengthReached) { 137 137 if (!containedSubSeqs.contains(subSeq)) { 138 containedSubSeqs.add(new LinkedList<Event <?>>(138 containedSubSeqs.add(new LinkedList<Event>( 139 139 subSeq)); 140 140 }
Note: See TracChangeset
for help on using the changeset viewer.