Changeset 1702
- Timestamp:
- 09/01/14 15:34:03 (10 years ago)
- Location:
- branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/DifferenceSubstitutionMatrix.java
r1698 r1702 29 29 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) 30 30 */ 31 public doublegetScore(int pos1, int pos2) {31 public float getScore(int pos1, int pos2) { 32 32 return maxValue - (input1[pos1] - input2[pos2]); 33 33 } … … 49 49 50 50 @Override 51 public doublegetGapPenalty() {51 public float getGapPenalty() { 52 52 return -maxValue; 53 53 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/DummySubstitutionMatrix.java
r1698 r1702 9 9 10 10 @Override 11 public doublegetScore(int pos1, int pos2) {11 public float getScore(int pos1, int pos2) { 12 12 if(pos1==pos2) { 13 13 return 1; … … 19 19 20 20 @Override 21 public doublegetGapPenalty() {21 public float getGapPenalty() { 22 22 return -1; 23 23 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/NearbySubstitutionMatrix.java
r1698 r1702 28 28 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) 29 29 */ 30 public doublegetScore(int pos1, int pos2) {30 public float getScore(int pos1, int pos2) { 31 31 int difference = Math.abs(input1[pos1]-input2[pos2]); 32 32 if(difference < range) { … … 40 40 41 41 @Override 42 public doublegetGapPenalty() {42 public float getGapPenalty() { 43 43 return -range-1; 44 44 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/ObjectDistanceSubstitionMatrix.java
r1699 r1702 16 16 import de.ugoe.cs.util.console.Console; 17 17 18 19 18 20 public class ObjectDistanceSubstitionMatrix implements SubstitutionMatrix { 19 21 20 22 private HashMap<Integer, Integer> idmapping; 21 private TriangleMatrix matrix;23 private ITriangleMatrix matrix; 22 24 private HashSet<ITask> uniqueTasks; 23 private doublegapPenalty;25 private float gapPenalty; 24 26 private int index = 0; 25 27 private HashMap<Integer, LinkedList<IEventTaskInstance>> etisOfTasks; 26 28 private boolean calculateNonTaskInstances = true; 29 private int firstRoundMaxIndex = 0; 27 30 28 31 private double positiveThreshold; 29 32 30 33 public ObjectDistanceSubstitionMatrix( 31 float positiveThreshold, int gapPenalty, 32 boolean calculateNonTaskInstances) { 33 34 float positiveThreshold, int gapPenalty, 35 boolean calculateNonTaskInstances) { 34 36 this.positiveThreshold = positiveThreshold; 35 37 idmapping = new HashMap<Integer, Integer>(); … … 40 42 } 41 43 42 public doublegetGapPenalty() {44 public float getGapPenalty() { 43 45 return gapPenalty; 44 46 } 45 47 46 public void setGapPenalty( doublegapPenalty) {48 public void setGapPenalty(float gapPenalty) { 47 49 this.gapPenalty = gapPenalty; 48 50 } … … 77 79 //Just Calculate the distance between the new tasks and the matrix. 78 80 public void update(LinkedList<ITask> newTasks) { 79 matrix.increaseSize(newTasks.size()); 81 80 82 if (this.calculateNonTaskInstances) { 81 Console.traceln(Level.INFO, "searching EventTasks in Tasks"); 83 try { 84 matrix.increaseSize(newTasks.size()); 85 System.out.println("Subsitution matrix size is now " + matrix.size()*(matrix.size()+1)/2); 86 Console.traceln(Level.INFO, "searching EventTasks in Tasks"); 87 } catch (Exception e) { 88 Console.logException(e); 89 } 82 90 this.updateEventTaskInstances(newTasks); 83 } 84 91 85 92 for(Iterator<ITask> it = newTasks.iterator();it.hasNext();) { 86 93 int index1 = -1; … … 137 144 } 138 145 } 146 } 139 147 } 140 148 141 149 public void generate(HashSet<ITask> uniqueTasks) { 142 150 this.uniqueTasks = uniqueTasks; 143 matrix = new TriangleMatrix(uniqueTasks.size() + 1);144 matrix.initialize(0);145 151 if (this.calculateNonTaskInstances) { 152 matrix = new DynamicTriangleMatrix(uniqueTasks.size() + 1); 146 153 Console.traceln(Level.INFO, "searching EventTasks in Tasks"); 147 154 searchEventTaskInstances(); 148 155 } 156 else{ 157 matrix = new StaticTriangleMatrix(uniqueTasks.size()+1); 158 } 159 matrix.initialize(0); 149 160 Console.traceln(Level.INFO, "calculating distances"); 150 161 int index1 = -1; … … 197 208 System.out.println("Unknown error"); 198 209 } 199 200 210 matrix.set(index1, index2, distance); 201 211 202 212 } 203 213 } 204 } 214 this.firstRoundMaxIndex=index; 215 } 216 217 private void computeDistance(ITask task1, ITask task2) { 218 219 220 } 221 205 222 206 223 … … 293 310 } 294 311 295 public doublegetScore(int taskId1, int taskId2) {312 public float getScore(int taskId1, int taskId2) { 296 313 if (taskId1 == Constants.GAP_SYMBOL 297 314 || taskId1 == Constants.UNMATCHED_SYMBOL 298 315 || taskId2 == Constants.GAP_SYMBOL 299 316 || taskId2 == Constants.UNMATCHED_SYMBOL) { 300 return 0.0; 317 return 0; 318 } else if(this.calculateNonTaskInstances==false && 319 (taskId1>this.firstRoundMaxIndex 320 || taskId2>this.firstRoundMaxIndex)) { 321 return 0; 301 322 } else { 302 323 Integer first = idmapping.get(taskId1); -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/SubstitutionMatrix.java
r1698 r1702 11 11 12 12 13 public doublegetScore(int pos1, int pos2);13 public float getScore(int pos1, int pos2); 14 14 15 public doublegetGapPenalty();15 public float getGapPenalty(); 16 16 17 17 public void generate(HashSet<ITask> uniqueTasks); -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/UPGMAMatrix.java
r1580 r1702 3 3 4 4 5 public class UPGMAMatrix extends TriangleMatrix {5 public class UPGMAMatrix extends StaticTriangleMatrix { 6 6 7 7 public UPGMAMatrix(int size) { -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1700 r1702 113 113 114 114 // TODO: Debug output 115 /* 115 116 System.out.println("PRINTING MODEL: "); 116 117 for (int i = 0; i < subsequence.getSequence().getChildren().size(); i++) { … … 140 141 } 141 142 System.out.println(); 142 143 */ 143 144 144 145 //TODO: This is dirty! … … 151 152 } 152 153 ITask tempTask = model.getChildren().get(modelindex); 153 System.out.println("Trying to add " + parent.get(startIndex)154 + " to the model instance " + tempTask);154 //System.out.println("Trying to add " + parent.get(startIndex) 155 // + " to the model instance " + tempTask); 155 156 if (tempTask.getType() == "optionality") { 156 157 157 158 if(((IMarkingTemporalRelationship) tempTask).getMarkedTask() == parent.get(startIndex).getTask()) { 158 System.out.println("Adding OptionalInstance " + parent.get(startIndex) + " to " + tempTask.getType());159 //System.out.println("Adding OptionalInstance " + parent.get(startIndex) + " to " + tempTask.getType()); 159 160 IOptionalInstance optional = taskFactory.createNewTaskInstance((IOptional) tempTask); 160 161 taskBuilder.setChild(optional, parent.get(startIndex)); … … 162 163 } 163 164 else { 164 System.out.println("Adding Empty optional, not deleting anything from the input sequence");165 //System.out.println("Adding Empty optional, not deleting anything from the input sequence"); 165 166 IOptionalInstance optional = taskFactory.createNewTaskInstance((IOptional) tempTask); 166 167 taskBuilder.addChild(subsequence, optional); … … 182 183 } 183 184 else if(parent.get(startIndex).getTask().getId() == tmpSel.getChildren().get(0).getId() || parent.get(startIndex).getTask().getId() == tmpSel.getChildren().get(1).getId() ) { 184 System.out.println("Session ID: " + parent.get(startIndex).getTask().getId() + " tmpSel(0): " + tmpSel.getChildren().get(0).getId() + " tmpSel(1): " +tmpSel.getChildren().get(1).getId() );185 //System.out.println("Session ID: " + parent.get(startIndex).getTask().getId() + " tmpSel(0): " + tmpSel.getChildren().get(0).getId() + " tmpSel(1): " +tmpSel.getChildren().get(1).getId() ); 185 186 continue; 186 187 } 187 188 188 189 for (int k=0;k<selseq.getSequence().getChildren().size();k++) { 189 System.out.println("Trying to add " + parent.get(startIndex) + " to " + selseq);190 //System.out.println("Trying to add " + parent.get(startIndex) + " to " + selseq); 190 191 taskBuilder.addChild(selseq,parent.get(startIndex)); 191 192 taskBuilder.removeTaskInstance(parent, startIndex); 192 193 i++; 193 System.out.println("I:" + i);194 } 195 System.out.println("Trying to add " + selseq + " to " + tmpSel);194 //System.out.println("I:" + i); 195 } 196 //System.out.println("Trying to add " + selseq + " to " + tmpSel); 196 197 taskBuilder.setChild(selection, selseq); 197 198 taskBuilder.addChild(subsequence, selection); … … 201 202 else 202 203 { 203 System.out.println("Trying to adding SelectionInstance " + parent.get(startIndex) + " to " + tempTask);204 //System.out.println("Trying to adding SelectionInstance " + parent.get(startIndex) + " to " + tempTask); 204 205 taskBuilder.setChild(selection, parent.get(startIndex)); 205 206 taskBuilder.addChild(subsequence,selection); 206 207 } 207 208 } else if (tempTask.getType() == "sequence") { 208 System.out.println("Adding SequenceInstance " + parent.get(startIndex) + " to " + tempTask);209 //System.out.println("Adding SequenceInstance " + parent.get(startIndex) + " to " + tempTask); 209 210 taskBuilder.addChild(subsequence, parent.get(startIndex)); 210 211 } else if (tempTask.getType() == "iteration") { 211 System.out.println("Adding IterationInstance " + parent.get(startIndex) + " to " + tempTask);212 //System.out.println("Adding IterationInstance " + parent.get(startIndex) + " to " + tempTask); 212 213 taskBuilder.addChild(subsequence, parent.get(startIndex)); 213 214 } else { 214 System.out.println("Adding EventInstance " + parent.get(startIndex) + " to " + tempTask);215 System.out.println("Foo");215 //System.out.println("Adding EventInstance " + parent.get(startIndex) + " to " + tempTask); 216 //System.out.println("Foo"); 216 217 taskBuilder.addChild(subsequence, parent.get(startIndex)); 217 218 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1700 r1702 141 141 // Generate a substitution matrix between all occurring events. 142 142 Console.traceln(Level.INFO, "generating substitution matrix"); 143 Console.traceln(Level.INFO,"Got " + appData.getUniqueTasks().size() + "tasks"); 143 144 appData.getSubmat().generate(appData.getUniqueTasks()); 144 145 146 147 Console.traceln(Level.INFO, "Starting main loop"); 145 148 do { 149 Console.traceln(Level.INFO, "Iteration Number: " + iteration); 146 150 iteration++; 147 151 148 152 appData.detectedAndReplacedTasks = false; 149 153 appData.getStopWatch().start("whole loop"); … … 642 646 MatchOccurence oc = it.next(); 643 647 644 648 /* 645 649 if (iteration > 1) { 646 650 … … 661 665 .get(j)); 662 666 } 663 } 667 }*/ 664 668 665 669 // Check if nothing has been replaced in the sequence we … … 773 777 stopWatch = new StopWatch(); 774 778 result = new RuleApplicationResult(); 775 submat= new ObjectDistanceSubstitionMatrix(6,-3, true);779 submat= new ObjectDistanceSubstitionMatrix(6,-3,false); 776 780 newTasks = new LinkedList<ITask>(); 777 781 }
Note: See TracChangeset
for help on using the changeset viewer.