Index: branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/ClassificationVariableImpactCalculationTest.cs
===================================================================
--- branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/ClassificationVariableImpactCalculationTest.cs	(revision 16061)
+++ branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/ClassificationVariableImpactCalculationTest.cs	(revision 16065)
@@ -3,7 +3,10 @@
 using System.Linq;
 using HeuristicLab.Algorithms.DataAnalysis;
+using HeuristicLab.Common;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Classification;
 using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Random;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
@@ -42,4 +45,32 @@
     [TestCategory("Problems.DataAnalysis")]
     [TestProperty("Time", "short")]
+    public void CustomModelVariableImpactTest() {
+      IClassificationProblemData problemData = CreateDefaultProblem();
+      ISymbolicExpressionTree tree = CreateCustomExpressionTree();
+      var model = new SymbolicNearestNeighbourClassificationModel(problemData.TargetVariable, 3, tree, new SymbolicDataAnalysisExpressionTreeInterpreter());
+      model.RecalculateModelParameters(problemData, problemData.TrainingIndices);
+      IClassificationSolution solution = new ClassificationSolution(model, (IClassificationProblemData)problemData.Clone());
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForCustomProblem();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void CustomModelVariableImpactNoInfluenceTest() {
+      IClassificationProblemData problemData = CreateDefaultProblem();
+      ISymbolicExpressionTree tree = CreateCustomExpressionTreeNoInfluenceX1();
+      var model = new SymbolicNearestNeighbourClassificationModel(problemData.TargetVariable, 3, tree, new SymbolicDataAnalysisExpressionTreeInterpreter());
+      model.RecalculateModelParameters(problemData, problemData.TrainingIndices);
+      IClassificationSolution solution = new ClassificationSolution(model, (IClassificationProblemData)problemData.Clone());
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForCustomProblemNoInfluence();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
     [ExpectedException(typeof(ArgumentException))]
     public void WrongDataSetTest() {
@@ -64,7 +95,36 @@
       return provider.LoadData(instance);
     }
+    private IClassificationProblemData CreateDefaultProblem() {
+      List<string> allowedInputVariables = new List<string>() { "x1", "x2", "x3", "x4", "x5" };
+      string targetVariable = "y";
+      var variableNames = allowedInputVariables.Union(targetVariable.ToEnumerable());
+      double[,] variableValues = new double[100, variableNames.Count()];
+
+      FastRandom random = new FastRandom(12345);
+      int len0 = variableValues.GetLength(0);
+      int len1 = variableValues.GetLength(1);
+      for (int i = 0; i < len0; i++) {
+        for (int j = 0; j < len1; j++) {
+          if (j == len1 - 1) {
+            variableValues[i, j] = (j + i) % 2;
+          } else {
+            variableValues[i, j] = random.Next(1, 100);
+          }
+        }
+      }
+
+      Dataset dataset = new Dataset(variableNames, variableValues);
+      var ret = new ClassificationProblemData(dataset, allowedInputVariables, targetVariable);
+
+      ret.SetClassName(0, "NOK");
+      ret.SetClassName(1, "OK");
+      return ret;
+    }
     #endregion
 
     #region Create SymbolicExpressionTree
+    private ISymbolicExpressionTree CreateCustomExpressionTree() {
+      return new InfixExpressionParser().Parse("x1*x2 - x2*x2 + x3*x3 + x4*x4 - x5*x5 + 14/12");
+    }
     private ISymbolicExpressionTree CreateCustomExpressionTreeNoInfluenceX1() {
       return new InfixExpressionParser().Parse("x1/x1*x2 - x2*x2 + x3*x3 + x4*x4 - x5*x5 + 14/12");
@@ -91,4 +151,24 @@
       return expectedImpacts;
     }
+    private Dictionary<string, double> GetExpectedValuesForCustomProblem() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("x1", 0.04);
+      expectedImpacts.Add("x2", 0.22);
+      expectedImpacts.Add("x3", 0.26);
+      expectedImpacts.Add("x4", 0.24);
+      expectedImpacts.Add("x5", 0.2);
+
+      return expectedImpacts;
+    }
+    private Dictionary<string, double> GetExpectedValuesForCustomProblemNoInfluence() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("x1", 0);
+      expectedImpacts.Add("x2", 0.22);
+      expectedImpacts.Add("x3", 0.14);
+      expectedImpacts.Add("x4", 0.3);
+      expectedImpacts.Add("x5", 0.44);
+
+      return expectedImpacts;
+    }
     #endregion
 
