- Timestamp:
- 05/23/14 21:54:40 (11 years ago)
- Location:
- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java
r1553 r1554 70 70 71 71 System.out.println("Starting SmithWaterman algorithm with a " 72 + submat.getClass() + " Substitution Matrix: " + submat. info());72 + submat.getClass() + " Substitution Matrix: " + submat.getClass().getCanonicalName()); 73 73 scoreThreshold = 20; 74 74 score = new double[length1 + 1][length2 + 1]; -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java
r1553 r1554 29 29 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) 30 30 */ 31 public doublegetDistance(int pos1, int pos2) {31 public float getDistance(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 }54 55 @Override56 public String info() {57 return "Max Value: " + maxValue;58 53 } 59 54 60 55 61 56 @Override 62 public void generate( List<IUserSession> sessions) {57 public void generate() { 63 58 // TODO Auto-generated method stub 64 59 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java
r1553 r1554 29 29 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) 30 30 */ 31 public doublegetDistance(int pos1, int pos2) {31 public float getDistance(int pos1, int pos2) { 32 32 int difference = Math.abs(input1[pos1]-input2[pos2]); 33 33 if(difference < range) { … … 41 41 42 42 @Override 43 public doublegetGapPenalty() {43 public float getGapPenalty() { 44 44 return -range-1; 45 45 } 46 46 47 @Override48 public String info() {49 return "Range: " + range;50 }51 47 52 48 @Override 53 public void generate( List<IUserSession> sessions) {49 public void generate() { 54 50 // TODO Auto-generated method stub 55 51 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java
r1553 r1554 3 3 import java.util.ArrayList; 4 4 import java.util.Collection; 5 import java.util.HashMap; 5 6 import java.util.Iterator; 6 7 … … 13 14 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.AlignmentHelpers; 14 15 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 16 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 15 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 19 import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; 16 20 import de.ugoe.cs.util.console.GlobalDataContainer; 17 21 18 22 public class ObjectDistanceSubstitionMatrix implements SubstitutionMatrix { 19 23 20 private ArrayList<int[][]> matrix; 21 private int currentSequence; 22 23 24 public ObjectDistanceSubstitionMatrix() { 25 currentSequence = 0; 26 matrix = new ArrayList<int[][]>(); 27 } 28 29 @Override 30 public String info() { 31 // TODO Auto-generated method stub 32 return null; 24 // private ArrayList<int[][]> matrix; 25 HashMap<Integer, Integer> idmapping; 26 private TriangleMatrix matrix; 27 private SymbolMap<ITaskInstance, ITask> uniqueTasks; 28 29 public ObjectDistanceSubstitionMatrix( 30 SymbolMap<ITaskInstance, ITask> uniqueTasks) { 31 this.uniqueTasks = uniqueTasks; 32 idmapping = new HashMap<Integer, Integer>(); 33 matrix = new TriangleMatrix(uniqueTasks.size()+1); 33 34 } 34 35 35 36 @Override 36 public double getDistance(int pos1, int pos2) { 37 // TODO Auto-generated method stub 38 39 return matrix.get(currentSequence)[pos1][pos2]; 40 } 41 42 public double getDistance(int sequence, int pos1, int pos2) { 43 return matrix.get(sequence)[pos1][pos2]; 44 45 46 } 47 48 @Override 49 public double getGapPenalty() { 37 public float getGapPenalty() { 50 38 // TODO Auto-generated method stub 51 39 return 0; … … 53 41 54 42 @Override 55 public void generate(List<IUserSession> sessions) { 56 57 for(Iterator it = sessions.iterator(); it.hasNext();) { 58 IUserSession session = (IUserSession) it.next(); 59 matrix.add(new int[sessions.size()][sessions.size()]); 60 61 62 for (int i=0; i < session.size(); i++) { 63 for (int j=0; j < session.size(); j++) { 64 //TODO Check if ITaskInstance is of type IEventTaskInstance 65 IEventTaskInstance eti1 = (IEventTaskInstance) session.get(i); 66 IEventTaskInstance eti2 = (IEventTaskInstance) session.get(j); 67 IGUIElement first = (IGUIElement) eti1.getEvent().getTarget(); 68 IGUIElement second =(IGUIElement) eti2.getEvent().getTarget(); 69 matrix.get(currentSequence)[i][j] = AlignmentHelpers.distanceBetween(first, second); 43 public void generate() { 44 int i = 0; 45 for (Iterator<ITaskInstance> it = uniqueTasks.getSymbols().iterator(); it 46 .hasNext();) { 47 Object obj1 = it.next(); 48 IEventTaskInstance eti1 = null; 49 if (obj1 instanceof IEventTaskInstance) { 50 eti1 = (IEventTaskInstance) obj1; 51 } 52 int j = 0; 53 for (Iterator<ITaskInstance> jt = uniqueTasks.getSymbols() 54 .iterator(); jt.hasNext();) { 55 IEventTaskInstance eti2 = null; 56 Object obj2 = jt.next(); 57 if (obj2 instanceof IEventTaskInstance) { 58 eti2 = (IEventTaskInstance) obj2; 70 59 } 71 } 60 IGUIElement first = (IGUIElement) eti1.getEvent().getTarget(); 61 IGUIElement second = (IGUIElement) eti2.getEvent().getTarget(); 62 idmapping.put(eti1.getTask().getId(), i); 63 idmapping.put(eti2.getTask().getId(), j); 64 matrix.set(i, j, AlignmentHelpers.distanceBetween(first, second)); 65 j++; 66 } 67 i++; 72 68 } 73 69 } 70 71 @Override 72 public float getDistance(int taskId1, int taskId2) { 73 return matrix.get(idmapping.get(taskId1),idmapping.get(taskId2)); 74 } 75 74 76 } 77 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java
r1553 r1554 9 9 10 10 public interface SubstitutionMatrix { 11 11 12 12 public String info(); 13 14 public double getDistance(int pos1, int pos2); 13 public float getDistance(int pos1, int pos2); 15 14 16 public doublegetGapPenalty();15 public float getGapPenalty(); 17 16 18 public void generate( List<IUserSession> sessions);17 public void generate(); 19 18 20 19 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1553 r1554 26 26 27 27 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence; 28 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.SmithWaterman; 29 import de.ugoe.cs.autoquest.tasktrees.alignment.substitution.ObjectDistanceSubstitionMatrix; 28 30 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 29 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; … … 140 142 numberseqs = new ArrayList<NumberSequence>(); 141 143 144 145 142 146 // this is the real rule application. Loop while something is replaced. 143 harmonizeEventTaskInstancesModel(appData); 147 SymbolMap<ITaskInstance, ITask> uniqueTasks = harmonizeEventTaskInstancesModel(appData,numberseqs); 148 ObjectDistanceSubstitionMatrix submat = new ObjectDistanceSubstitionMatrix(uniqueTasks); 149 submat.generate(); 150 151 152 SmithWaterman sm = new SmithWaterman(numberseqs.get(0).getSequence(), numberseqs.get(0).getSequence(), submat); 153 sm.printDPMatrix(); 154 144 155 145 156 … … 188 199 * 189 200 * @param appData the rule application data combining all data used for applying this rule 190 */ 191 private void harmonizeEventTaskInstancesModel(RuleApplicationData appData) { 201 * @return Returns the unique tasks symbol map 202 */ 203 private SymbolMap<ITaskInstance, ITask> harmonizeEventTaskInstancesModel(RuleApplicationData appData, ArrayList<NumberSequence> numberseqs) { 192 204 Console.traceln(Level.INFO, "harmonizing task model of event task instances"); 193 205 appData.getStopWatch().start("harmonizing event tasks"); … … 201 213 List<IUserSession> sessions = appData.getSessions(); 202 214 int sessionNo = 0; 215 numberseqs = new ArrayList<NumberSequence>(); 203 216 for (IUserSession session : sessions) { 204 217 Console.traceln(Level.FINE, "handling " + (++sessionNo) + ". " + session); … … 219 232 } 220 233 } 221 234 numberseqs.add(templist); 222 235 comparator.clearBuffers(); 223 236 } … … 229 242 appData.getStopWatch().dumpStatistics(System.out); 230 243 appData.getStopWatch().reset(); 244 return uniqueTasks; 231 245 } 232 246
Note: See TracChangeset
for help on using the changeset viewer.