source: trunk/autoquest-plugin-alignment/src/main/java/de/ugoe/cs/autoquest/plugin/alignment/DifferenceSubstitutionMatrix.java @ 1314

Last change on this file since 1314 was 1314, checked in by rkrimmel, 11 years ago

Hopefully resolved svn issues

File size: 1018 bytes
Line 
1/**
2 *
3 */
4package de.ugoe.cs.autoquest.plugin.alignment;
5
6/**
7 * @author Ralph Krimmel
8 *
9 */
10public class DifferenceSubstitutionMatrix implements SubstitutionMatrix {
11
12        private int[] input1;
13        private int[] input2;
14        private int maxValue;
15       
16        public DifferenceSubstitutionMatrix(int[] input1,int[] input2) {
17                this.input1 = input1;
18                this.input2 = input2;
19                this.maxValue = getMaxValue();
20        }
21       
22        /* (non-Javadoc)
23         * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int)
24         */
25        public double getDistance(int pos1, int pos2) {
26                return maxValue - (input1[pos1] - input2[pos2]);
27        }
28       
29        private int getMaxValue() {
30                int max = input1[0];
31                for (int i=0; i < input1.length; i++) {
32                        if(input1[i] > max) {
33                                max = input1[i];
34                        }
35                }
36                for (int j=0; j < input2.length; j++) {
37                        if(input2[j] > max) {
38                                max = input2[j];
39                        }
40                }
41                return max;
42        }
43
44        @Override
45        public double getGapPenalty() {
46                return -maxValue;
47        }
48
49        @Override
50        public String info() {
51                return "Max Value: " + maxValue;
52        }
53
54}
Note: See TracBrowser for help on using the repository browser.