- Timestamp:
- 07/30/13 09:44:39 (11 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManagerTest.java
r1146 r1285 285 285 } 286 286 287 new TaskTreeChecker( ).assertTaskInstanceList287 new TaskTreeChecker(true).assertTaskInstanceList 288 288 ("UserSession session {" + 289 289 " Iteration iteration2 {" + -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrieTest.java
r1256 r1285 37 37 38 38 /** 39 * The class <code>TaskInstanceTrieTest</code> contains tests for the class <code>{@link TaskInstanceTrie}</code>. 39 * The class <code>TaskInstanceTrieTest</code> contains tests for the class 40 * <code>{@link TaskInstanceTrie}</code>. 40 41 * 41 * @author Steffen Herbold42 * @author Patrick Harms 42 43 * @version 1.0 43 44 */ … … 54 55 55 56 /** */ 56 private TaskComparator comparator = new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL); 57 private TaskHandlingStrategy strategy = 58 new TaskHandlingStrategy(TaskEquality.IDENTICAL); 57 59 58 60 /** */ … … 84 86 @Test 85 87 public void testTaskInstanceTaskInstanceTrie_1() throws Exception { 86 TaskInstanceTrie result = new TaskInstanceTrie( comparator);88 TaskInstanceTrie result = new TaskInstanceTrie(strategy); 87 89 88 90 assertNotNull(result); … … 95 97 @Test(expected = java.lang.IllegalArgumentException.class) 96 98 public void testTaskInstanceTrie_2() throws Exception { 97 new TaskInstanceTrie((Task Comparator) null);99 new TaskInstanceTrie((TaskHandlingStrategy) null); 98 100 } 99 101 100 102 @Test 101 103 public void testTrainSessions_1() throws Exception { 102 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);104 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 103 105 104 106 IUserSession session = (IUserSession) decoder.decode … … 136 138 @Test 137 139 public void testTrainSessions_2() throws Exception { 138 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);140 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 139 141 140 142 IUserSession session = (IUserSession) decoder.decode … … 167 169 @Test 168 170 public void testTrainSessions_3() throws Exception { 169 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);171 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 170 172 171 173 IUserSession session = (IUserSession) decoder.decode … … 199 201 @Test 200 202 public void testTrainSessions_4() throws Exception { 201 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);203 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 202 204 203 205 IUserSession session = (IUserSession) decoder.decode … … 240 242 @Test 241 243 public void testTrainSessions_5() throws Exception { 242 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);244 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 243 245 244 246 IUserSession session = (IUserSession) decoder.decode … … 276 278 @Test 277 279 public void testTrainSessions_6() throws Exception { 278 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);280 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 279 281 280 282 IUserSession session = (IUserSession) decoder.decode … … 313 315 @Test 314 316 public void testTrainSessions_7() throws Exception { 315 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);317 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 316 318 317 319 IUserSession session = (IUserSession) decoder.decode … … 354 356 @Test 355 357 public void testTrainSessions_8() throws Exception { 356 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);358 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 357 359 358 360 IUserSession session = (IUserSession) decoder.decode … … 390 392 @Test 391 393 public void testTrainSessions_9() throws Exception { 392 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);394 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 393 395 394 396 IUserSession session = (IUserSession) decoder.decode … … 428 430 @Test 429 431 public void testGetSequencesWithMostOccurrences_1() throws Exception { 430 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);432 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 431 433 432 434 fixture.trainSessions(Arrays.asList(session), 3); … … 445 447 @Test 446 448 public void testGetSequencesWithMostOccurrences_2() throws Exception { 447 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);449 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 448 450 449 451 fixture.trainSessions(Arrays.asList(session), 3); … … 510 512 @Test 511 513 public void testGetSequencesWithMostOccurrences_3() throws Exception { 512 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);514 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 513 515 514 516 fixture.trainSessions(Arrays.asList(session), 3); … … 554 556 @Test 555 557 public void testGetSequencesWithMostOccurrences_4() throws Exception { 556 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);558 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 557 559 558 560 fixture.trainSessions(Arrays.asList(session), 3); … … 566 568 @Test 567 569 public void testGetSequencesWithMostOccurrences_5() throws Exception { 568 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);570 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 569 571 570 572 fixture.trainSessions(Arrays.asList(session), 3); … … 583 585 @Test 584 586 public void testGetSequencesWithMostOccurrences_6() throws Exception { 585 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);587 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 586 588 587 589 fixture.trainSessions(Arrays.asList(session), 3); … … 596 598 @Test 597 599 public void testGetSequencesWithMostOccurrences_7() throws Exception { 598 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);600 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 599 601 600 602 fixture.trainSessions(Arrays.asList(session), 3); … … 629 631 @Test 630 632 public void testGetSequencesWithMostOccurrences_8() throws Exception { 631 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);633 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 632 634 633 635 fixture.trainSessions(Arrays.asList(session), 3); … … 688 690 @Test 689 691 public void testGetSequencesWithMostOccurrences_9() throws Exception { 690 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);692 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 691 693 692 694 fixture.trainSessions(Arrays.asList(session), 3); … … 726 728 @Test 727 729 public void testGetSequencesWithMostOccurrences_10() throws Exception { 728 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);730 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 729 731 730 732 fixture.trainSessions(Arrays.asList(session), 3); … … 738 740 @Test 739 741 public void testGetSequencesWithMostOccurrences_11() throws Exception { 740 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);742 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 741 743 742 744 fixture.trainSessions(Arrays.asList(session), 3); … … 762 764 @Test 763 765 public void testGetSequencesWithMostOccurrences_12() throws Exception { 764 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);766 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 765 767 766 768 fixture.trainSessions(Arrays.asList(session), 3); … … 809 811 @Test 810 812 public void testGetSequencesWithMostOccurrences_13() throws Exception { 811 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);813 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 812 814 813 815 fixture.trainSessions(Arrays.asList(session), 3); … … 822 824 @Test 823 825 public void testGetSequencesWithMostOccurrences_14() throws Exception { 824 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);826 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 825 827 826 828 fixture.trainSessions(Arrays.asList(session), 3); … … 835 837 @Test 836 838 public void testGetCount_1() throws Exception { 837 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);839 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 838 840 839 841 fixture.trainSessions(Arrays.asList(session), 3); … … 850 852 @Test 851 853 public void testGetCount_2() throws Exception { 852 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);854 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 853 855 854 856 fixture.trainSessions(Arrays.asList(session), 3); … … 865 867 @Test 866 868 public void testGetCount_3() throws Exception { 867 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);869 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 868 870 869 871 fixture.trainSessions(Arrays.asList(session), 3); … … 879 881 @Test 880 882 public void testGetCount_4() throws Exception { 881 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);883 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 882 884 883 885 fixture.trainSessions(Arrays.asList(session), 3); … … 893 895 @Test 894 896 public void testGetCount_5() throws Exception { 895 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);897 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 896 898 897 899 fixture.trainSessions(Arrays.asList(session), 3); … … 908 910 @Test 909 911 public void testGetCount_6() throws Exception { 910 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);912 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 911 913 912 914 fixture.trainSessions(Arrays.asList(session), 3); … … 922 924 @Test 923 925 public void testGetFollowingSymbols_1() throws Exception { 924 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);926 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 925 927 926 928 fixture.trainSessions(Arrays.asList(session), 3); … … 940 942 @Test 941 943 public void testGetFollowingSymbols_2() throws Exception { 942 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);944 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 943 945 944 946 fixture.trainSessions(Arrays.asList(session), 3); … … 956 958 @Test 957 959 public void testGetFollowingSymbols_3() throws Exception { 958 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);960 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 959 961 960 962 fixture.trainSessions(Arrays.asList(session), 3); … … 970 972 @Test 971 973 public void testGetNumLeafAncestors_1() throws Exception { 972 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);974 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 973 975 974 976 fixture.trainSessions(Arrays.asList(session), 3); … … 981 983 @Test 982 984 public void testGetNumLeafs_1() throws Exception { 983 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);985 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 984 986 985 987 fixture.trainSessions(Arrays.asList(session), 3); … … 992 994 @Test 993 995 public void testGetNumSymbols_1() throws Exception { 994 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);996 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 995 997 996 998 fixture.trainSessions(Arrays.asList(session), 3); … … 1004 1006 @Test 1005 1007 public void testLargeTaskInstanceTrie_1() throws Exception { 1006 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1008 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1007 1009 1008 1010 int order = 2; … … 1024 1026 @Test 1025 1027 public void testLargeTaskInstanceTrie_2() throws Exception { 1026 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1028 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1027 1029 1028 1030 int order = 2; … … 1044 1046 @Test 1045 1047 public void testLargeTaskInstanceTrie_3() throws Exception { 1046 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1048 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1047 1049 1048 1050 int order = 2; … … 1064 1066 @Test 1065 1067 public void testLargeTaskInstanceTrie_4() throws Exception { 1066 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1068 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1067 1069 1068 1070 int order = 2; … … 1084 1086 @Test 1085 1087 public void testLargeTaskInstanceTrie_5() throws Exception { 1086 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1088 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1087 1089 1088 1090 int order = 2; … … 1104 1106 @Test 1105 1107 public void testLargeTaskInstanceTrie_6() throws Exception { 1106 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1108 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1107 1109 1108 1110 int order = 3; … … 1124 1126 @Test 1125 1127 public void testLargeTaskInstanceTrie_7() throws Exception { 1126 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1128 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1127 1129 1128 1130 int order = 3; … … 1144 1146 @Test 1145 1147 public void testLargeTaskInstanceTrie_8() throws Exception { 1146 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1148 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1147 1149 1148 1150 int order = 3; … … 1164 1166 @Test 1165 1167 public void testLargeTaskInstanceTrie_9() throws Exception { 1166 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1168 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1167 1169 1168 1170 int order = 3; … … 1184 1186 @Test 1185 1187 public void testLargeTaskInstanceTrie_10() throws Exception { 1186 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1188 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1187 1189 1188 1190 int order = 3; … … 1204 1206 @Test 1205 1207 public void testLargeTaskInstanceTrie_11() throws Exception { 1206 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1208 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1207 1209 1208 1210 int order = 4; … … 1224 1226 @Test 1225 1227 public void testLargeTaskInstanceTrie_12() throws Exception { 1226 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1228 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1227 1229 1228 1230 int order = 4; … … 1244 1246 @Test 1245 1247 public void testLargeTaskInstanceTrie_13() throws Exception { 1246 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1248 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1247 1249 1248 1250 int order = 4; … … 1264 1266 @Test 1265 1267 public void testLargeTaskInstanceTrie_14() throws Exception { 1266 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1268 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1267 1269 1268 1270 int order = 4; … … 1284 1286 @Test 1285 1287 public void testLargeTaskInstanceTrie_15() throws Exception { 1286 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1288 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1287 1289 1288 1290 int order = 4; … … 1304 1306 @Test 1305 1307 public void testLargeTaskInstanceTrie_16() throws Exception { 1306 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1308 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1307 1309 1308 1310 int order = 5; … … 1324 1326 @Test 1325 1327 public void testLargeTaskInstanceTrie_17() throws Exception { 1326 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1328 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1327 1329 1328 1330 int order = 5; … … 1344 1346 @Test 1345 1347 public void testLargeTaskInstanceTrie_18() throws Exception { 1346 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1348 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1347 1349 1348 1350 int order = 5; … … 1364 1366 @Test 1365 1367 public void testLargeTaskInstanceTrie_19() throws Exception { 1366 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1368 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1367 1369 1368 1370 int order = 5; … … 1384 1386 @Test 1385 1387 public void testLargeTaskInstanceTrie_20() throws Exception { 1386 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1388 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1387 1389 1388 1390 int order = 5; … … 1404 1406 @Test 1405 1407 public void testLargeTaskInstanceTrie_21() throws Exception { 1406 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1408 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1407 1409 1408 1410 int order = 6; … … 1424 1426 @Test 1425 1427 public void testLargeTaskInstanceTrie_22() throws Exception { 1426 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1428 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1427 1429 1428 1430 int order = 6; … … 1444 1446 @Test 1445 1447 public void testLargeTaskInstanceTrie_23() throws Exception { 1446 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1448 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1447 1449 1448 1450 int order = 6; … … 1464 1466 @Test 1465 1467 public void testLargeTaskInstanceTrie_24() throws Exception { 1466 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1468 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1467 1469 1468 1470 int order = 6; … … 1484 1486 @Test 1485 1487 public void testLargeTaskInstanceTrie_25() throws Exception { 1486 TaskInstanceTrie fixture = new TaskInstanceTrie( comparator);1488 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1487 1489 1488 1490 int order = 6; … … 1493 1495 fixture.trainSessions(Arrays.asList(tester.userSession), order); 1494 1496 System.out.println("testing session with 10000 task instances and 1000 symbols took " + 1497 (System.currentTimeMillis() - start) + "ms"); 1498 1499 fixture.process(tester); 1500 1501 // do not check if counts is empty, as some sequences may not be part of the reduced trie 1502 // and may therefore not be processed by the tester. 1503 //assertTrue(tester.counts.isEmpty()); 1504 } 1505 1506 @Test 1507 public void testLargeTaskInstanceTrie_26() throws Exception { 1508 TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 1509 1510 int order = 3; 1511 1512 TaskInstanceTrieTester tester = new TaskInstanceTrieTester(1000, 1000000, order); 1513 1514 long start = System.currentTimeMillis(); 1515 fixture.trainSessions(Arrays.asList(tester.userSession), order); 1516 System.out.println("testing session with 1000000 task instances and 1000 symbols took " + 1495 1517 (System.currentTimeMillis() - start) + "ms"); 1496 1518 … … 1513 1535 found = true; 1514 1536 for (int i = 0; i < containedList.size(); i++) { 1515 if (! comparator.equals(candidate.get(0), containedList.get(0))) {1537 if (!strategy.getTaskComparator().equals(candidate.get(0), containedList.get(0))) { 1516 1538 found = false; 1517 1539 break; … … 1660 1682 1661 1683 for (Map.Entry<Integer, ITaskInstance> entry : symbols.entrySet()) { 1662 if ( comparator.equals(entry.getValue(), symbol)) {1684 if (strategy.getTaskComparator().equals(entry.getValue(), symbol)) { 1663 1685 symbolIndex = entry.getKey(); 1664 1686 break; -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java
r1256 r1285 15 15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 16 16 17 import java.util.HashMap; 18 import java.util.HashSet; 17 19 import java.util.Iterator; 18 20 import java.util.LinkedList; 19 21 import java.util.List; 22 import java.util.Map; 23 import java.util.Set; 24 import java.util.logging.Level; 20 25 21 26 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; … … 32 37 import de.ugoe.cs.autoquest.usageprofiles.TrieProcessor; 33 38 import de.ugoe.cs.util.StopWatch; 39 import de.ugoe.cs.util.console.Console; 34 40 35 41 /** … … 59 65 /** 60 66 * <p> 61 * the task comparator to be used for comparing tasks 67 * the task comparator to be used for comparing tasks for preparation 62 68 * </p> 63 69 */ 64 private TaskComparator taskComparator; 65 70 private TaskHandlingStrategy preparationTaskHandlingStrategy; 71 72 /** 73 * <p> 74 * the task comparator to be used for comparing tasks during iteration detection an trie 75 * generation 76 * </p> 77 */ 78 private TaskHandlingStrategy identityTaskHandlingStrategy;; 79 66 80 /** 67 81 * <p> … … 77 91 this.taskBuilder = taskBuilder; 78 92 79 this.taskComparator = new TaskComparator(minimalTaskEquality); 93 this.preparationTaskHandlingStrategy = new TaskHandlingStrategy(minimalTaskEquality); 94 this.identityTaskHandlingStrategy = new TaskHandlingStrategy(TaskEquality.IDENTICAL); 80 95 } 81 96 … … 139 154 */ 140 155 private void harmonizeEventTaskInstancesModel(RuleApplicationData appData) { 141 System.out.print("harmonizing task model of event task instances");156 Console.traceln(Level.INFO, "harmonizing task model of event task instances"); 142 157 appData.getStopWatch().start("harmonizing event tasks"); 143 144 SymbolMap<ITaskInstance, ITask> unifiedTaskMap = 145 new SymbolMap<ITaskInstance, ITask>(taskComparator); 158 159 SymbolMap<ITaskInstance, ITask> uniqueTasks = 160 preparationTaskHandlingStrategy.createSymbolMap(); 161 TaskComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 146 162 147 163 int unifiedTasks = 0; 148 164 ITask task; 149 165 List<IUserSession> sessions = appData.getSessions(); 150 166 for (IUserSession session : sessions) { 167 Console.traceln(Level.FINE, "handling session " + session); 151 168 for (ITaskInstance taskInstance : session) { 152 ITask task = unifiedTaskMap.getValue(taskInstance);169 task = uniqueTasks.getValue(taskInstance); 153 170 154 171 if (task == null) { 155 uni fiedTaskMap.addSymbol(taskInstance, taskInstance.getTask());172 uniqueTasks.addSymbol(taskInstance, taskInstance.getTask()); 156 173 } 157 174 else { … … 160 177 } 161 178 } 162 } 163 179 180 comparator.clearBuffers(); 181 } 164 182 165 183 appData.getStopWatch().stop("harmonizing event tasks"); 166 System.out.println(" -->harmonized " + unifiedTasks + " task occurrences (still " +167 unifiedTaskMap.size() + " different tasks)");168 184 Console.traceln(Level.INFO, "harmonized " + unifiedTasks + " task occurrences (still " + 185 uniqueTasks.size() + " different tasks)"); 186 169 187 appData.getStopWatch().dumpStatistics(System.out); 188 appData.getStopWatch().reset(); 170 189 } 171 190 … … 174 193 */ 175 194 private void detectAndReplaceIterations(RuleApplicationData appData) { 176 System.out.print("detecting iterations");195 Console.traceln(Level.FINE, "detecting iterations"); 177 196 appData.getStopWatch().start("detecting iterations"); 178 197 179 198 List<IUserSession> sessions = appData.getSessions(); 180 int iteratedTasks = 0; 181 182 ITask iteratedTask = null; 183 184 do { 185 iteratedTask = searchIteratedTask(sessions); 186 187 if (iteratedTask != null) { 188 replaceIterationsOf(iteratedTask, sessions, appData); 189 iteratedTasks++; 190 } 191 } 192 while (iteratedTask != null); 199 200 Set<ITask> iteratedTasks = searchIteratedTasks(sessions); 201 202 if (iteratedTasks.size() > 0) { 203 replaceIterationsOf(iteratedTasks, sessions, appData); 204 } 193 205 194 206 appData.getStopWatch().stop("detecting iterations"); 195 System.out.println(" --> found " + iteratedTasks+ " iterated tasks");207 Console.traceln(Level.INFO, "replaced " + iteratedTasks.size() + " iterated tasks"); 196 208 } 197 209 … … 199 211 * 200 212 */ 201 private ITask searchIteratedTask(List<IUserSession> sessions) { 213 private Set<ITask> searchIteratedTasks(List<IUserSession> sessions) { 214 Set<ITask> iteratedTasks = new HashSet<ITask>(); 202 215 for (IUserSession session : sessions) { 203 216 for (int i = 0; i < (session.size() - 1); i++) { 204 if (taskComparator.equals(session.get(i), session.get(i + 1))) { 205 return session.get(i).getTask(); 206 } 207 } 208 } 209 210 return null; 217 // we prepared the task instances to refer to unique tasks, if they are treated 218 // as equal. Therefore, we just compare the identity of the tasks of the task 219 // instances 220 if (session.get(i).getTask() == session.get(i + 1).getTask()) { 221 iteratedTasks.add(session.get(i).getTask()); 222 } 223 } 224 } 225 226 return iteratedTasks; 211 227 } 212 228 … … 214 230 * 215 231 */ 216 /* private ITask searchIteratedTask(List<IUserSession> sessions) { 217 int minNoOfRepetitions = 2; 218 int minNoOfIterationOccurrences = 1; 219 220 Map<ITask, Integer> iterationsCounter = new HashMap<ITask, Integer>(); 221 222 for (IUserSession session : sessions) { 223 for (int i = 0; i < (session.size() - minNoOfRepetitions + 1); i++) { 224 ITask task = session.get(i).getTask(); 225 226 // check if the task is iterated 227 boolean isIterated = true; 228 for (int j = i + 1; j < i + minNoOfRepetitions; j++) { 229 if (!taskComparator.equals(task, session.get(j).getTask())) { 230 isIterated = false; 231 break; 232 } 233 } 234 235 if (isIterated) { 236 Integer currentCounter = null; 237 238 for (Map.Entry<ITask, Integer> entry : iterationsCounter.entrySet()) { 239 if (taskComparator.equals(task, entry.getKey())) { 240 currentCounter = entry.getValue(); 241 break; 242 } 243 } 244 245 if (currentCounter == null) { 246 currentCounter = 1; 247 iterationsCounter.put(task, currentCounter); 248 } 249 else { 250 currentCounter++; 251 iterationsCounter.put(task, currentCounter); 252 } 253 254 if (currentCounter >= minNoOfIterationOccurrences) { 255 return task; 256 } 257 } 258 } 259 } 260 261 return null; 262 }*/ 263 264 /** 265 * 266 */ 267 private void replaceIterationsOf(ITask iteratedTask, 232 private void replaceIterationsOf(Set<ITask> iteratedTasks, 268 233 List<IUserSession> sessions, 269 234 RuleApplicationData appData) 270 235 { 271 IIteration iteration = taskFactory.createNewIteration(); 236 Map<ITask, IIteration> iterations = new HashMap<ITask, IIteration>(); 237 Map<IIteration, List<ITaskInstance>> iterationInstances = 238 new HashMap<IIteration, List<ITaskInstance>>(); 239 240 for (ITask iteratedTask : iteratedTasks) { 241 IIteration iteration = taskFactory.createNewIteration(); 242 iterations.put(iteratedTask, iteration); 243 iterationInstances.put(iteration, new LinkedList<ITaskInstance>()); 244 } 245 272 246 ITaskInstance iterationInstance = null; 273 274 List<ITaskInstance> iterationInstances = new LinkedList<ITaskInstance>();275 247 276 248 for (IUserSession session : sessions) { 277 249 int index = 0; 278 250 while (index < session.size()) { 279 if (taskComparator.equals(iteratedTask, session.get(index).getTask())) { 280 if (iterationInstance == null) { 251 // we prepared the task instances to refer to unique tasks, if they are treated 252 // as equal. Therefore, we just compare the identity of the tasks of the task 253 // instances 254 ITask currentTask = session.get(index).getTask(); 255 IIteration iteration = iterations.get(currentTask); 256 if (iteration != null) { 257 if ((iterationInstance == null) || (iterationInstance.getTask() != iteration)) 258 { 281 259 iterationInstance = taskFactory.createNewTaskInstance(iteration); 282 iterationInstances. add(iterationInstance);260 iterationInstances.get(iteration).add(iterationInstance); 283 261 taskBuilder.addTaskInstance(session, index, iterationInstance); 284 262 index++; … … 297 275 } 298 276 299 harmonizeIterationInstancesModel(iteration, iterationInstances); 277 for (Map.Entry<IIteration, List<ITaskInstance>> entry : iterationInstances.entrySet()) { 278 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue()); 279 } 300 280 } 301 281 … … 307 287 { 308 288 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 289 TaskComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 309 290 310 291 // merge the lexically different variants of iterated task to a unique list … … 315 296 boolean found = false; 316 297 for (ITask taskVariant : iteratedTaskVariants) { 317 if ( taskComparator.areLexicallyEqual(taskVariant, candidate)) {298 if (comparator.areLexicallyEqual(taskVariant, candidate)) { 318 299 taskBuilder.setTask(executionVariant, taskVariant); 319 300 found = true; … … 359 340 */ 360 341 private void detectAndReplaceTasks(RuleApplicationData appData) { 361 System.out.println("detecting and replacing tasks");342 Console.traceln(Level.FINE, "detecting and replacing tasks"); 362 343 appData.getStopWatch().start("detecting tasks"); 363 344 … … 370 351 371 352 appData.getStopWatch().stop("replacing tasks"); 372 System.out.println("detected and replaced " + appData.getLastFoundTasks().size() + " tasks"); 353 Console.traceln(Level.INFO, "detected and replaced " + appData.getLastFoundTasks().size() + 354 " tasks occuring " + appData.getLastFoundTasks().getOccurrenceCount() + 355 "times"); 373 356 } 374 357 … … 377 360 */ 378 361 private void getSequencesOccuringMostOften(RuleApplicationData appData) { 379 System.out.println("determining most prominent tasks");362 Console.traceln(Level.FINE, "determining most prominent tasks"); 380 363 381 364 Tasks tasks; … … 411 394 412 395 appData.getStopWatch().start("testtrie"); 413 Trie<ITaskInstance> trie = new Trie<ITaskInstance>( taskComparator);396 Trie<ITaskInstance> trie = new Trie<ITaskInstance>(identityTaskComparator); 414 397 415 398 for (IUserSession session : appData.getSessions()) { … … 433 416 tasksEqual = true; 434 417 for (int i = 0; i < task1.size(); i++) { 435 if (! taskComparator.equals(task1.get(i).getTask(), task2.get(i).getTask()))418 if (!identityTaskComparator.equals(task1.get(i).getTask(), task2.get(i).getTask())) 436 419 { 437 420 tasksEqual = false; … … 458 441 459 442 throw new IllegalArgumentException("both tries calculated different subsequences"); 460 } */443 } 461 444 462 445 /*TrieStatisticsDumper dumper = new TrieStatisticsDumper(); … … 466 449 appData.setLastFoundTasks(tasks); 467 450 468 System.out.println("found " + appData.getLastFoundTasks().size() + " tasks occurring" +469 451 Console.traceln(Level.FINE, "found " + appData.getLastFoundTasks().size() + " tasks " + 452 "occurring " + appData.getLastFoundTasks().getOccurrenceCount() + " times"); 470 453 } 471 454 … … 475 458 */ 476 459 private void createNewTrie(RuleApplicationData appData) { 477 System.out.println("training trie with a maximum sequence length of " +478 460 Console.traceln(Level.FINER, "training trie with a maximum sequence length of " + 461 appData.getTrainedSequenceLength()); 479 462 480 463 appData.getStopWatch().start("training trie"); 481 appData.setLastTrie(new TaskInstanceTrie(taskComparator)); 464 465 // we prepared the task instances to refer to unique tasks, if they are treated 466 // as equal. Therefore, we just compare the identity of the tasks of the task 467 // instances 468 appData.setLastTrie(new TaskInstanceTrie(identityTaskHandlingStrategy)); 482 469 483 470 appData.getLastTrie().trainSessions … … 496 483 (appData.getLastFoundTasks().getOccurrenceCount() > 1)) 497 484 { 498 System.out.println("replacing tasks occurrences");485 Console.traceln(Level.FINER, "replacing tasks occurrences"); 499 486 500 487 for (List<ITaskInstance> task : appData.getLastFoundTasks()) { 501 488 ISequence sequence = taskFactory.createNewSequence(); 502 489 503 System.out.println("replacing " + sequence.getId() + ": " + task);490 Console.traceln(Level.FINEST, "replacing " + sequence.getId() + ": " + task); 504 491 505 492 List<ITaskInstance> sequenceInstances = … … 507 494 508 495 harmonizeSequenceInstancesModel(sequence, sequenceInstances,task.size()); 509 appData.detectedAndReplacedTasks(sequenceInstances.size() > 0); 496 appData.detectedAndReplacedTasks 497 (appData.detectedAndReplacedTasks() || (sequenceInstances.size() > 0)); 510 498 511 499 if (sequenceInstances.size() < appData.getLastFoundTasks().getOccurrenceCount()) { 512 System.out.println(sequence.getId() + ": replaced task only " +513 514 500 Console.traceln(Level.FINE, sequence.getId() + ": replaced task only " + 501 sequenceInstances.size() + " times instead of expected " + 502 appData.getLastFoundTasks().getOccurrenceCount()); 515 503 } 516 504 } … … 526 514 int sequenceLength) 527 515 { 516 TaskComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 528 517 529 518 // ensure for each subtask that lexically different variants are preserved … … 537 526 538 527 for (int i = 0; i < subTaskVariants.size(); i++) { 539 if ( taskComparator.areLexicallyEqual(subTaskVariants.get(i), candidate)) {528 if (comparator.areLexicallyEqual(subTaskVariants.get(i), candidate)) { 540 529 taskBuilder.setTask 541 530 (sequenceInstance.get(subTaskIndex), subTaskVariants.get(i)); … … 624 613 625 614 for (int j = 0; j < subList.size(); j++) { 626 if (!taskComparator.equals(list.get(i + j), subList.get(j))) { 615 // we prepared the task instances to refer to unique tasks, if they are treated 616 // as equal. Therefore, we just compare the identity of the tasks of the task 617 // instances 618 if (list.get(i + j).getTask() != subList.get(j).getTask()) { 627 619 matchFound = false; 628 620 break; … … 655 647 656 648 for (int j = 0; j < subList.size(); j++) { 657 if (!taskComparator.equals(list.get(i + j), subList.get(j))) { 649 // we prepared the task instances to refer to unique tasks, if they are treated 650 // as equal. Therefore, we just compare the identity of the tasks of the task 651 // instances 652 if (list.get(i + j) != subList.get(j)) { 658 653 matchFound = false; 659 654 break; -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskComparator.java
r1256 r1285 19 19 import java.util.HashMap; 20 20 21 import de.ugoe.cs.autoquest.eventcore.IEventType;22 21 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 23 22 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;28 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 29 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; … … 39 34 40 35 /** */ 41 private static final int MAX_BUFFER_SIZE = 10* 1024 * 1024;36 private static final int MAX_BUFFER_SIZE = 2 * 1024 * 1024; 42 37 43 38 /** */ … … 79 74 80 75 if (task1 != task2) { 81 if ((task1 instanceof IEventTask) && (task2 instanceof IEventTask)) {76 //if ((task1 instanceof IEventTask) && (task2 instanceof IEventTask)) { 82 77 long key = ((long) System.identityHashCode(task1)) << 32; 83 78 key += System.identityHashCode(task2); … … 92 87 } 93 88 } 94 }89 /*} 95 90 else { 96 91 result = false; 97 } 92 }*/ 98 93 } 99 94 else { … … 118 113 if (result == null) { 119 114 result = lexicalComparer.compare(task1, task2); 120 if (equalityBuffer.size() < 1024 * 1024 * 10) {115 if (equalityBuffer.size() < MAX_BUFFER_SIZE) { 121 116 lexicalEqualityBuffer.put(key, result); 122 117 } … … 130 125 } 131 126 132 /* (non-Javadoc) 133 * @see SymbolComparator#getBucketSearchOrder(Object) 134 */ 135 @Override 136 public int[] getBucketSearchOrder(ITaskInstance taskInstance) { 137 // 0 = sequence; 1 = selection; 2 = iteration; 3 = optional; 4 = event task in general; 138 // other = hashCode of name of event type 139 140 ITask task = taskInstance.getTask(); 141 142 if (task instanceof IEventTask) { 143 // event tasks are most likely equal to those of the event type with the same name, 144 // Afterwards, they may be equal to iterations, optionals, other event tasks, 145 // selections, and finally the rest. 146 IEventType eventType = ((IEventTask) task).getEventType(); 147 return new int[] { eventType.getName().hashCode(), 2, 3, 4, 1 }; 148 } 149 else if (task instanceof ISequence) { 150 return new int[] { 0, 2, 3, 1 }; 151 } 152 else if (task instanceof ISelection) { 153 return new int[] { 1, 4, 2, 3 }; 154 } 155 else if (task instanceof IIteration) { 156 return new int[] { 2, 1, 4 }; 157 } 158 159 return null; 160 } 161 127 /** 128 * <p> 129 * TODO: comment 130 * </p> 131 * 132 */ 133 void clearBuffers() { 134 equalityBuffer.clear(); 135 init(); 136 } 137 162 138 /** 163 139 * … … 275 251 } 276 252 } 253 277 254 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrie.java
r1273 r1285 20 20 import java.util.Map; 21 21 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 23 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; … … 33 34 * @author Patrick Harms 34 35 */ 35 publicclass TaskInstanceTrie extends Trie<ITaskInstance> {36 class TaskInstanceTrie extends Trie<ITaskInstance> { 36 37 37 38 /** */ … … 43 44 * </p> 44 45 */ 45 private Task Comparator comparator;46 46 private TaskHandlingStrategy taskStrategy; 47 47 48 /** 48 49 * <p> … … 52 53 * @param taskComparator2 53 54 */ 54 public TaskInstanceTrie(Task Comparator taskComparator) {55 super(task Comparator);56 this. comparator = taskComparator;55 public TaskInstanceTrie(TaskHandlingStrategy taskStrategy) { 56 super(taskStrategy); 57 this.taskStrategy = taskStrategy; 57 58 } 58 59 … … 65 66 } 66 67 67 SymbolMap<ITaskInstance, List<ITaskInstance>> equalTaskInstancesMap = 68 new SymbolMap<ITaskInstance, List<ITaskInstance>>(comparator); 69 70 Map<ITaskInstance, List<ITaskInstance>> taskInstancesMap = 71 new HashMap<ITaskInstance, List<ITaskInstance>>(); 68 SymbolMap<ITaskInstance, Counter> equalTaskInstancesMap = 69 taskStrategy.createSymbolMap(); 70 71 Map<ITask, Counter> instanceCountMap = new HashMap<ITask, Counter>(); 72 72 73 73 System.out.println("preparing training"); 74 int noOfTaskInstances = 0; 74 75 for (IUserSession session : userSessions) { 75 76 for (ITaskInstance taskInstance : session) { 76 List<ITaskInstance> equalTaskInstances = 77 equalTaskInstancesMap.getValue(taskInstance); 78 79 if (equalTaskInstances == null) { 80 equalTaskInstances = new LinkedList<ITaskInstance>(); 81 equalTaskInstancesMap.addSymbol(taskInstance, equalTaskInstances); 77 Counter counter = equalTaskInstancesMap.getValue(taskInstance); 78 79 if (counter == null) { 80 counter = new Counter(); 81 equalTaskInstancesMap.addSymbol(taskInstance, counter); 82 82 } 83 83 84 equalTaskInstances.add(taskInstance); 85 taskInstancesMap.put(taskInstance, equalTaskInstances); 86 } 87 } 88 89 System.out.println("performing training"); 84 counter.count++; 85 instanceCountMap.put(taskInstance.getTask(), counter); 86 87 noOfTaskInstances++; 88 } 89 } 90 91 System.out.println("performing training of " + noOfTaskInstances + " task instances"); 92 Counter processedTaskInstances = new Counter(); 93 int counterRecheckAt = noOfTaskInstances / 10; // recheck the maximum count after each 94 // 10% of processed task instances 90 95 for (IUserSession session : userSessions) { 91 train(session, maxOrder, taskInstancesMap);96 train(session, maxOrder, instanceCountMap, processedTaskInstances, counterRecheckAt); 92 97 } 93 98 … … 122 127 * 123 128 */ 124 private void train(IUserSession userSession, 125 int maxOrder, 126 Map<ITaskInstance, List<ITaskInstance>> taskInstancesMap) 129 private void train(IUserSession userSession, 130 int maxOrder, 131 Map<ITask, Counter> taskInstanceCountMap, 132 Counter processedTaskInstances, 133 int counterRecheckAt) 127 134 { 128 135 List<ITaskInstance> executedTasks = userSession.getExecutedTasks(); … … 130 137 List<ITaskInstance> subsequence = new LinkedList<ITaskInstance>(); 131 138 132 int numberOfTrainedSubsequences = 0;133 139 int sequenceMaxCount = 0; 134 140 135 141 for (ITaskInstance currentTaskInstance : executedTasks) { 136 int occurrenceCount = taskInstancesMap.get(currentTaskInstance).size(); 137 138 if ((numberOfTrainedSubsequences % 10) == 0) { 142 143 int occurrenceCount = taskInstanceCountMap.get(currentTaskInstance.getTask()).count; 144 145 if (processedTaskInstances.count >= counterRecheckAt) { 139 146 sequenceMaxCount = getCurrentSequenceMaxCount(); 147 processedTaskInstances.count = 0; 140 148 } 141 149 … … 158 166 add(subsequence); 159 167 subsequence.remove(0); 160 161 numberOfTrainedSubsequences++;162 168 } 163 169 } 170 171 processedTaskInstances.count++; 164 172 } 165 173 … … 219 227 } 220 228 229 /** 230 * @author Patrick Harms 231 */ 232 private static class Counter { 233 int count = 0; 234 } 235 221 236 }
Note: See TracChangeset
for help on using the changeset viewer.