Changeset 1401
- Timestamp:
- 02/26/14 17:12:53 (11 years ago)
- Location:
- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1294 r1401 98 98 } 99 99 100 101 100 taskBuilder.addTaskInstance(parent, startIndex, subsequence); 102 101 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java
r1356 r1401 38 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 39 39 import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; 40 import de.ugoe.cs.autoquest.usageprofiles.Trie; 40 41 import de.ugoe.cs.autoquest.usageprofiles.TrieProcessor; 41 42 import de.ugoe.cs.util.StopWatch; … … 44 45 /** 45 46 * <p> 46 * TODO comment 47 * This class implements the major rule for creating task trees based on a set of recorded 48 * user sessions. For this, it first harmonizes all tasks. This eases later comparison. Then it 49 * searches the sessions for iterations and replaces them accordingly. Then it searches for sub 50 * sequences being the longest and occurring most often. For each found sub sequence, it replaces 51 * the occurrences by creating appropriate {@link ISequence}s. Afterwards, again searches for 52 * iterations and then again for sub sequences until no more replacements are done. 53 * </p> 54 * <p> 55 * For determining the longest sequence occurring most often, the implementation uses a 56 * {@link Trie}. The depth of the tree is initially 3. If the algorithm has a longest sequence 57 * occurring most often whose length is equal to the depth of the trie, it recalculates the trie 58 * with an increased depth. 47 59 * </p> 48 60 * … … 54 66 * <p> 55 67 * the task factory to be used for creating substructures for the temporal 56 * relationships identified during rul e68 * relationships identified during rul application 57 69 * </p> 58 70 */ … … 68 80 /** 69 81 * <p> 70 * the task comparator to be used for comparing tasks for preparation 82 * the task handling strategy to be used for comparing tasks for preparation, i.e., before 83 * the tasks are harmonized 71 84 * </p> 72 85 */ … … 75 88 /** 76 89 * <p> 77 * the task comparatorto be used for comparing tasks during iteration detection an trie78 * generation 90 * the task handling strategy to be used for comparing tasks during iteration detection an trie 91 * generation, i.e., after the tasks are harmonized 79 92 * </p> 80 93 */ … … 83 96 /** 84 97 * <p> 85 * instantiates the rule and initializes it with a task equality rule manager and the minimal 86 * task equality identified sublist must have to consider them as iterated. 98 * instantiates the rule and initializes it with a task equality to be considered when 99 * comparing tasks as well as a task factory and builder to be used for creating task 100 * structures. 87 101 * </p> 102 * 103 * @param minimalTaskEquality the task equality to be considered when comparing tasks 104 * @param taskFactory the task factory to be used for creating substructures 105 * @param taskBuilder the task builder to be used for creating substructures 88 106 */ 89 107 SequenceForTaskDetectionRule(TaskEquality minimalTaskEquality, … … 151 169 /** 152 170 * <p> 153 * TODO: comment 171 * harmonizes the event task instances by unifying tasks. This is done, as initially the 172 * event tasks being equal with respect to the considered task equality are distinct objects. 173 * The comparison of these distinct objects is more time consuming than comparing the object 174 * references. 154 175 * </p> 155 176 * 156 * @param appData 177 * @param appData the rule application data combining all data used for applying this rule 157 178 */ 158 179 private void harmonizeEventTaskInstancesModel(RuleApplicationData appData) { … … 194 215 195 216 /** 196 * @param appData 217 * <p> 218 * searches for direct iterations of single tasks in all sequences and replaces them with 219 * {@link IIteration}s, respectively appropriate instances. Also all single occurrences of 220 * a task that is iterated somewhen are replaced with iterations to have again an efficient 221 * way for task comparisons. 222 * </p> 223 * 224 * @param appData the rule application data combining all data used for applying this rule 197 225 */ 198 226 private void detectAndReplaceIterations(RuleApplicationData appData) { … … 213 241 214 242 /** 215 * 243 * <p> 244 * searches the provided sessions for task iterations. If a task is iterated, it is added 245 * to the returned set. 246 * </p> 247 * 248 * @param the session to search for iterations in 249 * 250 * @return a set of tasks being iterated somewhere 216 251 */ 217 252 private Set<ITask> searchIteratedTasks(List<IUserSession> sessions) { … … 232 267 233 268 /** 269 * <p> 270 * replaces all occurrences of all tasks provided in the set with iterations 271 * </p> 234 272 * 273 * @param iteratedTasks the tasks to be replaced with iterations 274 * @param sessions the sessions in which the tasks are to be replaced 275 * @param appData the rule application data combining all data used for applying this rule 235 276 */ 236 277 private void replaceIterationsOf(Set<ITask> iteratedTasks, … … 288 329 289 330 /** 290 * 331 * <p> 332 * TODO clarify why this is done 333 * </p> 291 334 */ 292 335 private void harmonizeIterationInstancesModel(IIteration iteration, … … 345 388 346 389 /** 347 * @param appData 390 * TODO go on commenting 391 * @param appData the rule application data combining all data used for applying this rule 348 392 */ 349 393 private void detectAndReplaceTasks(RuleApplicationData appData) { … … 365 409 366 410 /** 367 * @ return411 * @param appData the rule application data combining all data used for applying this rule 368 412 */ 369 413 private void getSequencesOccuringMostOften(RuleApplicationData appData) { … … 462 506 463 507 /** 464 * @param parent 465 * @return 508 * @param appData the rule application data combining all data used for applying this rule 466 509 */ 467 510 private void createNewTrie(RuleApplicationData appData) { … … 483 526 484 527 /** 485 * @param appData 528 * @param appData the rule application data combining all data used for applying this rule 486 529 */ 487 530 private void replaceSequencesOccurringMostOften(RuleApplicationData appData) { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskHandlingStrategy.java
r1394 r1401 17 17 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 18 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 19 import de.ugoe.cs.autoquest.usageprofiles.DefaultSymbolMap;20 19 import de.ugoe.cs.autoquest.usageprofiles.SymbolComparator; 21 20 import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; … … 24 23 /** 25 24 * <p> 26 * TODO comment 25 * concrete implementation of a symbol strategy required in the creation of a 26 * {@link de.ugoe.cs.autoquest.usageprofiles.Trie}. The strategy can be parameterized with a 27 * considered task equality. It uses task instance comparators to perform task comparison. 28 * It creates task specific symbol maps, which are {@link TaskSymbolIdentityMap} and 29 * {@link TaskSymbolBucketedMap} depending on the level of considered task equality. 27 30 * </p> 28 31 * … … 35 38 36 39 /** 37 * 40 * <p> 41 * the level of task equality considered in this task handling strategy 42 * </p> 38 43 */ 39 44 private TaskEquality consideredEquality; 40 45 41 46 /** 42 * 47 * <p> 48 * the comparator used for task comparisons 49 * </p> 43 50 */ 44 51 private TaskInstanceComparator comparator; … … 46 53 /** 47 54 * <p> 48 * TODO: comment55 * initializes this strategy with a task equality to be considered for task comparisons 49 56 * </p> 50 57 * 51 * @param consideredEquality 58 * @param consideredEquality the task equality to be considered for task comparisons 52 59 */ 53 60 public TaskHandlingStrategy(TaskEquality consideredEquality) { … … 72 79 /** 73 80 * <p> 74 * TODO: comment 81 * convenience method to have a correctly typed return value as alternative to 82 * {@link #getSymbolComparator()}; 75 83 * </p> 76 *77 * @return78 84 */ 79 85 public TaskInstanceComparator getTaskComparator() { … … 95 101 96 102 /* (non-Javadoc) 97 * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#copySymbolMap( de.ugoe.cs.autoquest.usageprofiles.SymbolMap)103 * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#copySymbolMap(SymbolMap) 98 104 */ 99 105 @Override 100 106 public <V> SymbolMap<ITaskInstance, V> copySymbolMap(SymbolMap<ITaskInstance, V> other) { 101 107 if (consideredEquality == TaskEquality.IDENTICAL) { 102 return new DefaultSymbolMap<ITaskInstance,V>(other);108 return new TaskSymbolIdentityMap<V>(other); 103 109 } 104 110 else { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskIdentityComparator.java
r1294 r1401 19 19 20 20 /** 21 * TODO comment 21 * <p> 22 * symbol comparator implementation for task instances considering to task instances as equal if 23 * they refer to the identical task object (comparison of object references). 24 * </p> 22 25 */ 23 26 class TaskIdentityComparator extends TaskInstanceComparator { … … 28 31 /** 29 32 * <p> 30 * TODO: comment33 * initializes the parent class with the task equality {@link TaskEquality#IDENTICAL}. 31 34 * </p> 32 *33 * @param minimalNodeEquality34 35 */ 35 36 public TaskIdentityComparator() { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceComparator.java
r1394 r1401 26 26 27 27 /** 28 * TODO comment 28 * <p> 29 * implementation of a symbol comparator for task instances. Internally, it uses comparison buffers 30 * to prevent comparing two tasks or task instances several times. It internally instantiates 31 * comparers being the implementation strategy of the comparisons required for a specific level 32 * of task equality. The comparers internally use the {@link TaskEqualityRuleManager} for 33 * performing comparisons. 34 * </p> 29 35 */ 30 36 public class TaskInstanceComparator implements SymbolComparator<ITaskInstance> { … … 33 39 private static final long serialVersionUID = 1L; 34 40 35 /** */ 41 /** 42 * the maximum size of the internal buffer used for storing comparison results 43 */ 36 44 private static final int MAX_BUFFER_SIZE = 2 * 1024 * 1024; 37 45 38 /** */ 39 private TaskEquality minimalNodeEquality; 40 41 /** */ 46 /** 47 * the considered level of task equality 48 */ 49 private TaskEquality minimalTaskEquality; 50 51 /** 52 * the comparer used internally for comparing two tasks 53 */ 42 54 private transient Comparer comparer; 43 55 44 /** */ 56 /** 57 * the comparer used for comparing two tasks on the lexical level 58 */ 45 59 private transient Comparer lexicalComparer; 46 60 47 /** */ 61 /** 62 * internal buffer used for storing comparison results 63 */ 48 64 private transient HashMap<Long, Boolean> equalityBuffer = new HashMap<Long, Boolean>(); 49 65 50 /** */ 66 /** 67 * internal buffer used for storing comparison results only for lexical comparisons 68 */ 51 69 private transient HashMap<Long, Boolean> lexicalEqualityBuffer; 52 70 53 71 /** 54 * 55 */ 56 public TaskInstanceComparator(TaskEquality minimalNodeEquality) { 57 this.minimalNodeEquality = minimalNodeEquality; 72 * <p> 73 * initializes the comparator with a considered task equality level 74 * </p> 75 * 76 * @param minimalTaskEquality the considered task equality level 77 */ 78 public TaskInstanceComparator(TaskEquality minimalTaskEquality) { 79 this.minimalTaskEquality = minimalTaskEquality; 58 80 init(); 59 81 } … … 68 90 69 91 /** 70 * 92 * <p> 93 * returns true, if this comparator considers the provided tasks as equal, false else 94 * </p> 95 * 96 * @param task1 the first task to compare 97 * @param task2 the second task to compare 98 * 99 * @return as described 71 100 */ 72 101 public boolean equals(ITask task1, ITask task2) { … … 100 129 101 130 /** 102 * 131 * <p> 132 * returns true, if this comparator considers the provided tasks as lexically equal, false else 133 * </p> 134 * 135 * @param task1 the first task to compare 136 * @param task2 the second task to compare 137 * 138 * @return as described 103 139 */ 104 140 public boolean areLexicallyEqual(ITask task1, ITask task2) { … … 127 163 /** 128 164 * <p> 129 * TODO: comment 130 * </p> 131 * 165 * can be called externally to clear the internal comparison buffers 166 * </p> 132 167 */ 133 168 public void clearBuffers() { … … 137 172 138 173 /** 139 * 174 * <p> 175 * initializes the comparator with comparers depending on the different comparison levels as 176 * well as with the required comparison buffers. Comparers and buffers for lexical comparison 177 * may be reused if the considered equality level is also lexical. 178 * </p> 140 179 */ 141 180 private void init() { 142 if (minimal NodeEquality == TaskEquality.LEXICALLY_EQUAL) {181 if (minimalTaskEquality == TaskEquality.LEXICALLY_EQUAL) { 143 182 comparer = new LexicalComparer(); 144 183 } 145 else if (minimal NodeEquality == TaskEquality.SYNTACTICALLY_EQUAL) {184 else if (minimalTaskEquality == TaskEquality.SYNTACTICALLY_EQUAL) { 146 185 comparer = new SyntacticalComparer(); 147 186 } 148 else if (minimal NodeEquality == TaskEquality.SEMANTICALLY_EQUAL) {187 else if (minimalTaskEquality == TaskEquality.SEMANTICALLY_EQUAL) { 149 188 comparer = new SemanticalComparer(); 150 189 } 151 190 else { 152 comparer = new DefaultComparer(this.minimal NodeEquality);153 } 154 155 if (minimal NodeEquality == TaskEquality.LEXICALLY_EQUAL) {191 comparer = new DefaultComparer(this.minimalTaskEquality); 192 } 193 194 if (minimalTaskEquality == TaskEquality.LEXICALLY_EQUAL) { 156 195 lexicalComparer = comparer; 157 196 lexicalEqualityBuffer = equalityBuffer; … … 175 214 176 215 /** 177 * 216 * <p> 217 * interface for internally used comparers containing only a compare method 218 * </p> 178 219 */ 179 220 private static interface Comparer { 180 221 181 222 /** 223 * <p> 224 * returns true, if this comparator considers the provided tasks as equal, false else 225 * </p> 182 226 * 227 * @param task1 the first task to compare 228 * @param task2 the second task to compare 229 * 230 * @return as described 183 231 */ 184 232 boolean compare(ITask task1, ITask task2); … … 186 234 187 235 /** 188 * 236 * <p> 237 * comparer that performs comparisons only on the lexical level 238 * </p> 189 239 */ 190 240 private static class LexicalComparer implements Comparer { 191 241 192 /* *193 * 242 /* (non-Javadoc) 243 * @see Comparer#compare(ITask, ITask) 194 244 */ 195 245 public boolean compare(ITask task1, ITask task2) { … … 199 249 200 250 /** 251 * <p> 252 * comparer that performs comparisons only on the syntactical level 253 * </p> 201 254 * 202 255 */ 203 256 private static class SyntacticalComparer implements Comparer { 204 257 205 /* *206 * 258 /* (non-Javadoc) 259 * @see Comparer#compare(ITask, ITask) 207 260 */ 208 261 public boolean compare(ITask task1, ITask task2) { … … 212 265 213 266 /** 214 * 267 * <p> 268 * comparer that performs comparisons only on the semantical level 269 * </p> 215 270 */ 216 271 private static class SemanticalComparer implements Comparer { 217 272 218 /* *219 * 273 /* (non-Javadoc) 274 * @see Comparer#compare(ITask, ITask) 220 275 */ 221 276 public boolean compare(ITask task1, ITask task2) { … … 225 280 226 281 /** 227 * 282 * <p> 283 * comparer that performs comparisons only on the provided level 284 * </p> 228 285 */ 229 286 private static class DefaultComparer implements Comparer { … … 231 288 /** 232 289 * <p> 233 * the minimal task equality two identified sublists need to have to consider them as equal290 * the minimal task equality considered by this comparer 234 291 * </p> 235 292 */ 236 private TaskEquality minimal NodeEquality;293 private TaskEquality minimalTaskEquality; 237 294 238 295 /** 239 * 240 */ 241 public DefaultComparer(TaskEquality minimalNodeEquality) { 242 this.minimalNodeEquality = minimalNodeEquality; 243 } 244 245 /** 246 * 296 * <p> 297 * initializes this comparer with the task equality to be considered 298 * </p> 299 */ 300 public DefaultComparer(TaskEquality minimalTaskEquality) { 301 this.minimalTaskEquality = minimalTaskEquality; 302 } 303 304 /* (non-Javadoc) 305 * @see Comparer#compare(ITask, ITask) 247 306 */ 248 307 public boolean compare(ITask task1, ITask task2) { 249 308 return TaskEqualityRuleManager.getInstance().areAtLeastEqual 250 (task1, task2, minimal NodeEquality);309 (task1, task2, minimalTaskEquality); 251 310 } 252 311 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrie.java
r1285 r1401 29 29 /** 30 30 * <p> 31 * TODO comment 31 * This trie implementation is a performance optimization for generating task trees. It does not 32 * create a full trie but adds only those subsequences having a chance of occurring most often. 33 * For this, it initially counts the number of occurrences of each task instance. Then, during 34 * training, it regularly determines the number of the currently most often occurring sequence. If 35 * this number is higher than the count of a task instance to be trained, the task instance is 36 * skipped the not added to the trie. 32 37 * </p> 33 38 * … … 41 46 /** 42 47 * <p> 43 * the task comparatorto be used for comparing tasks48 * the task handling strategy to be used for comparing tasks 44 49 * </p> 45 50 */ … … 48 53 /** 49 54 * <p> 50 * TODO: comment55 * instantiated the trie with the task handling strategy to be used 51 56 * </p> 52 57 * 53 * @param task Comparator258 * @param taskStrategy the task handling strategy to be used for comparing tasks 54 59 */ 55 60 public TaskInstanceTrie(TaskHandlingStrategy taskStrategy) { … … 59 64 60 65 /** 61 * 66 * <p> 67 * trains this trie with the provided user sessions up to the provided maximum depth using 68 * the optimization described in the description of this class. 69 * </p> 70 * 71 * @param userSessions the sessions for which this trie is to be trained 72 * @param maxOrder the depth of the trie 62 73 */ 63 74 public void trainSessions(List<IUserSession> userSessions, int maxOrder) { … … 125 136 126 137 /** 127 * 138 * <p> 139 * internally used convenience method for implementing the training optimization 140 * </p> 128 141 */ 129 142 private void train(IUserSession userSession, … … 133 146 int counterRecheckAt) 134 147 { 135 List<ITaskInstance> executedTasks = userSession.getExecutedTasks();136 137 148 List<ITaskInstance> subsequence = new LinkedList<ITaskInstance>(); 138 149 139 150 int sequenceMaxCount = 0; 140 151 141 for (ITaskInstance currentTaskInstance : executedTasks) {152 for (ITaskInstance currentTaskInstance : userSession) { 142 153 143 154 int occurrenceCount = taskInstanceCountMap.get(currentTaskInstance.getTask()).count; … … 181 192 /** 182 193 * <p> 183 * TODO: comment 194 * determines the current maximum count of sequences of a minimal length of two. Task instances 195 * occuring more seldom do not have to be considered anymore 184 196 * </p> 185 197 * 186 * @return 198 * @return the current maximum count of sequences of a minimal length of two 187 199 */ 188 200 private int getCurrentSequenceMaxCount() { … … 193 205 194 206 /** 207 * <p> 208 * trie processor identifying the current maximum count of sequences of a minimal length of two 209 * </p> 210 * 195 211 * @author Patrick Harms 196 212 */ … … 198 214 199 215 /** 200 * 216 * <p> 217 * the current maximum count 218 * </p> 201 219 */ 202 220 private int currentCount = 0; … … 219 237 220 238 /** 221 * 239 * <p> 240 * returns the current maximum count 241 * </p> 222 242 */ 223 243 private int getMaxCount() { … … 228 248 229 249 /** 250 * <p> 251 * counter object to be able to call something by the counters reference 252 * </p> 253 * 230 254 * @author Patrick Harms 231 255 */ -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolIdentityMap.java
r1285 r1401 25 25 /** 26 26 * <p> 27 * TODO comment 27 * symbol map implementation for task instances considering two task instances as equal if their 28 * tasks are identical 28 29 * </p> 29 30 * … … 36 37 37 38 /** 38 * 39 * <p> 40 * internally used map for implementing the symbol map interface 41 * </p> 39 42 */ 40 43 private Map<ITask, V> delegate; 41 44 42 45 /** 43 * 46 * <p> 47 * mapping between the tasks and the real symbols stored in the map, i.e. the task instances 48 * </p> 44 49 */ 45 50 private Map<ITask, ITaskInstance> symbols; … … 47 52 /** 48 53 * <p> 49 * TODO: comment54 * initializes this map 50 55 * </p> 51 *52 * @param other53 56 */ 54 57 public TaskSymbolIdentityMap() { … … 59 62 /** 60 63 * <p> 61 * TODO: comment64 * copy constructor 62 65 * </p> 63 66 * 64 * @param other 67 * @param other the map to be copied 65 68 */ 66 69 public TaskSymbolIdentityMap(SymbolMap<ITaskInstance, V> other) {
Note: See TracChangeset
for help on using the changeset viewer.