Ignore:
Timestamp:
07/30/13 09:44:39 (11 years ago)
Author:
pharms
Message:
  • improved performance of task instance trie generation by using different symbol management strategies while creating the trie. This performance improvement is significant and allows to detect tasks now in a much faster manner.
Location:
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManagerTest.java

    r1146 r1285  
    285285        } 
    286286 
    287         new TaskTreeChecker().assertTaskInstanceList 
     287        new TaskTreeChecker(true).assertTaskInstanceList 
    288288            ("UserSession session {" + 
    289289             "  Iteration iteration2 {" + 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrieTest.java

    r1256 r1285  
    3737 
    3838/** 
    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>. 
    4041 *  
    41  * @author Steffen Herbold 
     42 * @author Patrick Harms 
    4243 * @version 1.0 
    4344 */ 
     
    5455     
    5556    /** */ 
    56     private TaskComparator comparator = new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL); 
     57    private TaskHandlingStrategy strategy = 
     58        new TaskHandlingStrategy(TaskEquality.IDENTICAL); 
    5759     
    5860    /** */ 
     
    8486    @Test 
    8587    public void testTaskInstanceTaskInstanceTrie_1() throws Exception { 
    86         TaskInstanceTrie result = new TaskInstanceTrie(comparator); 
     88        TaskInstanceTrie result = new TaskInstanceTrie(strategy); 
    8789 
    8890        assertNotNull(result); 
     
    9597    @Test(expected = java.lang.IllegalArgumentException.class) 
    9698    public void testTaskInstanceTrie_2() throws Exception { 
    97         new TaskInstanceTrie((TaskComparator) null); 
     99        new TaskInstanceTrie((TaskHandlingStrategy) null); 
    98100    } 
    99101 
    100102    @Test 
    101103    public void testTrainSessions_1() throws Exception { 
    102         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     104        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    103105         
    104106        IUserSession session = (IUserSession) decoder.decode 
     
    136138    @Test 
    137139    public void testTrainSessions_2() throws Exception { 
    138         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     140        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    139141         
    140142        IUserSession session = (IUserSession) decoder.decode 
     
    167169    @Test 
    168170    public void testTrainSessions_3() throws Exception { 
    169         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     171        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    170172         
    171173        IUserSession session = (IUserSession) decoder.decode 
     
    199201    @Test 
    200202    public void testTrainSessions_4() throws Exception { 
    201         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     203        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    202204         
    203205        IUserSession session = (IUserSession) decoder.decode 
     
    240242    @Test 
    241243    public void testTrainSessions_5() throws Exception { 
    242         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     244        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    243245         
    244246        IUserSession session = (IUserSession) decoder.decode 
     
    276278    @Test 
    277279    public void testTrainSessions_6() throws Exception { 
    278         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     280        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    279281         
    280282        IUserSession session = (IUserSession) decoder.decode 
     
    313315    @Test 
    314316    public void testTrainSessions_7() throws Exception { 
    315         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     317        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    316318         
    317319        IUserSession session = (IUserSession) decoder.decode 
     
    354356    @Test 
    355357    public void testTrainSessions_8() throws Exception { 
    356         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     358        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    357359         
    358360        IUserSession session = (IUserSession) decoder.decode 
     
    390392    @Test 
    391393    public void testTrainSessions_9() throws Exception { 
    392         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     394        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    393395         
    394396        IUserSession session = (IUserSession) decoder.decode 
     
    428430    @Test 
    429431    public void testGetSequencesWithMostOccurrences_1() throws Exception { 
    430         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     432        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    431433         
    432434        fixture.trainSessions(Arrays.asList(session), 3); 
     
    445447    @Test 
    446448    public void testGetSequencesWithMostOccurrences_2() throws Exception { 
    447         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     449        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    448450         
    449451        fixture.trainSessions(Arrays.asList(session), 3); 
     
    510512    @Test 
    511513    public void testGetSequencesWithMostOccurrences_3() throws Exception { 
    512         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     514        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    513515             
    514516        fixture.trainSessions(Arrays.asList(session), 3); 
     
    554556    @Test 
    555557    public void testGetSequencesWithMostOccurrences_4() throws Exception { 
    556         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     558        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    557559                 
    558560        fixture.trainSessions(Arrays.asList(session), 3); 
     
    566568    @Test 
    567569    public void testGetSequencesWithMostOccurrences_5() throws Exception { 
    568         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     570        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    569571                 
    570572        fixture.trainSessions(Arrays.asList(session), 3); 
     
    583585    @Test 
    584586    public void testGetSequencesWithMostOccurrences_6() throws Exception { 
    585         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     587        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    586588                 
    587589        fixture.trainSessions(Arrays.asList(session), 3); 
     
    596598    @Test 
    597599    public void testGetSequencesWithMostOccurrences_7() throws Exception { 
    598         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     600        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    599601                 
    600602        fixture.trainSessions(Arrays.asList(session), 3); 
     
    629631    @Test 
    630632    public void testGetSequencesWithMostOccurrences_8() throws Exception { 
    631         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     633        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    632634             
    633635        fixture.trainSessions(Arrays.asList(session), 3); 
     
    688690    @Test 
    689691    public void testGetSequencesWithMostOccurrences_9() throws Exception { 
    690         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     692        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    691693             
    692694        fixture.trainSessions(Arrays.asList(session), 3); 
     
    726728    @Test 
    727729    public void testGetSequencesWithMostOccurrences_10() throws Exception { 
    728         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     730        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    729731                
    730732        fixture.trainSessions(Arrays.asList(session), 3); 
     
    738740    @Test 
    739741    public void testGetSequencesWithMostOccurrences_11() throws Exception { 
    740         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     742        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    741743                 
    742744        fixture.trainSessions(Arrays.asList(session), 3); 
     
    762764    @Test 
    763765    public void testGetSequencesWithMostOccurrences_12() throws Exception { 
    764         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     766        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    765767                 
    766768        fixture.trainSessions(Arrays.asList(session), 3); 
     
    809811    @Test 
    810812    public void testGetSequencesWithMostOccurrences_13() throws Exception { 
    811         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     813        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    812814                 
    813815        fixture.trainSessions(Arrays.asList(session), 3); 
     
    822824    @Test 
    823825    public void testGetSequencesWithMostOccurrences_14() throws Exception { 
    824         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     826        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    825827                     
    826828        fixture.trainSessions(Arrays.asList(session), 3); 
     
    835837    @Test 
    836838    public void testGetCount_1() throws Exception { 
    837         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     839        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    838840                         
    839841        fixture.trainSessions(Arrays.asList(session), 3); 
     
    850852    @Test 
    851853    public void testGetCount_2() throws Exception { 
    852         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     854        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    853855                             
    854856        fixture.trainSessions(Arrays.asList(session), 3); 
     
    865867    @Test 
    866868    public void testGetCount_3() throws Exception { 
    867         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     869        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    868870                             
    869871        fixture.trainSessions(Arrays.asList(session), 3); 
     
    879881    @Test 
    880882    public void testGetCount_4() throws Exception { 
    881         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     883        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    882884                             
    883885        fixture.trainSessions(Arrays.asList(session), 3); 
     
    893895    @Test 
    894896    public void testGetCount_5() throws Exception { 
    895         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     897        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    896898                                 
    897899        fixture.trainSessions(Arrays.asList(session), 3); 
     
    908910    @Test 
    909911    public void testGetCount_6() throws Exception { 
    910         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     912        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    911913                                 
    912914        fixture.trainSessions(Arrays.asList(session), 3); 
     
    922924    @Test 
    923925    public void testGetFollowingSymbols_1() throws Exception { 
    924         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     926        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    925927                                     
    926928        fixture.trainSessions(Arrays.asList(session), 3); 
     
    940942    @Test 
    941943    public void testGetFollowingSymbols_2() throws Exception { 
    942         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     944        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    943945                                         
    944946        fixture.trainSessions(Arrays.asList(session), 3); 
     
    956958    @Test 
    957959    public void testGetFollowingSymbols_3() throws Exception { 
    958         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     960        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    959961                                         
    960962        fixture.trainSessions(Arrays.asList(session), 3); 
     
    970972    @Test 
    971973    public void testGetNumLeafAncestors_1() throws Exception { 
    972         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     974        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    973975                                             
    974976        fixture.trainSessions(Arrays.asList(session), 3); 
     
    981983    @Test 
    982984    public void testGetNumLeafs_1() throws Exception { 
    983         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     985        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    984986                                             
    985987        fixture.trainSessions(Arrays.asList(session), 3); 
     
    992994    @Test 
    993995    public void testGetNumSymbols_1() throws Exception { 
    994         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     996        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    995997                                             
    996998        fixture.trainSessions(Arrays.asList(session), 3); 
     
    10041006    @Test 
    10051007    public void testLargeTaskInstanceTrie_1() throws Exception { 
    1006         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1008        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    10071009 
    10081010        int order = 2; 
     
    10241026    @Test 
    10251027    public void testLargeTaskInstanceTrie_2() throws Exception { 
    1026         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1028        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    10271029 
    10281030        int order = 2; 
     
    10441046    @Test 
    10451047    public void testLargeTaskInstanceTrie_3() throws Exception { 
    1046         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1048        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    10471049 
    10481050        int order = 2; 
     
    10641066    @Test 
    10651067    public void testLargeTaskInstanceTrie_4() throws Exception { 
    1066         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1068        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    10671069 
    10681070        int order = 2; 
     
    10841086    @Test 
    10851087    public void testLargeTaskInstanceTrie_5() throws Exception { 
    1086         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1088        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    10871089 
    10881090        int order = 2; 
     
    11041106    @Test 
    11051107    public void testLargeTaskInstanceTrie_6() throws Exception { 
    1106         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1108        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    11071109 
    11081110        int order = 3; 
     
    11241126    @Test 
    11251127    public void testLargeTaskInstanceTrie_7() throws Exception { 
    1126         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1128        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    11271129 
    11281130        int order = 3; 
     
    11441146    @Test 
    11451147    public void testLargeTaskInstanceTrie_8() throws Exception { 
    1146         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1148        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    11471149 
    11481150        int order = 3; 
     
    11641166    @Test 
    11651167    public void testLargeTaskInstanceTrie_9() throws Exception { 
    1166         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1168        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    11671169 
    11681170        int order = 3; 
     
    11841186    @Test 
    11851187    public void testLargeTaskInstanceTrie_10() throws Exception { 
    1186         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1188        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    11871189 
    11881190        int order = 3; 
     
    12041206    @Test 
    12051207    public void testLargeTaskInstanceTrie_11() throws Exception { 
    1206         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1208        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    12071209 
    12081210        int order = 4; 
     
    12241226    @Test 
    12251227    public void testLargeTaskInstanceTrie_12() throws Exception { 
    1226         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1228        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    12271229 
    12281230        int order = 4; 
     
    12441246    @Test 
    12451247    public void testLargeTaskInstanceTrie_13() throws Exception { 
    1246         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1248        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    12471249 
    12481250        int order = 4; 
     
    12641266    @Test 
    12651267    public void testLargeTaskInstanceTrie_14() throws Exception { 
    1266         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1268        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    12671269 
    12681270        int order = 4; 
     
    12841286    @Test 
    12851287    public void testLargeTaskInstanceTrie_15() throws Exception { 
    1286         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1288        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    12871289 
    12881290        int order = 4; 
     
    13041306    @Test 
    13051307    public void testLargeTaskInstanceTrie_16() throws Exception { 
    1306         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1308        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    13071309 
    13081310        int order = 5; 
     
    13241326    @Test 
    13251327    public void testLargeTaskInstanceTrie_17() throws Exception { 
    1326         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1328        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    13271329 
    13281330        int order = 5; 
     
    13441346    @Test 
    13451347    public void testLargeTaskInstanceTrie_18() throws Exception { 
    1346         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1348        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    13471349 
    13481350        int order = 5; 
     
    13641366    @Test 
    13651367    public void testLargeTaskInstanceTrie_19() throws Exception { 
    1366         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1368        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    13671369 
    13681370        int order = 5; 
     
    13841386    @Test 
    13851387    public void testLargeTaskInstanceTrie_20() throws Exception { 
    1386         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1388        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    13871389 
    13881390        int order = 5; 
     
    14041406    @Test 
    14051407    public void testLargeTaskInstanceTrie_21() throws Exception { 
    1406         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1408        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    14071409 
    14081410        int order = 6; 
     
    14241426    @Test 
    14251427    public void testLargeTaskInstanceTrie_22() throws Exception { 
    1426         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1428        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    14271429 
    14281430        int order = 6; 
     
    14441446    @Test 
    14451447    public void testLargeTaskInstanceTrie_23() throws Exception { 
    1446         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1448        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    14471449 
    14481450        int order = 6; 
     
    14641466    @Test 
    14651467    public void testLargeTaskInstanceTrie_24() throws Exception { 
    1466         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1468        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    14671469 
    14681470        int order = 6; 
     
    14841486    @Test 
    14851487    public void testLargeTaskInstanceTrie_25() throws Exception { 
    1486         TaskInstanceTrie fixture = new TaskInstanceTrie(comparator); 
     1488        TaskInstanceTrie fixture = new TaskInstanceTrie(strategy); 
    14871489 
    14881490        int order = 6; 
     
    14931495        fixture.trainSessions(Arrays.asList(tester.userSession), order); 
    14941496        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 " + 
    14951517                           (System.currentTimeMillis() - start) + "ms"); 
    14961518         
     
    15131535                found = true; 
    15141536                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))) { 
    15161538                        found = false; 
    15171539                        break; 
     
    16601682                 
    16611683                for (Map.Entry<Integer, ITaskInstance> entry : symbols.entrySet()) { 
    1662                     if (comparator.equals(entry.getValue(), symbol)) { 
     1684                    if (strategy.getTaskComparator().equals(entry.getValue(), symbol)) { 
    16631685                        symbolIndex = entry.getKey(); 
    16641686                        break; 
Note: See TracChangeset for help on using the changeset viewer.