Changeset 94 for trunk/EventBenchCore/src
- Timestamp:
- 07/04/11 10:56:31 (13 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IStochasticProcess.java
r93 r94 15 15 public Set<List<? extends Event<?>>> generateSequences(int length); 16 16 17 public Set<List<? extends Event<?>>> generateSequences(int length, boolean fromStart); 18 19 public Set<List<? extends Event<?>>> generateValidSequences(int length); 20 17 21 public int getNumStates(); 18 22 -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java
r93 r94 112 112 113 113 public Set<List<? extends Event<?>>> generateSequences(int length) { 114 Set<List<? extends Event<?>>> sequenceSet = new LinkedHashSet<List<? extends Event<?>>>();; 114 return generateSequences(length, false); 115 /*Set<List<? extends Event<?>>> sequenceSet = new LinkedHashSet<List<? extends Event<?>>>();; 115 116 if( length<1 ) { 116 117 throw new InvalidParameterException("Length of generated subsequences must be at least 1."); … … 137 138 } 138 139 return sequenceSet; 140 */ 141 } 142 143 // if startValid, all sequences will start in Event.STARTEVENT 144 public Set<List<? extends Event<?>>> generateSequences(int length, boolean fromStart) { 145 Set<List<? extends Event<?>>> sequenceSet = new LinkedHashSet<List<? extends Event<?>>>();; 146 if( length<1 ) { 147 throw new InvalidParameterException("Length of generated subsequences must be at least 1."); 148 } 149 if( length==1 ) { 150 if( fromStart ) { 151 List<Event<?>> subSeq = new LinkedList<Event<?>>(); 152 subSeq.add(Event.STARTEVENT); 153 } else { 154 for( Event<?> event : getEvents() ) { 155 List<Event<?>> subSeq = new LinkedList<Event<?>>(); 156 subSeq.add(event); 157 sequenceSet.add(subSeq); 158 } 159 } 160 return sequenceSet; 161 } 162 Set<? extends Event<?>> events = getEvents(); 163 Set<List<? extends Event<?>>> seqsShorter = generateSequences(length-1); 164 for( Event<?> event : events ) { 165 for( List<? extends Event<?>> seqShorter : seqsShorter ) { 166 Event<?> lastEvent = event; 167 if( getProbability(seqShorter, lastEvent)>0.0 ) { 168 List<Event<?>> subSeq = new ArrayList<Event<?>>(seqShorter); 169 subSeq.add(lastEvent); 170 sequenceSet.add(subSeq); 171 } 172 } 173 } 174 return sequenceSet; 175 } 176 177 // sequences from start to end 178 public Set<List<? extends Event<?>>> generateValidSequences(int length) { 179 // check for min-length implicitly done by generateSequences 180 Set<List<? extends Event<?>>> validSequences = generateSequences(length, true); 181 for( List<? extends Event<?>> sequence : validSequences ) { 182 if( sequence.size()!=length ) { 183 validSequences.remove(sequence); 184 } else { 185 if( !Event.ENDEVENT.equals(sequence.get(sequence.size()-1)) ) { 186 validSequences.remove(sequence); 187 } 188 } 189 } 190 return validSequences; 139 191 } 140 192
Note: See TracChangeset
for help on using the changeset viewer.