Changeset 102 for trunk/EventBenchCore/src/de/ugoe
- Timestamp:
- 07/04/11 15:57:06 (13 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculator.java
r93 r102 1 1 package de.ugoe.cs.eventbench.coverage; 2 2 3 import java.util.Collection; 3 4 import java.util.LinkedHashMap; 4 5 import java.util.LinkedHashSet; … … 14 15 15 16 private final IStochasticProcess process; 16 private final List<List<? extends Event<?>>> sequences;17 private final Collection<List<? extends Event<?>>> sequences; 17 18 private final int length; 18 19 19 private Set<List<? extends Event<?>>> containedSubSeqs = null;20 private Set<List<? extends Event<?>>> allPossibleSubSeqs = null;20 private Collection<List<? extends Event<?>>> containedSubSeqs = null; 21 private Collection<List<? extends Event<?>>> allPossibleSubSeqs = null; 21 22 private Map<List<? extends Event<?>>, Double> subSeqWeights = null; 22 23 23 24 24 public CoverageCalculator(IStochasticProcess process, List<List<? extends Event<?>>> sequences, int length) {25 public CoverageCalculator(IStochasticProcess process, Collection<List<? extends Event<?>>> sequences, int length) { 25 26 this.process = process; 26 27 this.sequences = sequences; … … 63 64 } 64 65 65 private Map<List<? extends Event<?>>, Double> generateWeights(IStochasticProcess process, Set<List<? extends Event<?>>> sequences) {66 private Map<List<? extends Event<?>>, Double> generateWeights(IStochasticProcess process, Collection<List<? extends Event<?>>> sequences) { 66 67 Map<List<? extends Event<?>>, Double> subSeqWeights = new LinkedHashMap<List<? extends Event<?>>, Double>(); 67 68 double sum = 0.0; … … 89 90 90 91 // O(numSeq*lenSeq) 91 private Set<List<? extends Event<?>>> containedSubSequences( List<List<? extends Event<?>>> sequences, int length) {92 private Set<List<? extends Event<?>>> containedSubSequences(Collection<List<? extends Event<?>>> sequences, int length) { 92 93 Set<List<? extends Event<?>>> containedSubSeqs = new LinkedHashSet<List<? extends Event<?>>>(); 93 94 List<Event<?>> subSeq = new LinkedList<Event<?>>(); -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/DeterministicFiniteAutomaton.java
r101 r102 1 1 package de.ugoe.cs.eventbench.models; 2 2 3 import java.util.Collection; 3 4 import java.util.LinkedList; 4 5 import java.util.List; … … 61 62 } 62 63 63 List<Event<?>> followers = trie.getFollowingSymbols(contextCopy);64 Collection<Event<?>> followers = trie.getFollowingSymbols(contextCopy); 64 65 65 66 if (followers.size() != 0 && followers.contains(symbol)) { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/FirstOrderMarkovModel.java
r101 r102 2 2 3 3 import java.util.ArrayList; 4 import java.util.Collection; 4 5 import java.util.List; 5 6 import java.util.Random; … … 167 168 List<Event<?>> context = new ArrayList<Event<?>>(); 168 169 context.add(symbol); 169 List<Event<?>> followers = trie.getFollowingSymbols(context);170 Collection<Event<?>> followers = trie.getFollowingSymbols(context); 170 171 for (Event<?> follower : followers) { 171 172 stringBuilder.append(" " + symbol.hashCode() + " -> " … … 199 200 context.add(symbol); 200 201 201 List<Event<?>> followers = trie.getFollowingSymbols(context);202 Collection<Event<?>> followers = trie.getFollowingSymbols(context); 202 203 203 204 for (Event<?> follower : followers) { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/HighOrderMarkovModel.java
r101 r102 1 1 package de.ugoe.cs.eventbench.models; 2 2 3 import java.util.Collection; 3 4 import java.util.LinkedList; 4 5 import java.util.List; … … 49 50 50 51 51 List<Event<?>> followers = trie.getFollowingSymbols(contextCopy);52 Collection<Event<?>> followers = trie.getFollowingSymbols(contextCopy); 52 53 int sumCountFollowers = 0; // N(s\sigma') 53 54 for( Event<?> follower : followers ) { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IStochasticProcess.java
r99 r102 2 2 3 3 import java.io.Serializable; 4 import java.util.Collection; 4 5 import java.util.List; 5 import java.util.Set;6 6 7 7 import de.ugoe.cs.eventbench.data.Event; … … 55 55 * @see #generateSequences(int, boolean) 56 56 */ 57 public Set<List<? extends Event<?>>> generateSequences(int length);57 public Collection<List<? extends Event<?>>> generateSequences(int length); 58 58 59 59 /** … … 73 73 * @return generated sequences 74 74 */ 75 public Set<List<? extends Event<?>>> generateSequences(int length,75 public Collection<List<? extends Event<?>>> generateSequences(int length, 76 76 boolean fromStart); 77 77 … … 88 88 * @return generated sequences 89 89 */ 90 public Set<List<? extends Event<?>>> generateValidSequences(int length);90 public Collection<List<? extends Event<?>>> generateValidSequences(int length); 91 91 92 92 /** … … 117 117 * @return events known by the process 118 118 */ 119 public Set<? extends Event<?>> getEvents();119 public Collection<? extends Event<?>> getEvents(); 120 120 121 121 } -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java
r101 r102 1 1 package de.ugoe.cs.eventbench.models; 2 2 3 import java.util.Collection; 3 4 import java.util.LinkedList; 4 5 import java.util.List; … … 116 117 } 117 118 118 List<Event<?>> followers = trie.getFollowingSymbols(contextCopy); // \Sigma'119 Collection<Event<?>> followers = trie.getFollowingSymbols(contextCopy); // \Sigma' 119 120 int sumCountFollowers = 0; // N(s\sigma') 120 121 for (Event<?> follower : followers) { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/Trie.java
r86 r102 2 2 3 3 import java.io.Serializable; 4 import java.util.Collection; 4 5 import java.util.LinkedHashSet; 5 6 import java.util.LinkedList; … … 103 104 104 105 // returns all symbols that follow the defined sequence 105 public List<T> getFollowingSymbols(List<T> sequence) {106 List<T> result = new LinkedList<T>();106 public Collection<T> getFollowingSymbols(List<T> sequence) { 107 Collection<T> result = new LinkedList<T>(); 107 108 TrieNode<T> node = find(sequence); 108 109 if( node!=null ) { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java
r100 r102 3 3 import java.security.InvalidParameterException; 4 4 import java.util.ArrayList; 5 import java.util.Collection; 5 6 import java.util.LinkedHashSet; 6 7 import java.util.LinkedList; … … 84 85 * training data 85 86 */ 86 public void train( List<List<Event<?>>> sequences) {87 public void train(Collection<List<Event<?>>> sequences) { 87 88 trie = new Trie<Event<?>>(); 88 89 … … 204 205 */ 205 206 @Override 206 public Set<? extends Event<?>> getEvents() {207 public Collection<? extends Event<?>> getEvents() { 207 208 return trie.getKnownSymbols(); 208 209 } … … 215 216 */ 216 217 @Override 217 public Set<List<? extends Event<?>>> generateSequences(int length) {218 public Collection<List<? extends Event<?>>> generateSequences(int length) { 218 219 return generateSequences(length, false); 219 220 } … … 249 250 return sequenceSet; 250 251 } 251 Set<? extends Event<?>> events = getEvents();252 Set<List<? extends Event<?>>> seqsShorter = generateSequences(252 Collection<? extends Event<?>> events = getEvents(); 253 Collection<List<? extends Event<?>>> seqsShorter = generateSequences( 253 254 length - 1, fromStart); 254 255 for (Event<?> event : events) { … … 273 274 */ 274 275 @Override 275 public Set<List<? extends Event<?>>> generateValidSequences(int length) {276 public Collection<List<? extends Event<?>>> generateValidSequences(int length) { 276 277 // check for min-length implicitly done by generateSequences 277 Set<List<? extends Event<?>>> allSequences = generateSequences(length,278 Collection<List<? extends Event<?>>> allSequences = generateSequences(length, 278 279 true); 279 Set<List<? extends Event<?>>> validSequences = new LinkedHashSet<List<? extends Event<?>>>();280 Collection<List<? extends Event<?>>> validSequences = new LinkedHashSet<List<? extends Event<?>>>(); 280 281 for (List<? extends Event<?>> sequence : allSequences) { 281 282 if (sequence.size() == length -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieNode.java
r86 r102 3 3 import java.io.Serializable; 4 4 import java.security.InvalidParameterException; 5 import java.util.Collection; 5 6 import java.util.LinkedList; 6 7 import java.util.List; … … 22 23 private final T symbol; 23 24 24 private List<TrieNode<T>> children;25 private Collection<TrieNode<T>> children; 25 26 26 27 TrieNode() { … … 96 97 97 98 // returns all symbols that follow this node 98 public List<T> getFollowingSymbols() {99 List<T> followingSymbols = new LinkedList<T>();99 public Collection<T> getFollowingSymbols() { 100 Collection<T> followingSymbols = new LinkedList<T>(); 100 101 for( TrieNode<T> child : children ) { 101 102 followingSymbols.add(child.getSymbol());
Note: See TracChangeset
for help on using the changeset viewer.