Commit 5adc0c52 authored by lafabregue's avatar lafabregue

Full switch on DistanceModel usage

parent e1663488
...@@ -17,6 +17,7 @@ public abstract class Attribute implements Serializable { ...@@ -17,6 +17,7 @@ public abstract class Attribute implements Serializable {
public static final String INTERVAL_ATTRIBUTE = "INTERVAL ATTRIBUTE"; public static final String INTERVAL_ATTRIBUTE = "INTERVAL ATTRIBUTE";
public static final String NULERICAL_ATTRIBUTE = "NUMERICAL ATTRIBUTE"; public static final String NULERICAL_ATTRIBUTE = "NUMERICAL ATTRIBUTE";
public static final String SEQUENCE_ATTRIBUTE = "SEQUENCE ATTRIBUTE"; public static final String SEQUENCE_ATTRIBUTE = "SEQUENCE ATTRIBUTE";
public static final String MULTIDIM_SEQUENCE_ATTRIBUTE = "MULTIDIM SEQUENCE ATTRIBUTE";
public static final String STRUCTURED_ATTRIBUTE = "STRUCTURED ATTRIBUTE"; public static final String STRUCTURED_ATTRIBUTE = "STRUCTURED ATTRIBUTE";
public static final String SYMBOLIC_ATTRIBUTE = "SYMBOLIC ATTRIBUTE"; public static final String SYMBOLIC_ATTRIBUTE = "SYMBOLIC ATTRIBUTE";
public static final String SYMBOLIC_HISTOGRAMS_ATTRIBUTE = "SYMBOLIC HISTOGRAMS ATTRIBUTE"; public static final String SYMBOLIC_HISTOGRAMS_ATTRIBUTE = "SYMBOLIC HISTOGRAMS ATTRIBUTE";
......
...@@ -340,7 +340,7 @@ public class AttributeDCMDSequence extends Attribute { ...@@ -340,7 +340,7 @@ public class AttributeDCMDSequence extends Attribute {
@Override @Override
public String getTypeAttribute() { public String getTypeAttribute() {
return Attribute.SEQUENCE_ATTRIBUTE; return Attribute.MULTIDIM_SEQUENCE_ATTRIBUTE;
} }
protected static int ArgMin3(final double a, final double b, final double c) { protected static int ArgMin3(final double a, final double b, final double c) {
......
package jcl.data.attribute; package jcl.data.attribute;
import static jcl.data.distance.Tools.*; import static jcl.data.distance.Tools.*;
import java.util.Arrays;
import jcl.data.distance.sequential.DistanceDTWHardConstrainedMD;
import jcl.data.distance.sequential.DistanceDTWMD;
import jcl.data.distance.sequential.ParameterDTWConstrained;
import jcl.data.distance.sequential.ParameterDTW;
import jcl.data.sequence.DoubleTabArrayList;
/** /**
* Cette classe permet d'instancier un attribut de type séquence de t-uplets * Cette classe permet d'instancier un attribut de type séquence de t-uplets
...@@ -31,10 +24,6 @@ public class AttributeHardConstrainedMultiDimSequence extends Attribute { ...@@ -31,10 +24,6 @@ public class AttributeHardConstrainedMultiDimSequence extends Attribute {
public final static int NB_ITERATIONS = 15; public final static int NB_ITERATIONS = 15;
private final static int RIEN = -1;
private final static int DIAGONALE = 0;
private final static int GAUCHE = 1;
private final static int HAUT = 2;
// contient une sequence de tuples. // contient une sequence de tuples.
double[][] sequence; double[][] sequence;
...@@ -161,7 +150,7 @@ public class AttributeHardConstrainedMultiDimSequence extends Attribute { ...@@ -161,7 +150,7 @@ public class AttributeHardConstrainedMultiDimSequence extends Attribute {
@Override @Override
public String getTypeAttribute() { public String getTypeAttribute() {
return Attribute.SEQUENCE_ATTRIBUTE; return Attribute.MULTIDIM_SEQUENCE_ATTRIBUTE;
} }
public static final int ArgMin3(final double a, final double b, final double c) { public static final int ArgMin3(final double a, final double b, final double c) {
......
...@@ -16,8 +16,8 @@ import java.util.TreeMap; ...@@ -16,8 +16,8 @@ import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import jcl.data.concepts.Concept; import jcl.data.concepts.Concept;
import jcl.data.distance.DistanceSymbolicHistogram; import jcl.data.distance.unitary.DistanceSymbolicHistogram;
import jcl.data.distance.ParameterSymbolicHistogramDistance; import jcl.data.distance.unitary.ParameterSymbolicHistogramDistance;
import jcl.utils.Couple; import jcl.utils.Couple;
import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFactory;
......
...@@ -93,7 +93,7 @@ public class AttributeMDMRHSequence extends Attribute { ...@@ -93,7 +93,7 @@ public class AttributeMDMRHSequence extends Attribute {
@Override @Override
public String getTypeAttribute() { public String getTypeAttribute() {
return Attribute.SEQUENCE_ATTRIBUTE; return Attribute.MULTIDIM_SEQUENCE_ATTRIBUTE;
} }
public static double Min3(final double a, final double b, final double c) { public static double Min3(final double a, final double b, final double c) {
......
...@@ -140,7 +140,7 @@ public class AttributeMDMRSequence extends Attribute { ...@@ -140,7 +140,7 @@ public class AttributeMDMRSequence extends Attribute {
@Override @Override
public String getTypeAttribute() { public String getTypeAttribute() {
return Attribute.SEQUENCE_ATTRIBUTE; return Attribute.MULTIDIM_SEQUENCE_ATTRIBUTE;
} }
public static double Min3(final double a, final double b, final double c) { public static double Min3(final double a, final double b, final double c) {
......
...@@ -151,14 +151,9 @@ public class AttributeMultiDimSequence extends Attribute { ...@@ -151,14 +151,9 @@ public class AttributeMultiDimSequence extends Attribute {
} }
@Override @Override
public String getTypeAttribute() { public String getTypeAttribute() {
return Attribute.SEQUENCE_ATTRIBUTE; return Attribute.MULTIDIM_SEQUENCE_ATTRIBUTE;
} }
public static int ArgMin3(final double a, final double b, final double c) { public static int ArgMin3(final double a, final double b, final double c) {
......
...@@ -2,8 +2,8 @@ package jcl.data.attribute; ...@@ -2,8 +2,8 @@ package jcl.data.attribute;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import jcl.data.distance.CategorialDistance;
import jcl.data.distance.EmptyDistanceParameter; import jcl.data.distance.EmptyDistanceParameter;
import jcl.data.distance.unitary.CategorialDistance;
/** /**
* <p> * <p>
......
package jcl.data.distance; package jcl.data.distance;
import jcl.data.attribute.Attribute; import jcl.data.attribute.Attribute;
import jcl.weights.Weights;
/** /**
* Generic Distance interface. * Generic Distance interface.
...@@ -8,7 +9,11 @@ import jcl.data.attribute.Attribute; ...@@ -8,7 +9,11 @@ import jcl.data.attribute.Attribute;
* @param <A> Attribute * @param <A> Attribute
* @param <P> Parameter * @param <P> Parameter
*/ */
public interface Distance<A extends Attribute, P extends DistanceParameter> { public abstract class Distance<A extends Attribute, P extends DistanceParameter> {
public abstract double compute(A a1, A a2, P p); public abstract double compute(A a1, A a2, P p);
public double compute(A a1, A a2, P p, Weights w) {
return compute(a1, a2, p);
}
} }
...@@ -15,15 +15,17 @@ import jcl.data.attribute.AttributeMultiDimSequence; ...@@ -15,15 +15,17 @@ import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical; import jcl.data.attribute.AttributeNumerical;
import jcl.data.attribute.AttributeSequence; import jcl.data.attribute.AttributeSequence;
import jcl.data.distance.average.Average; import jcl.data.distance.average.Average;
import jcl.data.distance.average.AverageEuclidean;
import jcl.data.distance.average.AverageParameter; import jcl.data.distance.average.AverageParameter;
import jcl.data.distance.average.EmptyAverageParameter; import jcl.data.distance.average.EmptyAverageParameter;
import jcl.data.distance.average.ParameterDBAMean;
import jcl.data.distance.average.sequential.AverageMDDBAMean; import jcl.data.distance.average.sequential.AverageMDDBAMean;
import jcl.data.distance.average.sequential.AverageMDeuclideanMean; import jcl.data.distance.average.sequential.AverageMDeuclideanMean;
import jcl.data.distance.average.sequential.ParameterDBAMean;
import jcl.data.distance.average.unitary.AverageEuclidean;
import jcl.data.distance.sequential.DistanceDTW; import jcl.data.distance.sequential.DistanceDTW;
import jcl.data.distance.sequential.DistanceDTWMD; import jcl.data.distance.sequential.DistanceDTWMD;
import jcl.data.distance.sequential.DistanceEuclideanMD;
import jcl.data.distance.sequential.ParameterDTW; import jcl.data.distance.sequential.ParameterDTW;
import jcl.data.distance.unitary.NumericalEuclideanDistance;
import jcl.weights.ClassificationWeights; import jcl.weights.ClassificationWeights;
/** /**
...@@ -109,7 +111,7 @@ public class DistanceModel { ...@@ -109,7 +111,7 @@ public class DistanceModel {
for (int i = 0; i < dWeights.length; i++) { for (int i = 0; i < dWeights.length; i++) {
dWeights[i]=weights.getWeights(0).getWeight(i);//? dWeights[i]=weights.getWeights(0).getWeight(i);//?
} }
MetaDistance metaDistance = new MetaDistanceWeightedSquaredEuclidean(dWeights); //defines the way the two scores are combined, by default it is euclidean MetaDistance metaDistance = new MetaDistanceWeightedSquaredEuclidean(weights); //defines the way the two scores are combined, by default it is euclidean
DistanceModel model = new DistanceModel(distances, metaDistance, averages); DistanceModel model = new DistanceModel(distances, metaDistance, averages);
return model; return model;
} }
...@@ -124,18 +126,22 @@ public class DistanceModel { ...@@ -124,18 +126,22 @@ public class DistanceModel {
Average[] averages = new Average[dataObject.getNbAttributes()]; Average[] averages = new Average[dataObject.getNbAttributes()];
for (int i=0; i<distances.length;i++) { for (int i=0; i<distances.length;i++) {
distances[i]=NumericalEuclideanDistance.getInstance();// uses euclidian distance for every attribute // uses euclidian distance for every attribute
if (dataObject.getAttribute(i) instanceof AttributeMultiDimSequence) if (dataObject.getAttribute(i) instanceof AttributeMultiDimSequence) {
distances[i] = DistanceEuclideanMD.getInstance();// uses DTWMD distances for sequential attributes ...
averages[i]=AverageMDeuclideanMean.getInstance();// uses MultiDim euclidean mean for sequential attributes ... averages[i]=AverageMDeuclideanMean.getInstance();// uses MultiDim euclidean mean for sequential attributes ...
else }
averages[i] = AverageEuclidean.getInstance();// and classic euclidean mean for numerical attributes else {
distances[i]=NumericalEuclideanDistance.getInstance();//... and euclidean distances for numerical attributes
averages[i] = AverageEuclidean.getInstance();// ... and classic euclidean mean for numerical attributes
}
} }
double[] dWeights = new double[weights.getNbAttributes()]; double[] dWeights = new double[weights.getNbAttributes()];
for (int i = 0; i < dWeights.length; i++) { for (int i = 0; i < dWeights.length; i++) {
dWeights[i]=weights.getWeights(0).getWeight(i);//? dWeights[i]=weights.getWeights(0).getWeight(i);//?
} }
MetaDistance metaDistance = new MetaDistanceWeightedSquaredEuclidean(dWeights); // defines the way the two scores are combined, by default it is Euclidian MetaDistance metaDistance = new MetaDistanceWeightedSquaredEuclidean(weights); // defines the way the two scores are combined, by default it is Euclidian
DistanceModel model = new DistanceModel(distances, metaDistance, averages); DistanceModel model = new DistanceModel(distances, metaDistance, averages);
return model; return model;
} }
......
...@@ -17,7 +17,8 @@ public class MetaDistanceSquaredEuclidean implements MetaDistance { ...@@ -17,7 +17,8 @@ public class MetaDistanceSquaredEuclidean implements MetaDistance {
@Override @Override
public double compute(DataObject o1, DataObject o2, Distance<Attribute,DistanceParameter>[] distances,DistanceParameter[] params) { public double compute(DataObject o1, DataObject o2, Distance<Attribute,DistanceParameter>[] distances,
DistanceParameter[] params) {
double res = 0.0; double res = 0.0;
for(int i=0;i<o1.getNbAttributes();i++){ for(int i=0;i<o1.getNbAttributes();i++){
......
...@@ -2,16 +2,17 @@ package jcl.data.distance; ...@@ -2,16 +2,17 @@ package jcl.data.distance;
import jcl.data.DataObject; import jcl.data.DataObject;
import jcl.data.attribute.Attribute; import jcl.data.attribute.Attribute;
import jcl.weights.ClassificationWeights;
public class MetaDistanceWeightedSquaredEuclidean implements MetaDistance { public class MetaDistanceWeightedSquaredEuclidean implements MetaDistance {
public double[] weights; public ClassificationWeights weights;
/** /**
* Meta distance using weights * Meta distance using weights
* @param weights double tab giving the weights of the attributes * @param weights double tab giving the weights of the attributes
*/ */
public MetaDistanceWeightedSquaredEuclidean(double[] weights) { public MetaDistanceWeightedSquaredEuclidean(ClassificationWeights weights) {
this.weights = weights; this.weights = weights;
} }
...@@ -20,7 +21,8 @@ public class MetaDistanceWeightedSquaredEuclidean implements MetaDistance { ...@@ -20,7 +21,8 @@ public class MetaDistanceWeightedSquaredEuclidean implements MetaDistance {
double res = 0.0; double res = 0.0;
for (int i = 0; i < o1.getNbAttributes(); i++) { for (int i = 0; i < o1.getNbAttributes(); i++) {
double tmp = weights[i] * distances[i].compute(o1.getAttribute(i), o2.getAttribute(i), params[i]); double tmp = weights.getGlobalWeights().getWeight(i) * distances[i]
.compute(o1.getAttribute(i), o2.getAttribute(i), params[i], weights.getGlobalSubWeights()[i]);
res += tmp * tmp; res += tmp * tmp;
} }
return res; return res;
......
...@@ -6,12 +6,15 @@ import java.util.ArrayList; ...@@ -6,12 +6,15 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import jcl.data.attribute.AttributeDCMDSequence; import jcl.data.attribute.AttributeDCMDSequence;
import jcl.weights.Weights;
public class Tools { public class Tools {
public final static double Min3(final double a, final double b, final double c) { public final static double Min3(final double a, final double b, final double c) {
return (a < b) ? ((a < c) ? a : c) : (b < c) ? b : c; return (a < b) ? ((a < c) ? a : c) : (b < c) ? b : c;
} }
public final static double distanceTo(double[] a, double[] b) { public final static double distanceTo(double[] a, double[] b) {
double res = 0.0, tmp; double res = 0.0, tmp;
for (int i = 0; i < a.length; i++) { for (int i = 0; i < a.length; i++) {
...@@ -21,6 +24,15 @@ public class Tools { ...@@ -21,6 +24,15 @@ public class Tools {
return res; return res;
} }
public final static double distanceTo(double[] a, double[] b, Weights weights) {
double res = 0.0, tmp;
for (int i = 0; i < a.length; i++) {
tmp = (a[i] - b[i]);
res += weights.getWeight(i) * tmp * tmp;
}
return res;
}
public static double distanceTo(double a, double b) { public static double distanceTo(double a, double b) {
return (a - b) * (a - b); return (a - b) * (a - b);
} }
......
...@@ -5,7 +5,6 @@ import static jcl.data.distance.Tools.distanceTo; ...@@ -5,7 +5,6 @@ import static jcl.data.distance.Tools.distanceTo;
import jcl.data.attribute.Attribute; import jcl.data.attribute.Attribute;
import jcl.data.attribute.AttributeMultiDimSequence; import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.average.Average; import jcl.data.distance.average.Average;
import jcl.data.distance.average.ParameterDBAMean;
import jcl.data.sequence.DoubleTabArrayList; import jcl.data.sequence.DoubleTabArrayList;
/** /**
......
package jcl.data.distance.average; package jcl.data.distance.average.sequential;
import jcl.data.distance.average.AverageParameter;
/** /**
* Parameters used by DBA mean * Parameters used by DBA mean
......
package jcl.data.distance.average; package jcl.data.distance.average.unitary;
import jcl.data.attribute.Attribute; import jcl.data.attribute.Attribute;
import jcl.data.attribute.AttributeNumerical; import jcl.data.attribute.AttributeNumerical;
import jcl.data.distance.average.Average;
import jcl.data.distance.average.EmptyAverageParameter;
/** /**
* Class implementing the averaging method to use for numerical attributes * Class implementing the averaging method to use for numerical attributes
* @author Jean-Noël Balanche * @author Jean-Noël Balanche
......
...@@ -7,11 +7,12 @@ import jcl.data.attribute.AttributeSequence; ...@@ -7,11 +7,12 @@ import jcl.data.attribute.AttributeSequence;
import jcl.data.distance.Distance; import jcl.data.distance.Distance;
public class DistanceDTW implements Distance<AttributeSequence,ParameterDTW> { public class DistanceDTW extends Distance<AttributeSequence,ParameterDTW> {
private static DistanceDTW instance = new DistanceDTW(); private static DistanceDTW instance = new DistanceDTW();
private DistanceDTW(){} private DistanceDTW(){}
public static DistanceDTW getInstance(){ public static DistanceDTW getInstance(){
return instance; return instance;
} }
......
...@@ -5,8 +5,9 @@ import static jcl.data.distance.Tools.Min3; ...@@ -5,8 +5,9 @@ import static jcl.data.distance.Tools.Min3;
import static jcl.data.distance.Tools.distanceTo; import static jcl.data.distance.Tools.distanceTo;
import jcl.data.attribute.AttributeDCMDSequence; import jcl.data.attribute.AttributeDCMDSequence;
import jcl.data.distance.Distance; import jcl.data.distance.Distance;
import jcl.weights.Weights;
public class DistanceDTWConstrainedByDate implements Distance<AttributeDCMDSequence, ParameterDTWConstrained> { public class DistanceDTWConstrainedByDate extends Distance<AttributeDCMDSequence, ParameterDTWConstrained> {
private static DistanceDTWConstrainedByDate instance = new DistanceDTWConstrainedByDate(); private static DistanceDTWConstrainedByDate instance = new DistanceDTWConstrainedByDate();
...@@ -67,5 +68,60 @@ public class DistanceDTWConstrainedByDate implements Distance<AttributeDCMDSeque ...@@ -67,5 +68,60 @@ public class DistanceDTWConstrainedByDate implements Distance<AttributeDCMDSeque
return matriceW[tailleS - 1][tailleT - 1]; return matriceW[tailleS - 1][tailleT - 1];
} }
@Override
public double compute(AttributeDCMDSequence S, AttributeDCMDSequence T, ParameterDTWConstrained p, Weights weights) {
if (weights == null) {
return compute(S, T, p);
}
final int tailleS = S.getNbTuples();
final int tailleT = T.getNbTuples();
int i, j;
double[][] matriceW = p.weightMatrix;
int dateDifference = p.constraint;
if (tailleS > matriceW.length || tailleT > matriceW[0].length || tailleS == 0 || tailleT == 0) {
System.err.println("attention seq max dépassée!! ou taille=0");
return Double.NaN;
}
// Remplissage première colonne et première ligne de la matrice
if (abs(S.dates[0] - T.dates[0]) < dateDifference) {
matriceW[0][0] = distanceTo(S.sequence[0], T.sequence[0], weights);
} else {
matriceW[0][0] = Integer.MAX_VALUE;
}
for (i = 1; i < tailleS; i++) {
if (abs(S.dates[i] - T.dates[0]) < dateDifference) {
matriceW[i][0] = matriceW[i - 1][0] + distanceTo(S.sequence[i], T.sequence[0], weights);
} else {
matriceW[i][0] = Integer.MAX_VALUE;
}
}
for (j = 1; j < tailleT; j++) {
if (abs(S.dates[0] - T.dates[j]) < dateDifference) {
matriceW[0][j] = matriceW[0][j - 1] + distanceTo(T.sequence[j], S.sequence[0], weights);
} else {
matriceW[0][j] = Integer.MAX_VALUE;
}
}
// Calcul de la matrice
for (i = 1; i < tailleS; i++) {
for (j = 1; j < tailleT; j++) {
if (abs(S.dates[i] - T.dates[j]) < dateDifference) {
matriceW[i][j] = Min3(matriceW[i - 1][j - 1], matriceW[i][j - 1], matriceW[i - 1][j])
+ distanceTo(S.sequence[i], T.sequence[j], weights);
} else {
matriceW[i][j] = Integer.MAX_VALUE;
}
}
}
return matriceW[tailleS - 1][tailleT - 1];
}
} }
...@@ -4,8 +4,9 @@ import static jcl.data.distance.Tools.Min3; ...@@ -4,8 +4,9 @@ import static jcl.data.distance.Tools.Min3;
import static jcl.data.distance.Tools.distanceTo; import static jcl.data.distance.Tools.distanceTo;
import jcl.data.attribute.AttributeMultiDimSequence; import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.Distance; import jcl.data.distance.Distance;
import jcl.weights.Weights;
public class DistanceDTWHardConstrainedMD implements Distance<AttributeMultiDimSequence, ParameterDTWConstrained> { public class DistanceDTWHardConstrainedMD extends Distance<AttributeMultiDimSequence, ParameterDTWConstrained> {
private static DistanceDTWHardConstrainedMD instance = new DistanceDTWHardConstrainedMD(); private static DistanceDTWHardConstrainedMD instance = new DistanceDTWHardConstrainedMD();
...@@ -58,6 +59,50 @@ public class DistanceDTWHardConstrainedMD implements Distance<AttributeMultiDimS ...@@ -58,6 +59,50 @@ public class DistanceDTWHardConstrainedMD implements Distance<AttributeMultiDimS
return matriceW[tailleS - 1][tailleT - 1]; return matriceW[tailleS - 1][tailleT - 1];
} }
@Override
public double compute(AttributeMultiDimSequence S, AttributeMultiDimSequence T, ParameterDTWConstrained p, Weights weights) {
int deplacement = p.constraint;
final int tailleS = S.getNbTuples();
final int tailleT = T.getNbTuples();
int i, j;
double[][] matriceW = p.weightMatrix;
int[][] jIndexes = p.jIndexes;
if (tailleS > matriceW.length || tailleT > matriceW[0].length || tailleS == 0 || tailleT == 0) {
System.err.println("attention seq max dépassée!! ou taille=0");
return Double.NaN;
}
bresenhamConstraint(0, 0, tailleT - 1, tailleS - 1, deplacement, matriceW, jIndexes);
// Remplissage première colonne et première ligne de la matrice
matriceW[0][0] = distanceTo(S.sequence[0], T.sequence[0], weights);
i = 1;
while (jIndexes[i][0] == 0) { //tant que jMin de la ligne i est egal a 0
matriceW[i][0] = matriceW[i - 1][0] + distanceTo(S.sequence[i], T.sequence[0], weights);
jIndexes[i][0] = 1;
i++;
}
for (j = 1; j < jIndexes[0][1]; j++) { //pour j de 1 a jMax
matriceW[0][j] = matriceW[0][j - 1] + distanceTo(T.sequence[j], S.sequence[0], weights);
}
// Calcul de la matrice
for (i = 1; i < tailleS; i++) {
for (j = jIndexes[i][0]; j < jIndexes[i][1]; j++) { //pour j de jMin a jMax
matriceW[i][j] = Min3(matriceW[i - 1][j - 1], matriceW[i][j - 1], matriceW[i - 1][j])
+ distanceTo(S.sequence[i], T.sequence[j], weights);
}
}
return matriceW[tailleS - 1][tailleT - 1];
}
private static final void bresenhamConstraint(int x1, int y1, int x2, int y2, int deplacement, double[][] matriceW, int[][] jIndexes) { private static final void bresenhamConstraint(int x1, int y1, int x2, int y2, int deplacement, double[][] matriceW, int[][] jIndexes) {
if (((double) (y2 - y1)) / ((double) x2 - x1) <= 1.0) { //si la pente est <1 i.e., la matrice est plus large que haute if (((double) (y2 - y1)) / ((double) x2 - x1) <= 1.0) { //si la pente est <1 i.e., la matrice est plus large que haute
......
package jcl.data.distance.sequential; package jcl.data.distance.sequential;
import static jcl.data.distance.Tools.Min3;
import static jcl.data.distance.Tools.distanceTo;
import jcl.data.attribute.AttributeMultiDimSequence; import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.Distance; import jcl.data.distance.Distance;
import static jcl.data.distance.Tools.distanceTo; import jcl.weights.Weights;
import static jcl.data.distance.Tools.Min3;
public class DistanceDTWMD extends Distance<AttributeMultiDimSequence,ParameterDTW> {
public class DistanceDTWMD implements Distance<AttributeMultiDimSequence,ParameterDTW> {
private static DistanceDTWMD instance = new DistanceDTWMD(); private static DistanceDTWMD instance = new DistanceDTWMD();
private DistanceDTWMD(){} private DistanceDTWMD(){}
public static DistanceDTWMD getInstance(){ public static DistanceDTWMD getInstance(){
return instance; return instance;
} }
...@@ -51,4 +51,45 @@ public class DistanceDTWMD implements Distance<AttributeMultiDimSequence,Paramet ...@@ -51,4 +51,45 @@ public class DistanceDTWMD implements Distance<AttributeMultiDimSequence,Paramet
return matriceW[tailleS - 1][tailleT - 1]; return matriceW[tailleS - 1][tailleT - 1];
} }