- Timestamp:
- 10/15/11 01:41:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/FirstOrderMarkovModel.java
r102 r258 3 3 import java.util.ArrayList; 4 4 import java.util.Collection; 5 import java.util.LinkedList; 5 6 import java.util.List; 6 7 import java.util.Random; … … 99 100 int numStates = knownSymbols.size(); 100 101 101 int startStateIndex = knownSymbols.indexOf(Event.STARTEVENT); 102 int endStateIndex = knownSymbols.indexOf(Event.ENDEVENT); 103 if (startStateIndex == -1) { 102 List<Integer> startIndexList = new LinkedList<Integer>(); 103 List<Integer> endIndexList = new LinkedList<Integer>(); 104 for( int i=0 ; i<knownSymbols.size() ; i++ ) { 105 String id = knownSymbols.get(i).getStandardId(); 106 if( id.equals(Event.STARTEVENT.getStandardId()) || id.contains(Event.STARTEVENT.getStandardId()+"-=-") ) { 107 startIndexList.add(i); 108 } 109 if( id.equals(Event.ENDEVENT.getStandardId()) || id.contains("-=-"+Event.ENDEVENT.getStandardId()) ) { 110 endIndexList.add(i); 111 } 112 } 113 114 if (startIndexList.isEmpty()) { 104 115 Console.printerrln("Error calculating entropy. Initial state of markov chain not found."); 105 116 return Double.NaN; 106 117 } 107 if (end StateIndex == -1) {118 if (endIndexList.isEmpty()) { 108 119 Console.printerrln("Error calculating entropy. End state of markov chain not found."); 109 120 return Double.NaN; 110 121 } 111 transmissionMatrix.set(endStateIndex, startStateIndex, 1); 122 for( Integer i : endIndexList ) { 123 for(Integer j : startIndexList ) { 124 transmissionMatrix.set(i, j, 1); 125 } 126 } 112 127 113 128 // Calculate stationary distribution by raising the power of the … … 160 175 List<Event<?>> knownSymbols = new ArrayList<Event<?>>( 161 176 trie.getKnownSymbols()); 162 163 177 for (Event<?> symbol : knownSymbols) { 164 178 final String thisSaneId = symbol.getShortId().replace("\"", "\\\"") … … 183 197 /** 184 198 * <p> 185 * Returns a {@link Graph} represen ation of the model with the states as199 * Returns a {@link Graph} representation of the model with the states as 186 200 * nodes and directed edges weighted with transition probabilities. 187 201 * </p>
Note: See TracChangeset
for help on using the changeset viewer.