Changeset 1687 for branches/autoquest-core-tasktrees-alignment
- Timestamp:
- 08/21/14 08:51:26 (10 years ago)
- Location:
- branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/ObjectDistanceSubstitionMatrix.java
r1679 r1687 49 49 int index2=-1; 50 50 float distance=0; 51 52 //TODO: Nicht ueber Symbols sondern ueber values, wenn Eventtask -> getInstances()->get(0) 51 53 for (Iterator<ITaskInstance> it = uniqueTasks.getSymbols().iterator(); it 52 54 .hasNext();) { … … 156 158 } 157 159 else { 158 //System.out.println("Firsttask: " +taskId1); 159 //System.out.println("Secondtask: " + taskId2); 160 int first = idmapping.get(taskId1); 161 int second = idmapping.get(taskId2); 162 //System.out.println("First: " + first + " Second: " + second); 163 //System.out.println("Matrix: " + matrix.get(first, second)); 160 System.out.println("Firsttask: " +taskId1); 161 System.out.println("Secondtask: " + taskId2); 162 System.out.println(idmapping); 163 Integer first = idmapping.get(taskId1); 164 Integer second = idmapping.get(taskId2); 165 System.out.println("First: " + first + " Second: " + second); 166 System.out.println("Matrix: " + matrix.get(first, second)); 164 167 return matrix.get(first,second); 165 168 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1680 r1687 148 148 public RuleApplicationResult apply(List<IUserSession> sessions) { 149 149 RuleApplicationData appData = new RuleApplicationData(sessions); 150 150 harmonizeEventTaskInstancesModel(appData); 151 151 152 152 do { 153 153 iteration++; 154 154 appData.detectedAndReplacedTasks = false; 155 harmonizeEventTaskInstancesModel(appData);155 156 156 appData.getStopWatch().start("whole loop"); 157 157 detectAndReplaceIterations(appData); … … 363 363 .createNewTaskInstance(iteration); 364 364 iterationInstances.get(iteration) 365 .add(iterationInstance); 365 .add(iterationInstance);//TODO:: Don't create TaskInstances here, use a set of tasks instead 366 366 taskBuilder.addTaskInstance(session, index, 367 367 iterationInstance); … … 379 379 } 380 380 } 381 382 for (Map.Entry<IIteration, List<IIterationInstance>> entry : iterationInstances383 .entrySet()) {384 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue());385 }386 381 } 387 382 … … 412 407 IOptional optional = taskFactory.createNewOptional(); 413 408 appData.uniqueTasks.addSymbol( 409 //TODO:: Don't create TaskInstances here, use a set of tasks instead 414 410 taskFactory.createNewTaskInstance(optional), optional); 415 411 appData.number2task.put(optional.getId(), optional); … … 422 418 else if (first[i] != -1 && second[i] == -1) { 423 419 IOptional optional = taskFactory.createNewOptional(); 420 //TODO:: Don't create TaskInstances here, use a set of tasks instead 424 421 appData.uniqueTasks.addSymbol( 425 422 taskFactory.createNewTaskInstance(optional), optional); … … 434 431 //System.out.println("First: " + first[i] + " Second: " + second[i]); 435 432 ISelection selection = taskFactory.createNewSelection(); 433 //TODO:: Don't create TaskInstances here, use a set of tasks instead 436 434 ISelectionInstance temp = taskFactory.createNewTaskInstance(selection); 437 435 appData.uniqueTasks … … 460 458 } 461 459 462 /** 463 * <p> 464 * TODO clarify why this is done 465 * </p> 466 */ 467 private void harmonizeIterationInstancesModel(IIteration iteration, 468 List<IIterationInstance> iterationInstances) { 469 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 470 TaskInstanceComparator comparator = preparationTaskHandlingStrategy 471 .getTaskComparator(); 472 473 // merge the lexically different variants of iterated task to a unique 474 // list 475 for (IIterationInstance iterationInstance : iterationInstances) { 476 for (ITaskInstance executionVariant : iterationInstance) { 477 ITask candidate = executionVariant.getTask(); 478 479 boolean found = false; 480 for (ITask taskVariant : iteratedTaskVariants) { 481 if (comparator.areLexicallyEqual(taskVariant, candidate)) { 482 taskBuilder.setTask(executionVariant, taskVariant); 483 found = true; 484 break; 485 } 486 } 487 488 if (!found) { 489 iteratedTaskVariants.add(candidate); 490 } 491 } 492 } 493 494 // if there are more than one lexically different variant of iterated 495 // tasks, adapt the 496 // iteration model to be a selection of different variants. In this case 497 // also adapt 498 // the generated iteration instances to correctly contain selection 499 // instances. If there 500 // is only one variant of an iterated task, simply set this as the 501 // marked task of the 502 // iteration. In this case, the instances can be preserved as is 503 if (iteratedTaskVariants.size() > 1) { 504 ISelection selection = taskFactory.createNewSelection(); 505 506 for (ITask variant : iteratedTaskVariants) { 507 taskBuilder.addChild(selection, variant); 508 } 509 510 taskBuilder.setMarkedTask(iteration, selection); 511 512 for (IIterationInstance instance : iterationInstances) { 513 for (int i = 0; i < instance.size(); i++) { 514 ISelectionInstance selectionInstance = taskFactory 515 .createNewTaskInstance(selection); 516 taskBuilder.setChild(selectionInstance, instance.get(i)); 517 taskBuilder.setTaskInstance(instance, i, selectionInstance); 518 } 519 } 520 } else { 521 taskBuilder.setMarkedTask(iteration, iteratedTaskVariants.get(0)); 522 } 523 } 524 525 /** 526 * TODO go on commenting 460 461 /** 527 462 * 528 463 * @param appData … … 705 640 } 706 641 707 /** 708 * 709 */ 710 private void harmonizeSequenceInstancesModel(ISequence sequence, 711 List<ISequenceInstance> sequenceInstances, int sequenceLength) { 712 TaskInstanceComparator comparator = preparationTaskHandlingStrategy 713 .getTaskComparator(); 714 715 // ensure for each subtask that lexically different variants are 716 // preserved 717 for (int subTaskIndex = 0; subTaskIndex < sequenceLength; subTaskIndex++) { 718 List<ITask> subTaskVariants = new LinkedList<ITask>(); 719 720 for (ISequenceInstance sequenceInstance : sequenceInstances) { 721 ITask candidate = sequenceInstance.get(subTaskIndex).getTask(); 722 723 boolean found = false; 724 725 for (int i = 0; i < subTaskVariants.size(); i++) { 726 if (comparator.areLexicallyEqual(subTaskVariants.get(i), 727 candidate)) { 728 taskBuilder.setTask(sequenceInstance.get(subTaskIndex), 729 subTaskVariants.get(i)); 730 731 found = true; 732 break; 733 } 734 } 735 736 if (!found) { 737 subTaskVariants.add(candidate); 738 } 739 } 740 741 // if there are more than one lexically different variant of the sub 742 // task at 743 // the considered position, adapt the sequence model at that 744 // position to have 745 // a selection of the different variants. In this case also adapt 746 // the 747 // generated sequence instances to correctly contain selection 748 // instances. If 749 // there is only one variant of sub tasks at the given position, 750 // simply set 751 // this variant as the sub task of the selection. In this case, the 752 // instances 753 // can be preserved as is 754 if (subTaskVariants.size() > 1) { 755 ISelection selection = taskFactory.createNewSelection(); 756 757 for (ITask variant : subTaskVariants) { 758 taskBuilder.addChild(selection, variant); 759 } 760 761 taskBuilder.addChild(sequence, selection); 762 763 for (ISequenceInstance instance : sequenceInstances) { 764 ISelectionInstance selectionInstance = taskFactory 765 .createNewTaskInstance(selection); 766 taskBuilder.setChild(selectionInstance, 767 instance.get(subTaskIndex)); 768 taskBuilder.setTaskInstance(instance, subTaskIndex, 769 selectionInstance); 770 } 771 } else if (subTaskVariants.size() == 1) { 772 taskBuilder.addChild(sequence, subTaskVariants.get(0)); 773 } 774 } 775 } 642 776 643 777 644 /**
Note: See TracChangeset
for help on using the changeset viewer.