Changeset 1934 for trunk/autoquest-ui-core/src
- Timestamp:
- 03/27/15 13:26:47 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/sequences/CMDsequencesSubset.java
r1885 r1934 49 49 public void run(List<Object> parameters) { 50 50 int subsetCount; 51 int subsetSize; 51 double subsetSize; 52 boolean isPercent = false; 52 53 String sequencesName; 53 54 String newSequencesName; 54 55 try { 55 56 subsetCount = Integer.parseInt((String) parameters.get(0)); 56 subsetSize = Integer.parseInt((String) parameters.get(1)); 57 isPercent = ((String) parameters.get(1)).endsWith("%"); 58 59 if (!isPercent) { 60 subsetSize = Integer.parseInt((String) parameters.get(1)); 61 } 62 else { 63 String percent = (String) parameters.get(1); 64 percent = percent.substring(0, percent.length() - 1); 65 subsetSize = Double.parseDouble(percent); 66 } 57 67 sequencesName = (String) parameters.get(2); 58 68 if (parameters.size() > 3) { … … 108 118 } 109 119 120 int effSubsetSize; 121 if (isPercent) { 122 effSubsetSize = (int) Math.floor(subsetSize * allEvents / 100); 123 } 124 else { 125 effSubsetSize = (int) subsetSize; 126 } 127 110 128 Console.println("creating " + subsetCount + " sequence sets covering on average " + 111 subsetSize + " events by subdividing " + sequences.size() +129 effSubsetSize + " events by subdividing " + sequences.size() + 112 130 " sequences covering " + allEvents + " events into subsets"); 113 131 114 boolean mutuallyExclusiveSubsets = ( subsetSize * subsetCount) <allEvents;132 boolean mutuallyExclusiveSubsets = (effSubsetSize * subsetCount) <= allEvents; 115 133 116 134 if (!mutuallyExclusiveSubsets) { … … 120 138 121 139 List<List<List<Event>>> subsets = new LinkedList<>(); 122 double randomProbability = ((double) subsetSize) / allEvents;140 double randomProbability = ((double) effSubsetSize) / allEvents; 123 141 ListIterator<List<Event>> sequencesIterator = fixedOrderSequences.listIterator(); 124 142 int minSubsetSize = Integer.MAX_VALUE; … … 128 146 for (int i = 0; i < subsetCount; i++) { 129 147 List<List<Event>> subset = new LinkedList<>(); 130 int remainingEventsToAdd = subsetSize;148 int remainingEventsToAdd = effSubsetSize; 131 149 while (remainingEventsToAdd > 0) { 132 150 if (!sequencesIterator.hasNext()) {
Note: See TracChangeset
for help on using the changeset viewer.