- Timestamp:
- 06/18/14 08:59:41 (10 years ago)
- Location:
- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatrixEntry.java
r1559 r1568 2 2 3 3 public class MatrixEntry { 4 private floatscore;4 private double score; 5 5 private MatrixEntry previous; 6 6 private int xvalue; … … 15 15 } 16 16 17 public floatgetScore() {17 public double getScore() { 18 18 return score; 19 19 } 20 public void setScore( floatscore) {20 public void setScore(double score) { 21 21 this.score = score; 22 22 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java
r1559 r1568 3 3 import java.io.Serializable; 4 4 import java.util.ArrayList; 5 import java.util.Random; 5 6 6 7 public class NumberSequence implements Serializable { … … 33 34 System.out.println(); 34 35 } 36 37 public NumberSequence shuffle(){ 38 NumberSequence result = new NumberSequence(sequence.length); 39 result.setSequence(this.sequence); 40 Random rgen = new Random(); 41 42 for (int i=0; i<result.sequence.length; i++) { 43 int randomPosition = rgen.nextInt(result.sequence.length); 44 int temp = result.sequence[i]; 45 result.sequence[i] = result.sequence[randomPosition]; 46 result.sequence[randomPosition] = temp; 47 } 48 return result; 49 50 } 35 51 36 52 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java
r1559 r1568 71 71 * @return Cost of substitution of the character in str1 by the one in str2 72 72 */ 73 private floatsimilarity(int i, int j) {73 private double similarity(int i, int j) { 74 74 return submat.getDistance(input1[i - 1], input2[j - 1]); 75 75 } … … 101 101 // F(i,0) = max { F(i-1,0), F(i-1,j)-T j=1,...,m 102 102 103 floatfirstRowLeftScore = matrix[i-1][0].getScore();103 double firstRowLeftScore = matrix[i-1][0].getScore(); 104 104 //for sequences of length 1 105 floattempMax;105 double tempMax; 106 106 int maxRowIndex; 107 107 if(length2 == 1) { … … 138 138 matrix[i][0].setXvalue(input1[i-1]); 139 139 matrix[i][0].setYvalue(-2); 140 141 140 } 142 141 else { … … 147 146 148 147 for (int j = 1; j < length2; j++) { 149 floatdiagScore = matrix[i - 1][j - 1].getScore() + similarity(i, j);150 floatupScore = matrix[i][j - 1].getScore() + submat.getGapPenalty();151 floatleftScore = matrix[i - 1][j].getScore() + submat.getGapPenalty();148 double diagScore = matrix[i - 1][j - 1].getScore() + similarity(i, j); 149 double upScore = matrix[i][j - 1].getScore() + submat.getGapPenalty(); 150 double leftScore = matrix[i - 1][j].getScore() + submat.getGapPenalty(); 152 151 153 152 matrix[i][j].setScore(Math.max(diagScore,Math.max(upScore, Math.max(leftScore,matrix[i][0].getScore())))); … … 207 206 * Get the alignment score between the two input strings. 208 207 */ 209 public floatgetAlignmentScore() {208 public double getAlignmentScore() { 210 209 return matrix[length1+1][0].getScore(); 211 210 } … … 213 212 214 213 215 216 /**217 * given the bottom right corner point trace back the top left conrner. at218 * entry: i, j hold bottom right (end of Aligment coords) at return: hold219 * top left (start of Alignment coords)220 */221 214 private int[] traceback(int i, int j) { 222 215 … … 225 218 } 226 219 227 public voidtraceback() {220 public List<Match> traceback() { 228 221 MatrixEntry tmp = matrix[length1+1][0]; 229 222 String aligned1 = ""; … … 266 259 System.out.println(aligned1); 267 260 System.out.println(aligned2); 261 return null; 268 262 } 269 263 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java
r1554 r1568 29 29 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) 30 30 */ 31 public floatgetDistance(int pos1, int pos2) {31 public double getDistance(int pos1, int pos2) { 32 32 return maxValue - (input1[pos1] - input2[pos2]); 33 33 } … … 49 49 50 50 @Override 51 public floatgetGapPenalty() {51 public double getGapPenalty() { 52 52 return -maxValue; 53 53 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java
r1554 r1568 29 29 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) 30 30 */ 31 public floatgetDistance(int pos1, int pos2) {31 public double 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 floatgetGapPenalty() {43 public double getGapPenalty() { 44 44 return -range-1; 45 45 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java
r1559 r1568 26 26 private TriangleMatrix matrix; 27 27 private SymbolMap<ITaskInstance, ITask> uniqueTasks; 28 private floatgapPenalty;29 private floatpositiveThreshold;28 private double gapPenalty; 29 private double positiveThreshold; 30 30 31 31 public ObjectDistanceSubstitionMatrix( … … 40 40 41 41 @Override 42 public floatgetGapPenalty() {42 public double getGapPenalty() { 43 43 return gapPenalty; 44 44 } … … 48 48 int index = 0; 49 49 //TODO We need to determine this parameter before generating the matrix.. 50 float meandistance = 18;50 //float meandistance = 18; 51 51 //TODO We need to determine this parameter before generating the matrix.. 52 52 float maxDistance =34; … … 58 58 eti1 = (IEventTaskInstance) obj1; 59 59 } 60 //System.out.println(eti1.getTask().toString()); 60 61 61 62 for (Iterator<ITaskInstance> jt = uniqueTasks.getSymbols() … … 121 122 122 123 @Override 123 public floatgetDistance(int taskId1, int taskId2) {124 public double getDistance(int taskId1, int taskId2) { 124 125 //System.out.println("Taskid1: " + taskId1 + " Taskid2: " + taskId2 + " Idmapping1: " + idmapping.get(taskId1) + " Idmapping2: " + idmapping.get(taskId2)); 125 126 return matrix.get(idmapping.get(taskId1),idmapping.get(taskId2)); -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java
r1554 r1568 11 11 12 12 13 public floatgetDistance(int pos1, int pos2);13 public double getDistance(int pos1, int pos2); 14 14 15 public floatgetGapPenalty();15 public double getGapPenalty(); 16 16 17 17 public void generate(); -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java
r1558 r1568 3 3 public class TriangleMatrix { 4 4 5 private float[] matrix;5 private double[] matrix; 6 6 private int size; 7 7 8 8 public TriangleMatrix(int size) { 9 9 this.size = size; 10 matrix = new float[size*(size+1)/2];10 matrix = new double [size*(size+1)/2]; 11 11 } 12 12 13 public floatget(int first, int second) {13 public double get(int first, int second) { 14 14 int row = Math.min(first, second); 15 15 int col = Math.max(first, second); … … 18 18 } 19 19 20 public void set(int first, int second, floatvalue) {20 public void set(int first, int second, double value) { 21 21 int row = Math.min(first, second); 22 22 int col = Math.max(first, second);
Note: See TracChangeset
for help on using the changeset viewer.