Changeset 1743 for branches/autoquest-core-tasktrees-alignment
- Timestamp:
- 09/13/14 14:33:46 (10 years ago)
- Location:
- branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1742 r1743 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 19 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; … … 64 65 final ISequenceInstance subsequence = taskFactory 65 66 .createNewTaskInstance(model); 66 // TODO: Debugging output67 67 /* 68 int modelid = model.getId(); 69 if(modelid == 5412) { 70 System.out.println("Printing session: "); 71 for (int i = 0; i < parent.size();i++) { 72 System.out.println(parent.get(i)); 68 System.out.println("PRINTING MODEL: "); 69 for (int i = 0; i < subsequence.getSequence().getChildren().size(); i++) { 70 System.out.println(subsequence.getSequence().getChildren().get(i)); 71 72 if (subsequence.getSequence().getChildren().get(i).getType() == "selection") { 73 for (int j = 0; j < ((ISelection) subsequence.getSequence() 74 .getChildren().get(i)).getChildren().size(); j++) { 75 if (((IStructuringTemporalRelationship) subsequence 76 .getSequence().getChildren().get(i)).getChildren() 77 .get(j).getType() == "sequence") { 78 ISequence foo = (ISequence) ((ISelection) (subsequence 79 .getSequence().getChildren().get(i))) 80 .getChildren().get(j); 81 System.out.println("\t" + foo); 82 for (int k = 0; k < foo.getChildren().size(); k++) { 83 System.out.println("\t\t" 84 + foo.getChildren().get(k)); 85 } 86 System.out.println(); 87 } else { 88 System.out.println("\t" 89 + ((ISelection) subsequence.getSequence() 90 .getChildren().get(i)).getChildren() 91 .get(j)); 92 } 93 94 } 73 95 } 74 System.out.println("startIndex: " + startIndex + " endIndex: " + endIndex + "\n"); 75 System.out.println("Printing model: "); 76 for(int i = 0; i < ((ISequence)model).getChildren().size();i++) { 77 System.out.println((ISequence)model.getChildren().get(i)); 78 } 79 80 }*/ 96 97 } 98 System.out.println(); 99 */ 81 100 // TODO: This is dirty, return this in addition with the sequence 82 101 // instance instead … … 89 108 } 90 109 final ITask tempTask = model.getChildren().get(modelindex); 91 // 110 //System.out.println("Trying to add " + parent.get(startIndex) 92 111 // + " to the model instance " + tempTask); 93 112 if (tempTask.getType() == "optionality") { … … 111 130 } 112 131 } else if (tempTask instanceof ISelection) { 113 final ISelectionInstance selection = taskFactory.createNewTaskInstance((ISelection) tempTask); 132 final ISelectionInstance selection = taskFactory 133 .createNewTaskInstance((ISelection) tempTask); 114 134 final ISelection tmpSel = (ISelection) tempTask; 115 //Check if the selection has 2 sequences as children 116 if ((tmpSel.getChildren().get(0) instanceof ISequence) && (tmpSel.getChildren().get(1) instanceof ISequence)) { 135 if (tmpSel.getChildren().size() == 0) { 136 try { 137 throw new Exception("Selection without children"); 138 } catch (Exception e) { 139 e.printStackTrace(); 140 } 141 } 142 // Check if the selection has 2 sequences as children 143 // TODO: This segment is a mess, clean it up. 144 if ((tmpSel.getChildren().get(0) instanceof ISequence) 145 && (tmpSel.getChildren().get(1) instanceof ISequence)) { 117 146 ISequenceInstance selseq = null; 118 // The selection I create can just have 2 children, we need to check here, to which sequence of the model this occurence belongs 119 //This if checks of the occurrence is equal to the first element of the first sequence in the model 120 if (parent.get(startIndex).getTask().equals(((ISequence) tmpSel.getChildren().get(0)).getChildren().get(0))) { 121 selseq = taskFactory.createNewTaskInstance((ISequence) tmpSel.getChildren().get(0)); 122 //This if checks of the occurrence is equal to the first element of the second sequence in the model 123 } else if (parent.get(startIndex).getTask().equals(((ISequence) tmpSel.getChildren().get(1)).getChildren().get(0))) { 124 selseq = taskFactory.createNewTaskInstance((ISequence) tmpSel.getChildren().get(1)); 125 //If the occurence is already a sequence we don't need to do anything, the next iteration will detect this as a sequence and add it 126 } else if ((parent.get(startIndex).getTask().equals(tmpSel.getChildren().get(0).getId())) 127 || (parent.get(startIndex).getTask().equals(tmpSel.getChildren().get(1).getId()))) { 147 // The selection I create can just have 2 children, we need 148 // to check here, to which sequence of the model this 149 // occurence belongs 150 // This if checks of the occurrence is equal to the first 151 // element of the first sequence in the model 152 if (parent 153 .get(startIndex) 154 .getTask() 155 .equals(((ISequence) tmpSel.getChildren().get(0)) 156 .getChildren().get(0))) { 157 selseq = taskFactory 158 .createNewTaskInstance((ISequence) tmpSel 159 .getChildren().get(0)); 160 for (int k = 0; k < selseq.getSequence().getChildren() 161 .size(); k++) { 162 taskBuilder 163 .addChild(selseq, parent.get(startIndex)); 164 taskBuilder.removeTaskInstance(parent, startIndex); 165 i++; 166 } 167 taskBuilder.setChild(selection, selseq); 168 taskBuilder.addChild(subsequence, selection); 169 modelindex++; 170 continue; 171 } 172 // This if checks of the occurrence is equal to the first 173 // element of the second sequence in the model 174 else if (parent 175 .get(startIndex) 176 .getTask() 177 .equals(((ISequence) tmpSel.getChildren().get(1)) 178 .getChildren().get(0))) { 179 selseq = taskFactory 180 .createNewTaskInstance((ISequence) tmpSel 181 .getChildren().get(1)); 182 for (int k = 0; k < selseq.getSequence().getChildren() 183 .size(); k++) { 184 taskBuilder 185 .addChild(selseq, parent.get(startIndex)); 186 taskBuilder.removeTaskInstance(parent, startIndex); 187 i++; 188 } 189 taskBuilder.setChild(selection, selseq); 190 taskBuilder.addChild(subsequence, selection); 191 modelindex++; 192 continue; 193 } 194 // If the occurrence is already a sequence wedon't need to 195 // do anything, the next iteration will detect this as a 196 // sequence and add it 197 else if ((parent.get(startIndex).getTask().equals(tmpSel 198 .getChildren().get(0))) 199 || (parent.get(startIndex).getTask().equals(tmpSel 200 .getChildren().get(1)))) { 128 201 taskBuilder.setChild(selection, parent.get(startIndex)); 129 202 taskBuilder.addChild(subsequence, selection); 130 taskBuilder.removeTaskInstance(parent, 203 taskBuilder.removeTaskInstance(parent,startIndex); 131 204 modelindex++; 132 205 continue; 133 134 } 135 //TODO: Sometimes nullpointer exception here :( 136 for (int k = 0; k < ((ISequence)tmpSel.getChildren().get(0)).getChildren().size(); k++) { 137 taskBuilder.addChild(selseq, parent.get(startIndex)); 138 taskBuilder.removeTaskInstance(parent, startIndex); 139 i++; 140 } 141 taskBuilder.setChild(selection, selseq); 142 taskBuilder.addChild(subsequence, selection); 143 modelindex++; 144 continue; 145 //It is just a plain selection 146 } else { 206 } 207 } 208 // It is just a plain selection 209 else { 147 210 taskBuilder.setChild(selection, parent.get(startIndex)); 148 211 taskBuilder.addChild(subsequence, selection); … … 160 223 161 224 taskBuilder.addTaskInstance(parent, startIndex, subsequence); 162 163 225 164 226 return subsequence; … … 227 289 // Thread.currentThread().getName() + ": " + Math.round((float) 228 290 // count/size*100))+ "%"); 229 System.out.println(message + " in thread "230 + Thread.currentThread().getName() + ": "231 + Math.round(((float) count / size) * 100) + "%");291 // System.out.println(message + " in thread " 292 // + Thread.currentThread().getName() + ": " 293 // + Math.round(((float) count / size) * 100) + "%"); 232 294 } 233 295 } else { … … 235 297 // Thread.currentThread().getName() + ": " +Math.round((float) 236 298 // count/size*100))+ "%"); 237 System.out.println(message + " in thread "238 + Thread.currentThread().getName() + ": "239 + Math.round(((float) count / size) * 100) + "%");299 // System.out.println(message + " in thread " 300 // + Thread.currentThread().getName() + ": " 301 // + Math.round(((float) count / size) * 100) + "%"); 240 302 241 303 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1742 r1743 75 75 76 76 /** The n threads. */ 77 public static int nThreads = Runtime.getRuntime().availableProcessors() - 1; 77 //public static int nThreads = Runtime.getRuntime().availableProcessors() - 1; 78 public static int nThreads = 1; 78 79 79 80 /** The iteration. */
Note: See TracChangeset
for help on using the changeset viewer.