source: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/DifferenceSubstitutionMatrix.java @ 1617

Last change on this file since 1617 was 1580, checked in by rkrimmel, 10 years ago

Further code cleanup

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