Changeset 2032 for trunk/autoquest-ui-core/src/main/java/de
- Timestamp:
- 07/30/15 14:34:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usability/CMDtaskTreeStatistics.java
r1886 r2032 15 15 package de.ugoe.cs.autoquest.commands.usability; 16 16 17 import java.text.DecimalFormat; 17 18 import java.util.HashSet; 19 import java.util.LinkedList; 18 20 import java.util.List; 19 21 import java.util.Set; 22 23 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; 20 24 21 25 import de.ugoe.cs.autoquest.CommandHelpers; … … 30 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 31 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskMetric; 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 37 import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskTreeUtils; 33 38 import de.ugoe.cs.util.console.Command; 34 39 import de.ugoe.cs.util.console.Console; … … 82 87 ITaskModel taskModel = (ITaskModel) dataObject; 83 88 84 int taskCount = 0;85 int allTasks = taskModel.getTasks().size();86 Set<IEventTaskInstance> coveredEvents = new HashSet<IEventTaskInstance>();87 89 int allEvents = 0; 88 90 … … 92 94 int noOfSelections = 0; 93 95 int noOfOptionals = 0; 96 Set<IEventTaskInstance> coveredEvents = new HashSet<IEventTaskInstance>(); 94 97 95 98 for (ITask task : taskModel.getTasks()) { 96 int covQuant =97 taskModel.getTaskInfo(task).getMeasureValue(TaskMetric.EVENT_COVERAGE_QUANTILE);98 99 if (covQuant >= 950) {100 taskCount++;101 getCoveredEvents(task, coveredEvents);102 }103 104 99 if (task instanceof IEventTask) { 105 100 noOfEventTasks++; … … 108 103 else if (task instanceof ISequence) { 109 104 noOfSequences++; 105 getCoveredEvents(task, coveredEvents); 110 106 } 111 107 else if (task instanceof IIteration) { … … 120 116 } 121 117 122 Console.println(noOfEventTasks + " eventTasks, " + noOfSequences + " sequences, " + 123 noOfIterations + " iterations, " + noOfSelections + " selections, " + 124 noOfOptionals + " optionals"); 125 Console.println(taskCount + " of " + allTasks + " tasks (" + (taskCount * 100 / allTasks) + 126 "%) covered " + coveredEvents.size() + " of " + allEvents + 127 " recorded events (" + (coveredEvents.size() * 100 / allEvents) + "%)"); 118 DescriptiveStatistics stats = new DescriptiveStatistics(); 119 120 for (IUserSession session : taskModel.getUserSessions()) { 121 if (session.size() > 0) { 122 final List<IEventTaskInstance> events = new LinkedList<>(); 123 124 for (ITaskInstance instance : session) { 125 instance.accept(new DefaultTaskInstanceTraversingVisitor() { 126 @Override 127 public void visit(IEventTaskInstance eventTaskInstance) { 128 events.add(eventTaskInstance); 129 } 130 }); 131 } 132 133 stats.addValue(events.size()); 134 } 135 } 136 137 Console.println(stats.getN() + " sessions"); 138 Console.println("average session length " + stats.getMean() + " (std dev " + 139 stats.getStandardDeviation() + ")"); 140 Console.println(allEvents + " events"); 141 142 Console.println(noOfEventTasks + " eventTasks"); 143 Console.println(noOfSequences + " sequences"); 144 Console.println(noOfIterations + " iterations"); 145 Console.println(noOfSelections + " selections"); 146 Console.println(noOfOptionals + " optionals"); 147 148 Set<ISequence> mostProminent = 149 TaskTreeUtils.getMostProminentTasks(taskModel, taskModel.getTasks()); 150 151 Set<IEventTaskInstance> mpCoveredEvents = new HashSet<IEventTaskInstance>(); 152 153 for (ITask task : mostProminent) { 154 getCoveredEvents(task, mpCoveredEvents); 155 } 156 157 Console.println(noOfSequences + " sequences cover " + 158 coveredEvents.size() + " of " + allEvents + " recorded events (" + 159 formatPercent(coveredEvents.size(), allEvents) + ")"); 160 161 Console.println(mostProminent.size() + " of " + noOfSequences + " sequences (" + 162 formatPercent(mostProminent.size(), noOfSequences) + ") cover " + 163 mpCoveredEvents.size() + " of " + allEvents + " recorded events (" + 164 formatPercent(mpCoveredEvents.size(), allEvents) + ")"); 165 166 Console.println("CSV: " + tasktreeName + ";" + noOfEventTasks + ";" + noOfSequences + ";" + 167 noOfIterations + ";" + noOfSelections + ";" + noOfOptionals + ";" + 168 allEvents + ";" + coveredEvents.size() + ";" + 169 formatPercent(coveredEvents.size(), allEvents) + ";" + 170 mostProminent.size() + ";" + 171 formatPercent(mostProminent.size(), noOfSequences) + ";" + 172 mpCoveredEvents.size() + ";" + 173 formatPercent(mpCoveredEvents.size(), allEvents)); 174 } 175 176 /** 177 * convenience method to format a percentage 178 */ 179 private String formatPercent(int ratio, int full) { 180 return new DecimalFormat("#,##0.0%").format(((double) ratio) / full); 128 181 } 129 182
Note: See TracChangeset
for help on using the changeset viewer.