Changeset 129 for trunk/EventBenchCore/src
- Timestamp:
- 07/20/11 11:13:50 (13 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/SequenceTools.java
r123 r129 69 69 */ 70 70 public static long numSequences(IStochasticProcess process, int length) { 71 return (long) Math.pow(process.getNumS tates(), length);71 return (long) Math.pow(process.getNumSymbols(), length); 72 72 } 73 73 -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IStochasticProcess.java
r118 r129 107 107 * @return number of states 108 108 */ 109 public int getNumS tates();109 public int getNumSymbols(); 110 110 111 111 /** … … 116 116 * @return string representation for all known states 117 117 */ 118 public String[] getStateStrings(); 118 public String[] getSymbolStrings(); 119 120 /** 121 * <p> 122 * Returns the number of states the process would have if it would be flattened through state-splitting to a first-order Markov model. 123 * </p> 124 * <p> 125 * If it is not possible to flatten the model, -1 is returned. 126 * </p> 127 * 128 * @return number of states an equivalent FOM would have; -1 is not available 129 */ 130 public int getNumFOMStates(); 119 131 120 132 /** -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/Trie.java
r106 r129 3 3 import java.io.Serializable; 4 4 import java.util.Collection; 5 import java.util.HashSet; 5 6 import java.util.LinkedHashSet; 6 7 import java.util.LinkedList; 7 8 import java.util.List; 9 import java.util.Set; 8 10 9 11 import de.ugoe.cs.util.StringTools; … … 364 366 * </p> 365 367 * 366 * @return 368 * @return number of symbols contained in the trie 367 369 */ 368 370 public int getNumSymbols() { 369 371 return knownSymbols.size(); 370 372 } 373 374 /** 375 * <p> 376 * Returns the number of trie nodes that are ancestors of a leaf. This is 377 * the equivalent to the number of states a first-order markov model would 378 * have. 379 * <p> 380 * 381 * @return number of trie nodes that are ancestors of leafs. 382 */ 383 public int getNumLeafAncestors() { 384 Set<TrieNode<T>> ancestors = new HashSet<TrieNode<T>>(); 385 rootNode.getLeafAncestors(ancestors); 386 return ancestors.size(); 387 } 371 388 } -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java
r118 r129 179 179 */ 180 180 @Override 181 public int getNumS tates() {181 public int getNumSymbols() { 182 182 return trie.getNumSymbols(); 183 183 } … … 189 189 */ 190 190 @Override 191 public String[] getS tateStrings() {192 String[] stateStrings = new String[getNumS tates()];191 public String[] getSymbolStrings() { 192 String[] stateStrings = new String[getNumSymbols()]; 193 193 int i = 0; 194 194 for (Event<?> symbol : trie.getKnownSymbols()) { … … 309 309 } 310 310 311 /* (non-Javadoc) 312 * @see de.ugoe.cs.eventbench.models.IStochasticProcess#getNumFOMStates() 313 */ 314 @Override 315 public int getNumFOMStates() { 316 return trie.getNumLeafAncestors(); 317 } 311 318 } -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieNode.java
r106 r129 6 6 import java.util.LinkedList; 7 7 import java.util.List; 8 import java.util.Set; 8 9 9 10 import de.ugoe.cs.eventbench.models.Trie.Edge; … … 286 287 } 287 288 } 289 290 /** 291 * <p> 292 * Checks if the node is a leaf. 293 * </p> 294 * 295 * @return true if the node is a leaf, false otherwise. 296 */ 297 protected boolean isLeaf() { 298 return children.isEmpty(); 299 } 300 301 /** 302 * <p> 303 * Recursive methods that collects all nodes that are ancestors of leafs and 304 * stores them in the set. 305 * </p> 306 * 307 * @param ancestors 308 * set of all ancestors of leafs 309 */ 310 protected void getLeafAncestors(Set<TrieNode<T>> ancestors) { 311 boolean isAncestor = false; 312 for (TrieNode<T> child : children) { 313 child.getLeafAncestors(ancestors); 314 isAncestor |= child.isLeaf(); 315 } 316 if (isAncestor) { 317 ancestors.add(this); 318 } 319 } 288 320 }
Note: See TracChangeset
for help on using the changeset viewer.