Ignore:
Timestamp:
02/26/14 17:12:53 (11 years ago)
Author:
pharms
Message:
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  
    9898        } 
    9999 
    100  
    101100        taskBuilder.addTaskInstance(parent, startIndex, subsequence); 
    102101 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java

    r1356 r1401  
    3838import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    3939import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; 
     40import de.ugoe.cs.autoquest.usageprofiles.Trie; 
    4041import de.ugoe.cs.autoquest.usageprofiles.TrieProcessor; 
    4142import de.ugoe.cs.util.StopWatch; 
     
    4445/** 
    4546 * <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.  
    4759 * </p> 
    4860 *  
     
    5466     * <p> 
    5567     * the task factory to be used for creating substructures for the temporal 
    56      * relationships identified during rule 
     68     * relationships identified during rul application 
    5769     * </p> 
    5870     */ 
     
    6880    /** 
    6981     * <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 
    7184     * </p> 
    7285     */ 
     
    7588    /** 
    7689     * <p> 
    77      * the task comparator to be used for comparing tasks during iteration detection an trie 
    78      * 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  
    7992     * </p> 
    8093     */ 
     
    8396    /** 
    8497     * <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. 
    87101     * </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 
    88106     */ 
    89107    SequenceForTaskDetectionRule(TaskEquality minimalTaskEquality, 
     
    151169    /** 
    152170     * <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. 
    154175     * </p> 
    155176     * 
    156      * @param appData 
     177     * @param appData the rule application data combining all data used for applying this rule 
    157178     */ 
    158179    private void harmonizeEventTaskInstancesModel(RuleApplicationData appData) { 
     
    194215 
    195216    /** 
    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 
    197225     */ 
    198226    private void detectAndReplaceIterations(RuleApplicationData appData) { 
     
    213241 
    214242    /** 
    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 
    216251     */ 
    217252    private Set<ITask> searchIteratedTasks(List<IUserSession> sessions) { 
     
    232267 
    233268    /** 
     269     * <p> 
     270     * replaces all occurrences of all tasks provided in the set with iterations 
     271     * </p> 
    234272     * 
     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 
    235276     */ 
    236277    private void replaceIterationsOf(Set<ITask>          iteratedTasks, 
     
    288329 
    289330    /** 
    290      * 
     331     * <p> 
     332     * TODO clarify why this is done 
     333     * </p> 
    291334     */ 
    292335    private void harmonizeIterationInstancesModel(IIteration               iteration, 
     
    345388 
    346389    /** 
    347      * @param appData 
     390     * TODO go on commenting 
     391     * @param appData the rule application data combining all data used for applying this rule 
    348392     */ 
    349393    private void detectAndReplaceTasks(RuleApplicationData appData) { 
     
    365409 
    366410    /** 
    367      * @return 
     411     * @param appData the rule application data combining all data used for applying this rule 
    368412     */ 
    369413    private void getSequencesOccuringMostOften(RuleApplicationData appData) { 
     
    462506 
    463507    /** 
    464      * @param parent 
    465      * @return 
     508     * @param appData the rule application data combining all data used for applying this rule 
    466509     */ 
    467510    private void createNewTrie(RuleApplicationData appData) { 
     
    483526 
    484527    /** 
    485      * @param appData 
     528     * @param appData the rule application data combining all data used for applying this rule 
    486529     */ 
    487530    private void replaceSequencesOccurringMostOften(RuleApplicationData appData) { 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskHandlingStrategy.java

    r1394 r1401  
    1717import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
    1818import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
    19 import de.ugoe.cs.autoquest.usageprofiles.DefaultSymbolMap; 
    2019import de.ugoe.cs.autoquest.usageprofiles.SymbolComparator; 
    2120import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; 
     
    2423/** 
    2524 * <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. 
    2730 * </p> 
    2831 *  
     
    3538 
    3639    /** 
    37      *  
     40     * <p> 
     41     * the level of task equality considered in this task handling strategy 
     42     * </p> 
    3843     */ 
    3944    private TaskEquality consideredEquality; 
    4045 
    4146    /** 
    42      *  
     47     * <p> 
     48     * the comparator used for task comparisons 
     49     * </p> 
    4350     */ 
    4451    private TaskInstanceComparator comparator; 
     
    4653    /** 
    4754     * <p> 
    48      * TODO: comment 
     55     * initializes this strategy with a task equality to be considered for task comparisons 
    4956     * </p> 
    5057     * 
    51      * @param consideredEquality 
     58     * @param consideredEquality the task equality to be considered for task comparisons 
    5259     */ 
    5360    public TaskHandlingStrategy(TaskEquality consideredEquality) { 
     
    7279    /** 
    7380     * <p> 
    74      * TODO: comment 
     81     * convenience method to have a correctly typed return value as alternative to 
     82     * {@link #getSymbolComparator()}; 
    7583     * </p> 
    76      * 
    77      * @return 
    7884     */ 
    7985    public TaskInstanceComparator getTaskComparator() { 
     
    95101 
    96102    /* (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) 
    98104     */ 
    99105    @Override 
    100106    public <V> SymbolMap<ITaskInstance, V> copySymbolMap(SymbolMap<ITaskInstance, V> other) { 
    101107        if (consideredEquality == TaskEquality.IDENTICAL) { 
    102             return new DefaultSymbolMap<ITaskInstance, V>(other); 
     108            return new TaskSymbolIdentityMap<V>(other); 
    103109        } 
    104110        else { 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskIdentityComparator.java

    r1294 r1401  
    1919 
    2020/** 
    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> 
    2225 */ 
    2326class TaskIdentityComparator extends TaskInstanceComparator { 
     
    2831    /** 
    2932     * <p> 
    30      * TODO: comment 
     33     * initializes the parent class with the task equality {@link TaskEquality#IDENTICAL}. 
    3134     * </p> 
    32      * 
    33      * @param minimalNodeEquality 
    3435     */ 
    3536    public TaskIdentityComparator() { 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceComparator.java

    r1394 r1401  
    2626 
    2727/** 
    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> 
    2935 */ 
    3036public class TaskInstanceComparator implements SymbolComparator<ITaskInstance> { 
     
    3339    private static final long serialVersionUID = 1L; 
    3440     
    35     /** */ 
     41    /** 
     42     * the maximum size of the internal buffer used for storing comparison results 
     43     */ 
    3644    private static final int MAX_BUFFER_SIZE = 2 * 1024 * 1024; 
    3745 
    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     */ 
    4254    private transient Comparer comparer; 
    4355 
    44     /** */ 
     56    /** 
     57     * the comparer used for comparing two tasks on the lexical level 
     58     */ 
    4559    private transient Comparer lexicalComparer; 
    4660 
    47     /** */ 
     61    /** 
     62     * internal buffer used for storing comparison results 
     63     */ 
    4864    private transient HashMap<Long, Boolean> equalityBuffer = new HashMap<Long, Boolean>(); 
    4965 
    50     /** */ 
     66    /** 
     67     * internal buffer used for storing comparison results only for lexical comparisons 
     68     */ 
    5169    private transient HashMap<Long, Boolean> lexicalEqualityBuffer; 
    5270 
    5371    /** 
    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; 
    5880        init(); 
    5981    } 
     
    6890 
    6991    /** 
    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 
    71100     */ 
    72101    public boolean equals(ITask task1, ITask task2) { 
     
    100129 
    101130    /** 
    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 
    103139     */ 
    104140    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     
    127163    /** 
    128164     * <p> 
    129      * TODO: comment 
    130      * </p> 
    131      * 
     165     * can be called externally to clear the internal comparison buffers 
     166     * </p> 
    132167     */ 
    133168    public void clearBuffers() { 
     
    137172     
    138173    /** 
    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> 
    140179     */ 
    141180    private void init() { 
    142         if (minimalNodeEquality == TaskEquality.LEXICALLY_EQUAL) { 
     181        if (minimalTaskEquality == TaskEquality.LEXICALLY_EQUAL) { 
    143182            comparer = new LexicalComparer(); 
    144183        } 
    145         else if (minimalNodeEquality == TaskEquality.SYNTACTICALLY_EQUAL) { 
     184        else if (minimalTaskEquality == TaskEquality.SYNTACTICALLY_EQUAL) { 
    146185            comparer = new SyntacticalComparer(); 
    147186        } 
    148         else if (minimalNodeEquality == TaskEquality.SEMANTICALLY_EQUAL) { 
     187        else if (minimalTaskEquality == TaskEquality.SEMANTICALLY_EQUAL) { 
    149188            comparer = new SemanticalComparer(); 
    150189        } 
    151190        else { 
    152             comparer = new DefaultComparer(this.minimalNodeEquality); 
    153         } 
    154          
    155         if (minimalNodeEquality == TaskEquality.LEXICALLY_EQUAL) { 
     191            comparer = new DefaultComparer(this.minimalTaskEquality); 
     192        } 
     193         
     194        if (minimalTaskEquality == TaskEquality.LEXICALLY_EQUAL) { 
    156195            lexicalComparer = comparer; 
    157196            lexicalEqualityBuffer = equalityBuffer; 
     
    175214 
    176215    /** 
    177      *  
     216     * <p> 
     217     * interface for internally used comparers containing only a compare method 
     218     * </p> 
    178219     */ 
    179220    private static interface Comparer { 
    180221         
    181222        /** 
     223         * <p> 
     224         * returns true, if this comparator considers the provided tasks as equal, false else 
     225         * </p> 
    182226         *  
     227         * @param task1 the first task to compare 
     228         * @param task2 the second task to compare 
     229         *  
     230         * @return as described 
    183231         */ 
    184232        boolean compare(ITask task1, ITask task2); 
     
    186234 
    187235    /** 
    188      *  
     236     * <p> 
     237     * comparer that performs comparisons only on the lexical level 
     238     * </p> 
    189239     */ 
    190240    private static class LexicalComparer implements Comparer { 
    191241         
    192         /** 
    193          *  
     242        /* (non-Javadoc) 
     243         * @see Comparer#compare(ITask, ITask) 
    194244         */ 
    195245        public boolean compare(ITask task1, ITask task2) { 
     
    199249 
    200250    /** 
     251     * <p> 
     252     * comparer that performs comparisons only on the syntactical level 
     253     * </p> 
    201254     *  
    202255     */ 
    203256    private static class SyntacticalComparer implements Comparer { 
    204257         
    205         /** 
    206          *  
     258        /* (non-Javadoc) 
     259         * @see Comparer#compare(ITask, ITask) 
    207260         */ 
    208261        public boolean compare(ITask task1, ITask task2) { 
     
    212265 
    213266    /** 
    214      *  
     267     * <p> 
     268     * comparer that performs comparisons only on the semantical level 
     269     * </p> 
    215270     */ 
    216271    private static class SemanticalComparer implements Comparer { 
    217272         
    218         /** 
    219          *  
     273        /* (non-Javadoc) 
     274         * @see Comparer#compare(ITask, ITask) 
    220275         */ 
    221276        public boolean compare(ITask task1, ITask task2) { 
     
    225280 
    226281    /** 
    227      *  
     282     * <p> 
     283     * comparer that performs comparisons only on the provided level 
     284     * </p> 
    228285     */ 
    229286    private static class DefaultComparer implements Comparer { 
     
    231288        /** 
    232289         * <p> 
    233          * the minimal task equality two identified sublists need to have to consider them as equal 
     290         * the minimal task equality considered by this comparer 
    234291         * </p> 
    235292         */ 
    236         private TaskEquality minimalNodeEquality; 
     293        private TaskEquality minimalTaskEquality; 
    237294         
    238295        /** 
    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) 
    247306         */ 
    248307        public boolean compare(ITask task1, ITask task2) { 
    249308            return TaskEqualityRuleManager.getInstance().areAtLeastEqual 
    250                 (task1, task2, minimalNodeEquality); 
     309                (task1, task2, minimalTaskEquality); 
    251310        } 
    252311    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrie.java

    r1285 r1401  
    2929/** 
    3030 * <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. 
    3237 * </p> 
    3338 *  
     
    4146    /** 
    4247     * <p> 
    43      * the task comparator to be used for comparing tasks 
     48     * the task handling strategy to be used for comparing tasks 
    4449     * </p> 
    4550     */ 
     
    4853    /** 
    4954     * <p> 
    50      * TODO: comment 
     55     * instantiated the trie with the task handling strategy to be used 
    5156     * </p> 
    5257     * 
    53      * @param taskComparator2 
     58     * @param taskStrategy the task handling strategy to be used for comparing tasks 
    5459     */ 
    5560    public TaskInstanceTrie(TaskHandlingStrategy taskStrategy) { 
     
    5964 
    6065    /** 
    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 
    6273     */ 
    6374    public void trainSessions(List<IUserSession> userSessions, int maxOrder) { 
     
    125136 
    126137    /** 
    127      *  
     138     * <p> 
     139     * internally used convenience method for implementing the training optimization 
     140     * </p> 
    128141     */ 
    129142    private void train(IUserSession        userSession, 
     
    133146                       int                 counterRecheckAt) 
    134147    { 
    135         List<ITaskInstance> executedTasks = userSession.getExecutedTasks(); 
    136          
    137148        List<ITaskInstance> subsequence = new LinkedList<ITaskInstance>(); 
    138149         
    139150        int sequenceMaxCount = 0; 
    140151         
    141         for (ITaskInstance currentTaskInstance : executedTasks) { 
     152        for (ITaskInstance currentTaskInstance : userSession) { 
    142153             
    143154            int occurrenceCount = taskInstanceCountMap.get(currentTaskInstance.getTask()).count; 
     
    181192    /** 
    182193     * <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 
    184196     * </p> 
    185197     * 
    186      * @return 
     198     * @return the current maximum count of sequences of a minimal length of two 
    187199     */ 
    188200    private int getCurrentSequenceMaxCount() { 
     
    193205 
    194206    /** 
     207     * <p> 
     208     * trie processor identifying the current maximum count of sequences of a minimal length of two 
     209     * </p> 
     210     *  
    195211     * @author Patrick Harms 
    196212     */ 
     
    198214         
    199215        /** 
    200          *  
     216         * <p> 
     217         * the current maximum count 
     218         * </p> 
    201219         */ 
    202220        private int currentCount = 0; 
     
    219237 
    220238        /** 
    221          *  
     239         * <p> 
     240         * returns the current maximum count 
     241         * </p> 
    222242         */ 
    223243        private int getMaxCount() { 
     
    228248     
    229249    /** 
     250     * <p> 
     251     * counter object to be able to call something by the counters reference 
     252     * </p> 
     253     *  
    230254     * @author Patrick Harms 
    231255     */ 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolIdentityMap.java

    r1285 r1401  
    2525/** 
    2626 * <p> 
    27  * TODO comment 
     27 * symbol map implementation for task instances considering two task instances as equal if their 
     28 * tasks are identical 
    2829 * </p> 
    2930 *  
     
    3637 
    3738    /** 
    38      *  
     39     * <p> 
     40     * internally used map for implementing the symbol map interface 
     41     * </p> 
    3942     */ 
    4043    private Map<ITask, V> delegate; 
    4144 
    4245    /** 
    43      *  
     46     * <p> 
     47     * mapping between the tasks and the real symbols stored in the map, i.e. the task instances 
     48     * </p> 
    4449     */ 
    4550    private Map<ITask, ITaskInstance> symbols; 
     
    4752    /** 
    4853     * <p> 
    49      * TODO: comment 
     54     * initializes this map 
    5055     * </p> 
    51      * 
    52      * @param other 
    5356     */ 
    5457    public TaskSymbolIdentityMap() { 
     
    5962    /** 
    6063     * <p> 
    61      * TODO: comment 
     64     * copy constructor 
    6265     * </p> 
    6366     * 
    64      * @param other 
     67     * @param other the map to be copied 
    6568     */ 
    6669    public TaskSymbolIdentityMap(SymbolMap<ITaskInstance, V> other) { 
Note: See TracChangeset for help on using the changeset viewer.