Changeset 1891


Ignore:
Timestamp:
03/05/15 11:43:42 (9 years ago)
Author:
pharms
Message:
  • remove support for tasks contexts in value measurements
Location:
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInfo.java

    r1428 r1891  
    5656    /** 
    5757     * <p> 
    58      * returns the value of the measure identified through the given metric if the task is 
    59      * observed in the given context, i.e. parent task. The result is Integer.MIN_VALUE if there 
    60      * is no value for this measure in a context. 
    61      * </p> 
    62      * 
    63      * @param metric  the metric for which the value is to be returned 
    64      * @param context the context for which the measure value is to be returned 
    65      *  
    66      * @return as described 
    67      */ 
    68     public int getMeasureValue(TaskMetric metric, ITask context); 
    69  
    70     /** 
    71      * <p> 
    7258     * represents a measure for a specific metric 
    7359     * </p> 
     
    9581        public int getValue(); 
    9682         
    97         /** 
    98          * <p> 
    99          * returns the value of the measure if the task was observed in a specific context, i.e. 
    100          * parent task 
    101          * </p> 
    102          *  
    103          * @return as described 
    104          */ 
    105         public int getValue(ITask context); 
    106          
    10783    } 
    10884 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInfo.java

    r1428 r1891  
    1616 
    1717import java.util.ArrayList; 
    18 import java.util.HashMap; 
    1918 
    2019import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     
    8988 
    9089    /* (non-Javadoc) 
    91      * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo#getMeasureValue(java.lang.String, de.ugoe.cs.autoquest.tasktrees.treeifc.ITask) 
    92      */ 
    93     @Override 
    94     public int getMeasureValue(TaskMetric metric, ITask context) { 
    95         Measure measure = getMeasure(metric); 
    96          
    97         if (measure == null) { 
    98             throw new IllegalArgumentException("unknown metric " + metric); 
    99         } 
    100          
    101         return measure.getValue(context); 
    102     } 
    103  
    104     /* (non-Javadoc) 
    10590     * @see java.lang.Object#toString() 
    10691     */ 
     
    11297    /** 
    11398     * <p> 
    114      * must be called to indicate that a new new measures for the provided metric are about to 
     99     * must be called to indicate that new measures for the provided metric are about to 
    115100     * be calculated and added. 
    116101     * </p> 
     
    131116    /** 
    132117     * <p> 
    133      * sets a specific value for a measure of a specific metric in the provided context of the task 
     118     * sets a specific value for a measure of a specific metric 
    134119     * </p> 
    135120     *  
    136121     * @param metric  the metric to which the value belongs 
    137      * @param context the context of the task in which the measure was recorded 
    138122     * @param value   the value of the measure 
    139123     */ 
    140     void setCount(TaskMetric metric, ITask context, int value) { 
     124    void setCount(TaskMetric metric, int value) { 
    141125        Measure measure = getMeasure(metric); 
    142126         
     
    146130        } 
    147131         
    148         measure.set(context, value); 
    149     } 
    150  
    151     /** 
    152      * <p> 
    153      * increases a specific value for a measure of a specific metric in the provided context of the 
    154      * task 
     132        measure.set(value); 
     133    } 
     134 
     135    /** 
     136     * <p> 
     137     * increases a specific value for a measure of a specific metric 
    155138     * </p> 
    156139     *  
    157140     * @param metric    the metric to which the value belongs 
    158      * @param context   the context of the task in which the measure was recorded 
    159141     * @param increment the increment to be added to the value of the measure 
    160142     */ 
    161     void increaseCount(TaskMetric metric, ITask context, int increment) { 
     143    void increaseCount(TaskMetric metric, int increment) { 
    162144        Measure measure = getMeasure(metric); 
    163145         
     
    167149        } 
    168150         
    169         measure.increase(context, increment); 
     151        measure.increase(increment); 
    170152    } 
    171153 
     
    204186        /** 
    205187         * <p> 
    206          * the observed values for the difference contexts of the task 
    207          * </p> 
    208          */ 
    209         private HashMap<ITask, Integer> values; 
    210          
    211         /** 
    212          * <p> 
    213          * the context free value of the measure independent of the task context 
    214          * </p> 
    215          */ 
    216         private int contextFreeValue = 0; 
     188         * the value of the measure independent 
     189         * </p> 
     190         */ 
     191        private int value = 0; 
    217192         
    218193        /** 
     
    239214        @Override 
    240215        public int getValue() { 
    241             return contextFreeValue; 
    242         } 
    243  
    244         /* (non-Javadoc) 
    245          * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo.IMeasure#getValue(de.ugoe.cs.autoquest.tasktrees.treeifc.ITask) 
    246          */ 
    247         @Override 
    248         public int getValue(ITask context) { 
    249             if ((context != null) && (values != null)) { 
    250                 Integer currentValue = values.get(context); 
    251                  
    252                 if (currentValue != null) { 
    253                     return currentValue; 
    254                 } 
    255             } 
    256              
    257             return Integer.MIN_VALUE; 
    258         } 
    259  
    260         /** 
    261          * <p> 
    262          * sets the value of the measure context free as well as specific to the provided context 
    263          * </p> 
    264          */ 
    265         private void set(ITask context, int value) { 
    266             contextFreeValue = value; 
    267              
    268             if (context != null) { 
    269                 if (values == null) { 
    270                     values = new HashMap<ITask, Integer>(); 
    271                 } 
    272                  
    273                 values.put(context, value); 
    274             } 
    275         } 
    276  
    277         /** 
    278          * <p> 
    279          * increases the value of the measure context free as well as specific to the provided 
    280          * context according to the provided increment 
    281          * </p> 
    282          */ 
    283         private void increase(ITask context, int increment) { 
    284             contextFreeValue += increment; 
    285              
    286             if (context != null) { 
    287                 if (values == null) { 
    288                     values = new HashMap<ITask, Integer>(); 
    289                 } 
    290                  
    291                 Integer currentValue = values.get(context); 
    292                  
    293                 if (currentValue == null) { 
    294                     currentValue = 0; 
    295                 } 
    296                  
    297                 values.put(context, currentValue + increment); 
    298             } 
     216            return value; 
     217        } 
     218 
     219        /** 
     220         * <p> 
     221         * sets the value of the measure 
     222         * </p> 
     223         */ 
     224        private void set(int newValue) { 
     225            value = newValue; 
     226        } 
     227 
     228        /** 
     229         * <p> 
     230         * increases the value of the measure 
     231         * </p> 
     232         */ 
     233        private void increase(int increment) { 
     234            value += increment; 
    299235        } 
    300236 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInstance.java

    r1405 r1891  
    102102        // task instances are only equal if they are identical or if they have the same id 
    103103        // (may happen, if they are cloned) 
    104         return (this == taskInstance) || (this.hashCode() == taskInstance.hashCode()); 
     104        return (this == taskInstance) || 
     105            ((taskInstance != null) && (this.hashCode() == taskInstance.hashCode())); 
    105106    } 
    106107 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java

    r1494 r1891  
    146146    } 
    147147 
     148    /* (non-Javadoc) 
     149     * @see java.lang.Object#toString() 
     150     */ 
     151    @Override 
     152    public String toString() { 
     153        return "Task Model (" + userSessions.size() + " sessions, " + index.taskMap.size() + 
     154            " tasks, hash " + System.identityHashCode(this) + ")"; 
     155    } 
     156 
    148157    /** 
    149158     * <p> 
     
    158167            for (IUserSession session : this.userSessions) { 
    159168                for (ITaskInstance taskInstance : session) { 
    160                     index.handleTaskInstance(taskInstance, null); 
     169                    index.handleTaskInstance(taskInstance); 
    161170                } 
    162171            } 
     
    187196                 
    188197                eventCoverageRatios[i++] = coverageRatio; 
    189                 info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, null, coverageRatio); 
     198                info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, coverageRatio); 
    190199            } 
    191200             
     
    201210                quantile = 1000 * quantile / eventCoverageRatios.length; 
    202211                 
    203                 info.setCount(TaskMetric.EVENT_COVERAGE_QUANTILE, null, quantile); 
     212                info.setCount(TaskMetric.EVENT_COVERAGE_QUANTILE, quantile); 
    204213            } 
    205214             
     
    242251         * </p> 
    243252         */ 
    244         private int[] handleTaskInstance(ITaskInstance taskInstance, ITask context) { 
     253        private int[] handleTaskInstance(ITaskInstance taskInstance) { 
    245254            int eventTaskInstancesCovered = 0; 
    246255            int depth = 0; 
     
    248257            if (taskInstance instanceof ITaskInstanceList) { 
    249258                for (ITaskInstance child : (ITaskInstanceList) taskInstance) { 
    250                     int[] measures = handleTaskInstance(child, taskInstance.getTask()); 
     259                    int[] measures = handleTaskInstance(child); 
    251260                    eventTaskInstancesCovered += measures[0]; 
    252261                    depth = Math.max(depth, measures[1]); 
     
    257266                { 
    258267                    // ensure also empty task infos for unselected variants 
    259                     ensureTaskInfo(((IIteration) taskInstance.getTask()).getMarkedTask(), context); 
     268                    ensureTaskInfo(((IIteration) taskInstance.getTask()).getMarkedTask()); 
    260269                } 
    261270            } 
    262271            else if (taskInstance instanceof ISelectionInstance) { 
    263272                ITaskInstance child = ((ISelectionInstance) taskInstance).getChild(); 
    264                 int[] measures = handleTaskInstance(child, taskInstance.getTask()); 
     273                int[] measures = handleTaskInstance(child); 
    265274                eventTaskInstancesCovered += measures[0]; 
    266275                depth = Math.max(depth, measures[1]); 
     
    268277                // ensure also empty task infos for unselected variants 
    269278                for (ITask otherChildTask : ((ISelection) taskInstance.getTask()).getChildren()) { 
    270                     ensureTaskInfo(otherChildTask, context); 
     279                    ensureTaskInfo(otherChildTask); 
    271280                } 
    272281            } 
     
    274283                ITaskInstance child = ((IOptionalInstance) taskInstance).getChild(); 
    275284                if (child != null) { 
    276                     int[] measures = handleTaskInstance(child, taskInstance.getTask()); 
     285                    int[] measures = handleTaskInstance(child); 
    277286                    eventTaskInstancesCovered += measures[0]; 
    278287                    depth = Math.max(depth, measures[1]); 
     
    280289                else { 
    281290                    // ensure also empty task infos for unselected variants 
    282                     ensureTaskInfo(((IOptional) taskInstance.getTask()).getMarkedTask(), context); 
     291                    ensureTaskInfo(((IOptional) taskInstance.getTask()).getMarkedTask()); 
    283292                } 
    284293            } 
     
    289298            depth++; 
    290299             
    291             ensureTaskInfo(taskInstance.getTask(), context, eventTaskInstancesCovered, depth); 
     300            ensureTaskInfo(taskInstance.getTask(), eventTaskInstancesCovered, depth); 
    292301             
    293302            return new int[] { eventTaskInstancesCovered, depth }; 
     
    299308         * </p> 
    300309         */ 
    301         private void ensureTaskInfo(ITask task, ITask context) { 
    302             ensureTaskInfo(task, context, 0, 0); 
     310        private void ensureTaskInfo(ITask task) { 
     311            ensureTaskInfo(task, 0, 0); 
    303312             
    304313            if (task instanceof IStructuringTemporalRelationship) { 
    305314                for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 
    306                     ensureTaskInfo(child, task); 
     315                    ensureTaskInfo(child); 
    307316                } 
    308317            } 
    309318            else if (task instanceof IMarkingTemporalRelationship) { 
    310                 ensureTaskInfo(((IMarkingTemporalRelationship) task).getMarkedTask(), task); 
     319                ensureTaskInfo(((IMarkingTemporalRelationship) task).getMarkedTask()); 
    311320            } 
    312321         
     
    322331         */ 
    323332        private void ensureTaskInfo(ITask task, 
    324                                     ITask context, 
    325333                                    int   eventTaskInstancesCovered, 
    326334                                    int   depth) 
     
    335343                taskMap.put(task, taskInfo); 
    336344                 
    337                 taskInfo.setCount(TaskMetric.DEPTH, null, getDepth(task)); 
    338             } 
    339  
    340             taskInfo.increaseCount(TaskMetric.COUNT, context, 1); 
    341             taskInfo.increaseCount(TaskMetric.EVENT_COVERAGE, context, eventTaskInstancesCovered); 
    342  
    343             taskInfo.setCount(TaskMetric.DEPTH, context, depth); 
     345                taskInfo.setCount(TaskMetric.DEPTH, getDepth(task)); 
     346            } 
     347 
     348            taskInfo.increaseCount(TaskMetric.COUNT, 1); 
     349            taskInfo.increaseCount(TaskMetric.EVENT_COVERAGE, eventTaskInstancesCovered); 
     350 
     351            taskInfo.setCount(TaskMetric.DEPTH, depth); 
    344352        } 
    345353 
Note: See TracChangeset for help on using the changeset viewer.