Changeset 1692 for branches/autoquest-core-tasktrees-alignment/src
- Timestamp:
- 08/23/14 17:19:39 (10 years ago)
- Location:
- branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/ObjectDistanceSubstitionMatrix.java
r1687 r1692 3 3 4 4 import java.util.HashMap; 5 import java.util.HashSet; 5 6 import java.util.Iterator; 6 7 … … 11 12 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 12 13 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 13 import de.ugoe.cs.autoquest.usageprofiles.SymbolMap;14 14 15 15 16 16 public class ObjectDistanceSubstitionMatrix implements SubstitutionMatrix { 17 17 18 // private ArrayList<int[][]> matrix;19 18 HashMap<Integer, Integer> idmapping; 20 19 private TriangleMatrix matrix; 21 private SymbolMap<ITaskInstance,ITask> uniqueTasks;20 private HashSet<ITask> uniqueTasks; 22 21 private double gapPenalty; 23 22 private int index = 0; … … 26 25 27 26 public ObjectDistanceSubstitionMatrix( 28 SymbolMap<ITaskInstance,ITask> uniqueTasks,float positiveThreshold, int gapPenalty) {27 HashSet<ITask> uniqueTasks,float positiveThreshold, int gapPenalty) { 29 28 this.uniqueTasks = uniqueTasks; 30 29 this.positiveThreshold = positiveThreshold; … … 49 48 int index2=-1; 50 49 float distance=0; 51 52 //TODO: Nicht ueber Symbols sondern ueber values, wenn Eventtask -> getInstances()->get(0) 53 for (Iterator<ITaskInstance> it = uniqueTasks.getSymbols().iterator(); it 54 .hasNext();) { 55 Object obj1 = it.next(); 56 for (Iterator<ITaskInstance> jt = uniqueTasks.getSymbols() 57 .iterator(); jt.hasNext();) { 58 50 for (Iterator<ITask> it = uniqueTasks.iterator(); it.hasNext();) { 51 ITask task1 = it.next(); 52 for (Iterator<ITask> jt = uniqueTasks.iterator(); jt.hasNext();) { 53 ITask task2 = jt.next(); 54 ITaskInstance ti1 = null; 55 ITaskInstance ti2 = null; 56 //TODO This seems ugly 57 if(task1.getInstances().size() > 0) { 58 ti1 = (ITaskInstance) task1.getInstances().iterator().next(); 59 } 60 if(task2.getInstances().size() > 0) { 61 ti2 = (ITaskInstance) task2.getInstances().iterator().next(); 62 } 59 63 IEventTaskInstance eti1 = null; 60 I Task task1= null;64 IEventTaskInstance eti2 = null; 61 65 62 IEventTaskInstance eti2 = null;63 ITask task2 = null;64 66 65 Object obj2 = jt.next(); 66 67 if (obj1 instanceof IEventTaskInstance && obj2 instanceof IEventTaskInstance) { 68 eti1 = (IEventTaskInstance) obj1; 67 if (ti1 instanceof IEventTaskInstance && ti2 instanceof IEventTaskInstance) { 68 eti1 = (IEventTaskInstance) ti1; 69 69 index1 = getIndex(eti1); 70 eti2 = (IEventTaskInstance) obj2;70 eti2 = (IEventTaskInstance) ti2; 71 71 index2 = getIndex(eti2); 72 72 distance = distanceBetweenInstances(eti1,eti2); 73 73 } 74 else if( obj1 instanceof IEventTaskInstance && !(obj2 instanceof IEventTaskInstance)) {75 task 2 = ((ITaskInstance) obj2).getTask();74 else if(ti1 instanceof IEventTaskInstance && !(ti2 instanceof IEventTaskInstance)) { 75 task1 = ((ITaskInstance) ti1).getTask(); 76 76 index2 = getIndex(task2); 77 eti1 = (IEventTaskInstance) obj1;77 eti1 = (IEventTaskInstance) ti1; 78 78 index1 = getIndex(eti1); 79 79 distance = distanceBetweenTaskAndInstance(task2,eti1); 80 80 } 81 else if(!(obj1 instanceof IEventTaskInstance) && obj2 instanceof IEventTaskInstance) { 82 task1 = ((ITaskInstance) obj1).getTask(); 81 else if(!(ti1 instanceof IEventTaskInstance) && ti2 instanceof IEventTaskInstance) { 83 82 index1 = getIndex(task1); 84 eti2 = (IEventTaskInstance) obj2;83 eti2 = (IEventTaskInstance) ti2; 85 84 index2 = getIndex(eti2); 86 85 distance = distanceBetweenTaskAndInstance(task1,eti2); 87 86 } 88 else if(!(obj2 instanceof IEventTaskInstance) && !(obj2 instanceof IEventTaskInstance)) { 89 task1 = ((ITaskInstance) obj1).getTask(); 87 else if(!(ti1 instanceof IEventTaskInstance) && !(ti2 instanceof IEventTaskInstance)) { 90 88 index1 = getIndex(task1); 91 task2 = ((ITaskInstance) obj2).getTask();92 89 index2 = getIndex(task2); 93 90 distance = distanceBetweenTasks(task1,task2); … … 103 100 } 104 101 105 102 //TODO: Calculate distance here 106 103 private float distanceBetweenTaskAndInstance(ITask task1, IEventTaskInstance eti) { 107 104 return 0; 108 105 } 109 106 107 //TODO: Calculate distance here 110 108 private float distanceBetweenTasks(ITask task1, ITask task2) { 111 109 return 0; … … 158 156 } 159 157 else { 160 System.out.println("Firsttask: " +taskId1); 161 System.out.println("Secondtask: " + taskId2); 162 System.out.println(idmapping); 158 163 159 Integer first = idmapping.get(taskId1); 164 160 Integer second = idmapping.get(taskId2); 165 System.out.println("First: " + first + " Second: " + second);166 System.out.println("Matrix: " + matrix.get(first, second));167 161 return matrix.get(first,second); 168 162 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1690 r1692 15 15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 18 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; … … 145 147 146 148 } else if (tempTask.getType() == "sequence") { 147 //System.out.println("Adding SequenceInstance " + parent.get(startIndex) + " to " + tempTask.getType()); 148 taskBuilder.addChild(subsequence,parent.get(startIndex)); 149 //ISequenceInstance sequence = taskFactory.createNewTaskInstance((ISequence) tempTask); 150 //taskBuilder.addChild(sequence, parent.get(i)); 151 //taskBuilder.addChild(subsequence,sequence); 152 taskBuilder.addChild(subsequence, parent.get(startIndex)); 149 153 } else if (tempTask.getType() == "iteration") { 154 //IIterationInstance iteration = taskFactory.createNewTaskInstance((IIteration) tempTask); 155 //taskBuilder.addChild(iteration, parent.get(startIndex)); 156 //taskBuilder.addChild(subsequence, iteration); 150 157 taskBuilder.addChild(subsequence, parent.get(startIndex)); 151 158 //System.out.println("Adding IterationInstance " + parent.get(startIndex) + " to " + tempTask.getType()); -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1690 r1692 38 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 39 39 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 40 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 40 41 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 41 42 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; … … 138 139 public RuleApplicationResult apply(List<IUserSession> sessions) { 139 140 RuleApplicationData appData = new RuleApplicationData(sessions); 141 140 142 harmonizeEventTaskInstancesModel(appData); 141 142 143 do { 143 144 iteration++; 145 144 146 appData.detectedAndReplacedTasks = false; 145 147 appData.getStopWatch().start("whole loop"); … … 364 366 } 365 367 } 366 } 368 369 for (Map.Entry<IIteration, List<IIterationInstance>> entry : iterationInstances.entrySet()) 370 { 371 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue()); 372 } 373 } 374 375 376 /** 377 * <p> 378 * TODO clarify why this is done 379 * </p> 380 */ 381 private void harmonizeIterationInstancesModel(IIteration iteration, 382 List<IIterationInstance> iterationInstances) 383 { 384 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 385 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 386 387 // merge the lexically different variants of iterated task to a unique list 388 for (IIterationInstance iterationInstance : iterationInstances) { 389 for (ITaskInstance executionVariant : iterationInstance) { 390 ITask candidate = executionVariant.getTask(); 391 392 boolean found = false; 393 for (ITask taskVariant : iteratedTaskVariants) { 394 if (comparator.areLexicallyEqual(taskVariant, candidate)) { 395 taskBuilder.setTask(executionVariant, taskVariant); 396 found = true; 397 break; 398 } 399 } 400 401 if (!found) { 402 iteratedTaskVariants.add(candidate); 403 } 404 } 405 } 406 407 // if there are more than one lexically different variant of iterated tasks, adapt the 408 // iteration model to be a selection of different variants. In this case also adapt 409 // the generated iteration instances to correctly contain selection instances. If there 410 // is only one variant of an iterated task, simply set this as the marked task of the 411 // iteration. In this case, the instances can be preserved as is 412 if (iteratedTaskVariants.size() > 1) { 413 ISelection selection = taskFactory.createNewSelection(); 414 415 for (ITask variant : iteratedTaskVariants) { 416 taskBuilder.addChild(selection, variant); 417 } 418 419 taskBuilder.setMarkedTask(iteration, selection); 420 421 for (IIterationInstance instance : iterationInstances) { 422 for (int i = 0; i < instance.size(); i++) { 423 ISelectionInstance selectionInstance = 424 taskFactory.createNewTaskInstance(selection); 425 taskBuilder.setChild(selectionInstance, instance.get(i)); 426 taskBuilder.setTaskInstance(instance, i, selectionInstance); 427 } 428 } 429 } 430 else { 431 taskBuilder.setMarkedTask(iteration, iteratedTaskVariants.get(0)); 432 } 433 } 434 367 435 368 436 ISequence matchAsSequence(RuleApplicationData appData, Match m) {
Note: See TracChangeset
for help on using the changeset viewer.