Changeset 547 for trunk/quest-core-testgeneration/src/main/java/de
- Timestamp:
- 08/16/12 12:34:24 (12 years ago)
- Location:
- trunk/quest-core-testgeneration/src/main/java/de/ugoe/cs/quest/testgeneration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-testgeneration/src/main/java/de/ugoe/cs/quest/testgeneration/DrawFromAllSequencesGenerator.java
r523 r547 127 127 * @return the test suite 128 128 */ 129 public Collection<List< ? extends Event<?>>> generateTestSuite(129 public Collection<List<Event>> generateTestSuite( 130 130 IStochasticProcess model) { 131 131 if (model == null) { … … 133 133 } 134 134 135 Collection<List< ? extends Event<?>>> sequences = new LinkedHashSet<List<? extends Event<?>>>();135 Collection<List<Event>> sequences = new LinkedHashSet<List<Event>>(); 136 136 for (int length = minLength; length <= maxLength; length++) { 137 137 if (validEnd) { … … 145 145 List<Double> probabilities = new ArrayList<Double>(sequences.size()); 146 146 double probSum = 0.0; 147 for (List< ? extends Event<?>> sequence : sequences) {147 for (List<Event> sequence : sequences) { 148 148 double prob = model.getProbability(sequence); 149 149 probabilities.add(prob); … … 167 167 } 168 168 } 169 Collection<List< ? extends Event<?>>> retainedSequences = new LinkedList<List<? extends Event<?>>>();169 Collection<List<Event>> retainedSequences = new LinkedList<List<Event>>(); 170 170 int index = 0; 171 for (List< ? extends Event<?>> sequence : sequences) {171 for (List<Event> sequence : sequences) { 172 172 if (drawnSequences.contains(index)) { 173 173 retainedSequences.add(sequence); -
trunk/quest-core-testgeneration/src/main/java/de/ugoe/cs/quest/testgeneration/HybridGenerator.java
r523 r547 107 107 * @return the test suite 108 108 */ 109 public Collection<List< ? extends Event<?>>> generateTestSuite(109 public Collection<List<Event>> generateTestSuite( 110 110 IStochasticProcess model) { 111 111 if (model == null) { … … 113 113 } 114 114 115 Collection<List< ? extends Event<?>>> sequences = new LinkedHashSet<List<? extends Event<?>>>();116 117 List<List< ? extends Event<?>>> seqsTmp = new ArrayList<List<? extends Event<?>>>(115 Collection<List<Event>> sequences = new LinkedHashSet<List<Event>>(); 116 117 List<List<Event>> seqsTmp = new ArrayList<List<Event>>( 118 118 model.generateSequences(maxLengthAll + 1, true)); 119 119 … … 122 122 List<Double> probabilities = new ArrayList<Double>(seqsTmp.size()); 123 123 double probSum = 0.0; 124 for (List< ? extends Event<?>> sequence : seqsTmp) {124 for (List<Event> sequence : seqsTmp) { 125 125 double prob = model.getProbability(sequence); 126 126 probabilities.add(prob); … … 140 140 sum += currentProb; 141 141 } 142 List< ? extends Event<?>> seqTmp = seqsTmp.get(index);142 List<Event> seqTmp = seqsTmp.get(index); 143 143 if (!Event.ENDEVENT.equals(seqTmp.get(seqTmp.size() - 1))) { 144 List< ? extends Event<?>> sequence;144 List<Event> sequence; 145 145 if (validEnd) { 146 146 sequence = finishSequence(seqTmp, model, length + 2, … … 180 180 * @return finished sequence of the desired length 181 181 */ 182 private List< ? extends Event<?>> finishSequence(183 List< ? extends Event<?>> sequence, IStochasticProcess model,182 private List<Event> finishSequence( 183 List<Event> sequence, IStochasticProcess model, 184 184 int length, boolean validEnd) { 185 185 Random r = new Random(); 186 186 boolean endFound = false; 187 List<Event <?>> sequenceCopy = new LinkedList<Event<?>>(sequence);187 List<Event> sequenceCopy = new LinkedList<Event>(sequence); 188 188 final int maxIter = 30000; 189 189 int iter = 0; 190 190 while (!endFound && iter < maxIter) { 191 191 iter++; 192 sequenceCopy = new LinkedList<Event <?>>(sequence);192 sequenceCopy = new LinkedList<Event>(sequence); 193 193 while (!endFound && sequenceCopy.size() <= length) { 194 194 double randVal = r.nextDouble(); 195 195 double probSum = 0.0; 196 for (Event <?>symbol : model.getEvents()) {196 for (Event symbol : model.getEvents()) { 197 197 probSum += model.getProbability(sequenceCopy, symbol); 198 198 if (probSum >= randVal) { -
trunk/quest-core-testgeneration/src/main/java/de/ugoe/cs/quest/testgeneration/RandomWalkGenerator.java
r523 r547 138 138 * @return the test suite 139 139 */ 140 @SuppressWarnings("unchecked") 141 public Collection<List<? extends Event<?>>> generateTestSuite( 140 public Collection<List<Event>> generateTestSuite( 142 141 IStochasticProcess model) { 143 142 if (model == null) { … … 145 144 } 146 145 147 Set<List< ? extends Event<?>>> sequences = new HashSet<List<? extends Event<?>>>(146 Set<List<Event>> sequences = new HashSet<List<Event>>( 148 147 numSequences); 149 148 actualIter = 0; 150 149 while (sequences.size() < numSequences && actualIter < maxIter) { 151 List< ? extends Event<?>> generatedSequence = model.randomSequence(150 List<Event> generatedSequence = model.randomSequence( 152 151 maxLength, validEnd); 153 152 if (generatedSequence.size() >= minLength 154 153 && generatedSequence.size() <= maxLength) { 155 ((List<Event <?>>) generatedSequence).add(0, Event.STARTEVENT);154 ((List<Event>) generatedSequence).add(0, Event.STARTEVENT); 156 155 if (validEnd) { 157 ((List<Event <?>>) generatedSequence).add(Event.ENDEVENT);156 ((List<Event>) generatedSequence).add(Event.ENDEVENT); 158 157 } 159 158 sequences.add(generatedSequence);
Note: See TracChangeset
for help on using the changeset viewer.