Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatrixEntry.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatrixEntry.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatrixEntry.java	(revision 1568)
@@ -2,5 +2,5 @@
 
 public class MatrixEntry {
-	private float score;
+	private double score;
 	private MatrixEntry previous;
 	private int xvalue;
@@ -15,8 +15,8 @@
 	}
 
-	public float getScore() {
+	public double getScore() {
 		return score;
 	}
-	public void setScore(float score) {
+	public void setScore(double score) {
 		this.score = score;
 	}
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java	(revision 1568)
@@ -3,4 +3,5 @@
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Random;
 
 public class NumberSequence implements Serializable {
@@ -33,4 +34,19 @@
 		System.out.println();
 	}
+	
+	public NumberSequence shuffle(){
+		NumberSequence result = new NumberSequence(sequence.length);
+		result.setSequence(this.sequence);
+		Random rgen = new Random();
+		
+		for (int i=0; i<result.sequence.length; i++) {
+		    int randomPosition = rgen.nextInt(result.sequence.length);
+		    int temp = result.sequence[i];
+		    result.sequence[i] = result.sequence[randomPosition];
+		    result.sequence[randomPosition] = temp;
+		}
+		return result;
+		
+	}
 
 }
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java	(revision 1568)
@@ -71,5 +71,5 @@
 	 * @return Cost of substitution of the character in str1 by the one in str2
 	 */
-	private float similarity(int i, int j) { 
+	private double similarity(int i, int j) { 
 		return submat.getDistance(input1[i - 1], input2[j - 1]);
 	}
@@ -101,7 +101,7 @@
 			// F(i,0) = max { F(i-1,0), F(i-1,j)-T  j=1,...,m
 			
-			float firstRowLeftScore = matrix[i-1][0].getScore();
+			double firstRowLeftScore = matrix[i-1][0].getScore();
 			//for sequences of length 1
-			float tempMax;
+			double tempMax;
 			int maxRowIndex;
 			if(length2 == 1) {
@@ -138,5 +138,4 @@
 				matrix[i][0].setXvalue(input1[i-1]);
 				matrix[i][0].setYvalue(-2);
-				
 			}
 			else { 
@@ -147,7 +146,7 @@
 			
 			for (int j = 1; j < length2; j++) {
-				float diagScore = matrix[i - 1][j - 1].getScore() + similarity(i, j);
-				float upScore = matrix[i][j - 1].getScore() + submat.getGapPenalty();
-				float leftScore = matrix[i - 1][j].getScore() + submat.getGapPenalty();
+				double diagScore = matrix[i - 1][j - 1].getScore() + similarity(i, j);
+				double upScore = matrix[i][j - 1].getScore() + submat.getGapPenalty();
+				double leftScore = matrix[i - 1][j].getScore() + submat.getGapPenalty();
 
 				matrix[i][j].setScore(Math.max(diagScore,Math.max(upScore, Math.max(leftScore,matrix[i][0].getScore()))));
@@ -207,5 +206,5 @@
 	 * Get the alignment score between the two input strings.
 	 */
-	public float getAlignmentScore() {
+	public double getAlignmentScore() {
 		return matrix[length1+1][0].getScore();
 	}
@@ -213,10 +212,4 @@
 	
 	
-	
-	/**
-	 * given the bottom right corner point trace back the top left conrner. at
-	 * entry: i, j hold bottom right (end of Aligment coords) at return: hold
-	 * top left (start of Alignment coords)
-	 */
 	private int[] traceback(int i, int j) {
 		
@@ -225,5 +218,5 @@
 	}
 	
-	public void traceback() {
+	public List<Match> traceback() {
 		MatrixEntry tmp = matrix[length1+1][0];
 		String aligned1 = "";
@@ -266,4 +259,5 @@
 		System.out.println(aligned1);
 		System.out.println(aligned2);
+		return null;
 	}
 	
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java	(revision 1568)
@@ -29,5 +29,5 @@
 	 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int)
 	 */
-	public float getDistance(int pos1, int pos2) {
+	public double getDistance(int pos1, int pos2) {
 		return maxValue - (input1[pos1] - input2[pos2]);
 	}
@@ -49,5 +49,5 @@
 
 	@Override
-	public float getGapPenalty() {
+	public double getGapPenalty() {
 		return -maxValue;
 	}
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java	(revision 1568)
@@ -29,5 +29,5 @@
 	 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int)
 	 */
-	public float getDistance(int pos1, int pos2) {
+	public double getDistance(int pos1, int pos2) {
 		int difference = Math.abs(input1[pos1]-input2[pos2]); 
 		if(difference < range) {
@@ -41,5 +41,5 @@
 
 	@Override
-	public float getGapPenalty() {
+	public double getGapPenalty() {
 		return -range-1;
 	}
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java	(revision 1568)
@@ -26,6 +26,6 @@
 	private TriangleMatrix matrix;
 	private SymbolMap<ITaskInstance, ITask> uniqueTasks;
-	private float gapPenalty; 
-	private float positiveThreshold;
+	private double gapPenalty; 
+	private double positiveThreshold;
 	
 	public ObjectDistanceSubstitionMatrix(
@@ -40,5 +40,5 @@
 
 	@Override
-	public float getGapPenalty() {
+	public double getGapPenalty() {
 		return gapPenalty;
 	}
@@ -48,5 +48,5 @@
 		int index = 0;
 		//TODO We need to determine this parameter before generating the matrix..
-		float meandistance = 18;
+		//float meandistance = 18;
 		//TODO We need to determine this parameter before generating the matrix..
 		float maxDistance =34;
@@ -58,4 +58,5 @@
 				eti1 = (IEventTaskInstance) obj1;
 			}
+			//System.out.println(eti1.getTask().toString());
 		
 			for (Iterator<ITaskInstance> jt = uniqueTasks.getSymbols()
@@ -121,5 +122,5 @@
 
 	@Override
-	public float getDistance(int taskId1, int taskId2) {
+	public double getDistance(int taskId1, int taskId2) {
 		//System.out.println("Taskid1: " + taskId1 + " Taskid2: " + taskId2 + " Idmapping1: " + idmapping.get(taskId1) + " Idmapping2: " + idmapping.get(taskId2));
 		return matrix.get(idmapping.get(taskId1),idmapping.get(taskId2));
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java	(revision 1568)
@@ -11,7 +11,7 @@
 	
 
-	public float getDistance(int pos1, int pos2);
+	public double getDistance(int pos1, int pos2);
 
-	public float getGapPenalty();
+	public double getGapPenalty();
 
 	public void generate();
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java	(revision 1568)
@@ -3,13 +3,13 @@
 public class TriangleMatrix {
 	
-	private float[] matrix;
+	private double[] matrix;
 	private int size;
 	
 	public TriangleMatrix(int size) {
 		this.size = size;
-		matrix = new float [size*(size+1)/2];
+		matrix = new double [size*(size+1)/2];
 	}
 	
-	public float get(int first, int second) {
+	public double get(int first, int second) {
 		int row = Math.min(first, second);
 		int col = Math.max(first, second);
@@ -18,5 +18,5 @@
 	}
 	
-	public void set(int first, int second, float value) {
+	public void set(int first, int second, double value) {
 		int row = Math.min(first, second);
 		int col = Math.max(first, second);
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java	(revision 1559)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java	(revision 1568)
@@ -30,4 +30,5 @@
 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.SmithWatermanRepeated;
 import de.ugoe.cs.autoquest.tasktrees.alignment.substitution.ObjectDistanceSubstitionMatrix;
+import de.ugoe.cs.autoquest.tasktrees.alignment.substitution.TriangleMatrix;
 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
@@ -156,39 +157,76 @@
 		// this is the real rule application. Loop while something is replaced.
 		SymbolMap<ITaskInstance, ITask> uniqueTasks = harmonizeEventTaskInstancesModel(appData);
+
 		ObjectDistanceSubstitionMatrix submat = new ObjectDistanceSubstitionMatrix(
 				uniqueTasks, 5);
 		submat.generate();
 
-		// good tests: 7/8 20/24
+		TriangleMatrix sequenceDistances = new TriangleMatrix(numberseqs.size());
+
 		for (int i = 0; i < numberseqs.size(); i++) {
+			NumberSequence ns1 = numberseqs.get(i);
+			//System.out.print("Sequence " + i + ": ");
+			//ns1.printSequence();
 			for (int j = 0; j < numberseqs.size(); j++) {
+				NumberSequence ns2 = numberseqs.get(j);
+
+				if (i != j) {
+					int smithWatermanThreshold = 10;
+
+					SmithWatermanRepeated twoSequences = new SmithWatermanRepeated(
+							ns1.getSequence(), ns2.getSequence(), submat,
+							smithWatermanThreshold);
+					SmithWatermanRepeated sameSequence1 = new SmithWatermanRepeated(
+							ns1.getSequence(), ns1.getSequence(), submat,
+							smithWatermanThreshold);
+					SmithWatermanRepeated sameSequence2 = new SmithWatermanRepeated(
+							ns2.getSequence(), ns2.getSequence(), submat,
+							smithWatermanThreshold);
+					
+					SmithWatermanRepeated randomSequence = new SmithWatermanRepeated(
+							ns1.shuffle().getSequence(),ns2.shuffle().getSequence(),submat,smithWatermanThreshold);
+					//randomSequence.printDPMatrix();
+					//randomSequence.traceback();
+					
+					double score = twoSequences.getAlignmentScore();
+					// Scores of the sequence beeing aligned to itself
+					double sSelf1 = sameSequence1.getAlignmentScore();
+					double sSelf2 = sameSequence2.getAlignmentScore();
+
+					double sRand = randomSequence.getAlignmentScore();
+
+					double sMax = (sSelf1 + sSelf2) / 2;
+					double sEff = (score - sRand)/ (sMax - sRand);
+					double distance = -Math.log(sEff);
 				
-				NumberSequence ns1 = numberseqs.get(i);
-				NumberSequence ns2 = numberseqs.get(j);
-				
-				
-				
-				SmithWatermanRepeated sw = new SmithWatermanRepeated(
-						ns1.getSequence(), ns2.getSequence(), submat, 10);
-				
-				if(sw.getAlignmentScore() > 0)
-				{   
-					System.out.println("=================================================");
-					System.out.println("| Sequence " + String.format("%3d", i) +" Sequence " + String.format("%3d", j)  + "                     |");
-					System.out.println("=================================================");
-					//System.out.print("Sequence " + i + ": ");
-					//ns1.printSequence();
-					//System.out.print("Sequence " + j + ": ");
-					//ns2.printSequence();
-					//System.out.println("Max Scrore: " + sw.getMaxScore());
-					System.out.println("Alignment Score: " + sw.getAlignmentScore());
-					//sw.printDPMatrix();
-					sw.traceback();
-					System.out.println();
-					System.out.println();
-				}
-			}
-		}
-
+					System.out.println("Score: " + score + " sRand: " + sRand + " sMax: " + sMax + " sEff: " + sEff + " distance: " + distance);
+					
+					sequenceDistances.set(i,j,distance );
+
+					if (score > 0) {
+						/*
+						 * System.out.println(
+						 * "=================================================");
+						 * System.out.println("| Sequence " +
+						 * String.format("%3d", i) +" Sequence " +
+						 * String.format("%3d", j) + "                     |");
+						 * System.out.println(
+						 * "=================================================");
+						 * System.out.print("Sequence " + i + ": ");
+						 * ns1.printSequence(); System.out.print("Sequence " + j
+						 * + ": "); ns2.printSequence(); System.out.println();
+						 * //System.out.println("Max Scrore: " +
+						 * sw.getMaxScore());
+						 * System.out.println("Alignment Score: " +
+						 * sw.getAlignmentScore()); //sw.printDPMatrix();
+						 * sw.traceback(); System.out.println();
+						 * System.out.println();
+						 */
+					}
+				}
+			}
+		}
+		//System.out.println(sequenceDistances.toString());
+		
 		do {
 			System.out.println();
