Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrie.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrie.java	(revision 1273)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrie.java	(revision 1285)
@@ -20,4 +20,5 @@
 import java.util.Map;
 
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession;
@@ -33,5 +34,5 @@
  * @author Patrick Harms
  */
-public class TaskInstanceTrie extends Trie<ITaskInstance> {
+class TaskInstanceTrie extends Trie<ITaskInstance> {
 
     /**  */
@@ -43,6 +44,6 @@
      * </p>
      */
-    private TaskComparator comparator;
-
+    private TaskHandlingStrategy taskStrategy;
+    
     /**
      * <p>
@@ -52,7 +53,7 @@
      * @param taskComparator2
      */
-    public TaskInstanceTrie(TaskComparator taskComparator) {
-        super(taskComparator);
-        this.comparator = taskComparator;
+    public TaskInstanceTrie(TaskHandlingStrategy taskStrategy) {
+        super(taskStrategy);
+        this.taskStrategy = taskStrategy;
     }
 
@@ -65,29 +66,33 @@
         }
         
-        SymbolMap<ITaskInstance, List<ITaskInstance>> equalTaskInstancesMap =
-            new SymbolMap<ITaskInstance, List<ITaskInstance>>(comparator);
-        
-        Map<ITaskInstance, List<ITaskInstance>> taskInstancesMap =
-            new HashMap<ITaskInstance, List<ITaskInstance>>();
+        SymbolMap<ITaskInstance, Counter> equalTaskInstancesMap =
+            taskStrategy.createSymbolMap();
+        
+        Map<ITask, Counter> instanceCountMap = new HashMap<ITask, Counter>();
         
         System.out.println("preparing training");
+        int noOfTaskInstances = 0;
         for (IUserSession session : userSessions) {
             for (ITaskInstance taskInstance : session) {
-                List<ITaskInstance> equalTaskInstances =
-                    equalTaskInstancesMap.getValue(taskInstance);
-                
-                if (equalTaskInstances == null) {
-                    equalTaskInstances = new LinkedList<ITaskInstance>();
-                    equalTaskInstancesMap.addSymbol(taskInstance, equalTaskInstances);
+                Counter counter = equalTaskInstancesMap.getValue(taskInstance);
+                
+                if (counter == null) {
+                    counter = new Counter();
+                    equalTaskInstancesMap.addSymbol(taskInstance, counter);
                 }
                 
-                equalTaskInstances.add(taskInstance);
-                taskInstancesMap.put(taskInstance, equalTaskInstances);
-            }
-        }
-        
-        System.out.println("performing training");
+                counter.count++;
+                instanceCountMap.put(taskInstance.getTask(), counter);
+                
+                noOfTaskInstances++;
+            }
+        }
+        
+        System.out.println("performing training of " + noOfTaskInstances + " task instances");
+        Counter processedTaskInstances = new Counter();
+        int counterRecheckAt = noOfTaskInstances / 10; // recheck the maximum count after each
+                                                       // 10% of processed task instances
         for (IUserSession session : userSessions) {
-            train(session, maxOrder, taskInstancesMap);
+            train(session, maxOrder, instanceCountMap, processedTaskInstances, counterRecheckAt);
         }      
         
@@ -122,7 +127,9 @@
      * 
      */
-    private void train(IUserSession                            userSession,
-                       int                                     maxOrder,
-                       Map<ITaskInstance, List<ITaskInstance>> taskInstancesMap)
+    private void train(IUserSession        userSession,
+                       int                 maxOrder,
+                       Map<ITask, Counter> taskInstanceCountMap,
+                       Counter             processedTaskInstances,
+                       int                 counterRecheckAt)
     {
         List<ITaskInstance> executedTasks = userSession.getExecutedTasks();
@@ -130,12 +137,13 @@
         List<ITaskInstance> subsequence = new LinkedList<ITaskInstance>();
         
-        int numberOfTrainedSubsequences = 0;
         int sequenceMaxCount = 0;
         
         for (ITaskInstance currentTaskInstance : executedTasks) {
-            int occurrenceCount = taskInstancesMap.get(currentTaskInstance).size();
-            
-            if ((numberOfTrainedSubsequences % 10) == 0) {
+            
+            int occurrenceCount = taskInstanceCountMap.get(currentTaskInstance.getTask()).count;
+            
+            if (processedTaskInstances.count >= counterRecheckAt) {
                 sequenceMaxCount = getCurrentSequenceMaxCount();
+                processedTaskInstances.count = 0;
             }
             
@@ -158,8 +166,8 @@
                     add(subsequence);
                     subsequence.remove(0);
-
-                    numberOfTrainedSubsequences++;
                 }
             }
+            
+            processedTaskInstances.count++;
         }
         
@@ -219,3 +227,10 @@
     }
     
+    /**
+     * @author Patrick Harms
+     */
+    private static class Counter {
+        int count = 0;
+    }
+        
 }
