Rev | Line | |
---|
[1314] | 1 | /** |
---|
| 2 | * |
---|
| 3 | */ |
---|
[1323] | 4 | package de.ugoe.cs.autoquest.plugin.alignment.substitution; |
---|
[1314] | 5 | |
---|
[1324] | 6 | import java.util.Collection; |
---|
| 7 | import java.util.List; |
---|
| 8 | |
---|
| 9 | import de.ugoe.cs.autoquest.eventcore.Event; |
---|
| 10 | |
---|
[1314] | 11 | /** |
---|
| 12 | * @author Ralph Krimmel |
---|
| 13 | * |
---|
| 14 | */ |
---|
| 15 | public class DifferenceSubstitutionMatrix implements SubstitutionMatrix { |
---|
| 16 | |
---|
| 17 | private int[] input1; |
---|
| 18 | private int[] input2; |
---|
| 19 | private int maxValue; |
---|
| 20 | |
---|
| 21 | public DifferenceSubstitutionMatrix(int[] input1,int[] input2) { |
---|
| 22 | this.input1 = input1; |
---|
| 23 | this.input2 = input2; |
---|
| 24 | this.maxValue = getMaxValue(); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | /* (non-Javadoc) |
---|
| 28 | * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) |
---|
| 29 | */ |
---|
| 30 | public double getDistance(int pos1, int pos2) { |
---|
| 31 | return maxValue - (input1[pos1] - input2[pos2]); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | private int getMaxValue() { |
---|
| 35 | int max = input1[0]; |
---|
| 36 | for (int i=0; i < input1.length; i++) { |
---|
| 37 | if(input1[i] > max) { |
---|
| 38 | max = input1[i]; |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | for (int j=0; j < input2.length; j++) { |
---|
| 42 | if(input2[j] > max) { |
---|
| 43 | max = input2[j]; |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | return max; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | @Override |
---|
| 50 | public double getGapPenalty() { |
---|
| 51 | return -maxValue; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | @Override |
---|
| 55 | public String info() { |
---|
| 56 | return "Max Value: " + maxValue; |
---|
| 57 | } |
---|
| 58 | |
---|
[1324] | 59 | @Override |
---|
| 60 | public void generate(Collection<List<Event>> eventList) { |
---|
| 61 | // TODO Auto-generated method stub |
---|
| 62 | |
---|
| 63 | } |
---|
| 64 | |
---|
[1314] | 65 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.