Changeset 361 for trunk/EventBenchCore
- Timestamp:
- 01/27/12 14:42:36 (13 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/ModelFlattener.java
r258 r361 43 43 HighOrderMarkovModel model) { 44 44 int markovOrder = model.trieOrder - 1; 45 if (markovOrder == 1) {46 // TODO model is already FOM47 // requires copy constructor in class trie48 }49 firstOrderTrie = new Trie<Event<?>>();50 TrieNode<Event<?>> rootNode = model.trie.find(null);51 generateFirstOrderTrie(rootNode, new LinkedList<String>(), markovOrder);52 firstOrderTrie.updateKnownSymbols();53 54 45 FirstOrderMarkovModel firstOrderModel = new FirstOrderMarkovModel( 55 46 new Random()); 56 firstOrderModel.trie = firstOrderTrie;57 47 firstOrderModel.trieOrder = 2; 48 if (markovOrder == 1) { 49 firstOrderModel.trie = new Trie<Event<?>>(model.trie); 50 firstOrderModel.trieOrder = 2; 51 } else { 52 firstOrderTrie = new Trie<Event<?>>(); 53 TrieNode<Event<?>> rootNode = model.trie.find(null); 54 generateFirstOrderTrie(rootNode, new LinkedList<String>(), markovOrder); 55 firstOrderTrie.updateKnownSymbols(); 56 firstOrderModel.trie = firstOrderTrie; 57 } 58 58 59 59 return firstOrderModel; -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/Trie.java
r316 r361 2 2 3 3 import java.io.Serializable; 4 import java.security.InvalidParameterException; 4 5 import java.util.Collection; 5 6 import java.util.HashSet; … … 64 65 /** 65 66 * <p> 67 * Copy-Constructor. Creates a new Trie as the copy of other. The other trie 68 * must noch be null. 69 * </p> 70 * 71 * @param other 72 * Trie that is copied 73 */ 74 public Trie(Trie<T> other) { 75 if (other == null) { 76 throw new InvalidParameterException("other trie must not be null"); 77 } 78 rootNode = new TrieNode<T>(other.rootNode); 79 knownSymbols = new LinkedHashSet<T>(other.knownSymbols); 80 } 81 82 /** 83 * <p> 66 84 * Returns a collection of all symbols occuring in the trie. 67 85 * </p> … … 251 269 public List<T> getContextSuffix(List<T> context) { 252 270 List<T> contextSuffix; 253 if ( context!=null) {271 if (context != null) { 254 272 contextSuffix = new LinkedList<T>(context); // defensive copy 255 273 } else { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieNode.java
r258 r361 78 78 * symbol associated with the trie node 79 79 */ 80 publicTrieNode(T symbol) {80 TrieNode(T symbol) { 81 81 if (symbol == null) { 82 82 throw new InvalidParameterException( … … 86 86 count = 0; 87 87 children = new LinkedList<TrieNode<T>>(); 88 } 89 90 /** 91 * <p> 92 * Copy-Constructor. Creates a new TrieNode as copy of other. Other must not 93 * be null. 94 * </p> 95 * 96 * @param other 97 */ 98 TrieNode(TrieNode<T> other) { 99 if (other == null) { 100 throw new InvalidParameterException("other must not be null"); 101 } 102 symbol = other.symbol; 103 count = other.count; 104 children = new LinkedList<TrieNode<T>>(); 105 for (TrieNode<T> child : other.children) { 106 children.add(new TrieNode<T>(child)); 107 } 88 108 } 89 109
Note: See TracChangeset
for help on using the changeset viewer.