Changeset 119 for trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateRandomSequences.java
- Timestamp:
- 07/13/11 10:15:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateRandomSequences.java
r84 r119 2 2 3 3 import java.security.InvalidParameterException; 4 import java.util.HashSet; 4 5 import java.util.LinkedList; 5 6 import java.util.List; 7 import java.util.Set; 6 8 7 9 import de.ugoe.cs.eventbench.data.GlobalDataContainer; … … 18 20 String sequencesName; 19 21 int numSessions; 22 long maxIter; 20 23 try { 21 24 modelname = (String) parameters.get(0); 22 25 sequencesName = (String) parameters.get(1); 23 26 numSessions = Integer.parseInt((String) parameters.get(2)); 27 maxIter = numSessions*10; 28 if( parameters.size()==4 ) { 29 maxIter = Long.parseLong((String) parameters.get(3)); 30 } 24 31 } 25 32 catch (Exception e) { … … 36 43 } else { 37 44 model = (IStochasticProcess) dataObject; 38 List<List<? extends Event<?>>> sequences = new LinkedList<List<? extends Event<?>>>(); 39 for( int i=0 ; i<numSessions ; i++ ) { 45 Set<List<? extends Event<?>>> sequences = new HashSet<List<? extends Event<?>>>(numSessions); 46 long numIterations = 0; 47 while( sequences.size()<numSessions && numIterations<maxIter ) { 40 48 sequences.add(model.randomSequence()); 49 numIterations++; 50 } 51 if( sequences.size() < numSessions ) { 52 Console.println("Only " + sequences.size() + " unique sessions generated after " + maxIter + " iterations"); 41 53 } 42 54 if( GlobalDataContainer.getInstance().addData(sequencesName, sequences) ) { … … 48 60 @Override 49 61 public void help() { 50 Console.println("Usage: generateRandomSequenecs <modelName> <sequencesName> <numSessions> ");62 Console.println("Usage: generateRandomSequenecs <modelName> <sequencesName> <numSessions> {<maxIter>}"); 51 63 } 52 64
Note: See TracChangeset
for help on using the changeset viewer.