Changeset 2026
- Timestamp:
- 07/23/15 13:43:38 (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-testgeneration/src/main/java/de/ugoe/cs/autoquest/testgeneration/RandomWalkGenerator.java
r927 r2026 74 74 /** 75 75 * <p> 76 * Maximal number of attempts for creating a valid sequence. If this value is reached, the 77 * sequence generation will be aborted. 78 * </p> 79 */ 80 private final long maxIterValidSequence; 81 82 /** 83 * <p> 76 84 * Actual number of random walks performed to generate the test suite. 77 85 * </p> … … 103 111 * maximal number of random walks before aborting the test case generation (see 104 112 * {@link #maxIter}) 113 * @param maxIterValidSequence 114 * maximal number of attempts to create a valid sequence within the given restrictions 105 115 */ 106 116 public RandomWalkGenerator(int numSequences, … … 108 118 int maxLength, 109 119 boolean validEnd, 110 long maxIter) 120 long maxIter, 121 long maxIterValidSequence) 111 122 { 112 123 // check validity of the parameters … … 117 128 if (maxLength < 1) { 118 129 throw new IllegalArgumentException( 119 120 130 "maximal allowed length of test cases must be at least 1 but is " + 131 maxLength); 121 132 } 122 133 if (minLength > maxLength) { 123 134 throw new IllegalArgumentException( 124 125 135 "minimal allowed length of test cases must be less than or equal to the maximal allowed length (min length: " + 136 minLength + " ; max length: " + maxLength + ")"); 126 137 } 127 138 if (maxIter < numSequences) { 128 139 throw new IllegalArgumentException( 129 "maximal number of iterations must greater than or equal to the number of sequences (number of sequences: " + 130 numSequences + 131 " ; max iterations: " + 132 maxIter + 133 ")"); 140 "maximal number of iterations must greater than or equal to the number of sequences (number of sequences: " + 141 numSequences + 142 " ; max iterations: " + 143 maxIter + 144 ")"); 145 } 146 if( maxIterValidSequence < 1) { 147 throw new IllegalArgumentException("maximal number of attempts to get a valid sequence must be positive, but is: " + maxIterValidSequence); 134 148 } 135 149 this.numSequences = numSequences; … … 138 152 this.validEnd = validEnd; 139 153 this.maxIter = maxIter; 154 this.maxIterValidSequence = maxIterValidSequence; 140 155 } 141 156 … … 157 172 actualIter = 0; 158 173 while (sequences.size() < numSequences && actualIter < maxIter) { 159 List<Event> generatedSequence = model.randomSequence(maxLength, validEnd );174 List<Event> generatedSequence = model.randomSequence(maxLength, validEnd, maxIterValidSequence); 160 175 if (generatedSequence.size() >= minLength && generatedSequence.size() <= maxLength) { 161 176 ((List<Event>) generatedSequence).add(0, Event.STARTEVENT); -
trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/IStochasticProcess.java
r1641 r2026 61 61 */ 62 62 double getProbability(List<Event> sequence); 63 64 /** 65 * <p> 66 * Returns the sum of the negative logarithm of the probabilities. 67 * </p> 68 * 63 64 /** 65 * <p> 66 * Returns the sum of the negative logarithm of the probabilities. 67 * </p> 68 * 69 69 * @param sequence 70 70 * sequences of which the logsum is calculated … … 101 101 * @param validEnd 102 102 * if true, only sequences that finish with {@link Event#ENDEVENT} are generated 103 * @param maxIter 104 * maximum number of attempts for the generation of the sequence; in case of failure 105 * and empty sequence is returned 103 106 * @return randomly generated sequence 104 107 * 105 108 */ 106 public List<Event> randomSequence(int maxLength, boolean validEnd );109 public List<Event> randomSequence(int maxLength, boolean validEnd, long maxIter); 107 110 108 111 /** -
trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieBasedModel.java
r1996 r2026 147 147 @Override 148 148 public List<Event> randomSequence() { 149 return randomSequence(Integer.MAX_VALUE, true );149 return randomSequence(Integer.MAX_VALUE, true, 100); 150 150 } 151 151 … … 156 156 */ 157 157 @Override 158 public List<Event> randomSequence(int maxLength, boolean validEnd ) {158 public List<Event> randomSequence(int maxLength, boolean validEnd, long maxIter) { 159 159 List<Event> sequence = new LinkedList<Event>(); 160 int attempts = 0; 160 161 if (trie != null) { 161 162 boolean endFound = false; 162 while (!endFound) { // outer loop for length checking 163 sequence = new LinkedList<Event>(); 163 while (!endFound && attempts <= maxIter) { // outer loop for length checking 164 164 IncompleteMemory<Event> context = new IncompleteMemory<Event>(trieOrder - 1); 165 165 context.add(Event.STARTEVENT); … … 186 186 } 187 187 } 188 if (!endFound) { 189 sequence = new LinkedList<Event>(); 190 } 191 attempts++; 188 192 } 189 193 } … … 398 402 List<Event> context = new LinkedList<Event>(); 399 403 for (Event event : sequence) { 400 odds += Math.log(getProbability(context, event) +1);404 odds += Math.log(getProbability(context, event) + 1); 401 405 context.add(event); 402 406 } -
trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usage/CMDgenerateRandomSequences.java
r927 r2026 81 81 82 82 RandomWalkGenerator generator = new RandomWalkGenerator(numSessions, 83 minLength, maxLength, validEnd, maxIter );83 minLength, maxLength, validEnd, maxIter, 100); 84 84 Collection<List<Event>> sequences = generator 85 85 .generateTestSuite(model);
Note: See TracChangeset
for help on using the changeset viewer.