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

Last change on this file since 1324 was 1324, checked in by rkrimmel, 10 years ago
File size: 1.2 KB
Line 
1/**
2 *
3 */
4package de.ugoe.cs.autoquest.plugin.alignment.substitution;
5
6import java.util.Collection;
7import java.util.List;
8
9import de.ugoe.cs.autoquest.eventcore.Event;
10
11/**
12 * @author Ralph Krimmel
13 *
14 */
15public 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
59        @Override
60        public void generate(Collection<List<Event>> eventList) {
61                // TODO Auto-generated method stub
62               
63        }
64
65}
Note: See TracBrowser for help on using the repository browser.