Index: /branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/VariableImpactCalculationTest.cs
===================================================================
--- /branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/VariableImpactCalculationTest.cs	(revision 16057)
+++ /branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/VariableImpactCalculationTest.cs	(revision 16058)
@@ -2,13 +2,10 @@
 using System.Collections.Generic;
 using System.Linq;
-using HeuristicLab.Algorithms.ALPS;
-using HeuristicLab.Algorithms.DataAnalysis;
-using HeuristicLab.Data;
+using HeuristicLab.Common;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Problems.DataAnalysis.Symbolic;
 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
 using HeuristicLab.Problems.Instances.DataAnalysis;
-using HeuristicLab.Selection;
-using HeuristicLab.Tests;
+using HeuristicLab.Random;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
@@ -17,222 +14,260 @@
   [TestClass()]
   public class VariableImpactCalculationTest {
-    [TestMethod]
-    [TestCategory("Problems.DataAnalysis")]
-    [TestProperty("Time", "medium")]
-    public void RunAlpsSymRegFactoryVariableMibaC1Test() {
-      var alpsGA = CreateAlpsGaSymRegMibaC1Sample();
-      alpsGA.Start();
-      var ers = alpsGA.Results.FirstOrDefault(v => v.Name == "Variable impacts").Value as DoubleMatrix;
-      Assert.IsNotNull(ers);
-      Assert.IsTrue(ers.Rows == 22);
-      List<string> expectedVariableOrder = new List<string> { "Oil", "Grooving", "Material_Cat", "x20", "Material", "x14", "x12", "x3", "x7", "x2", "x16", "x15", "x8", "x10", "x11", "x22", "x4", "x5", "x6", "x9", "x17", "x13" };
-      List<double> expectedVariableImpacts = new List<double> { 0.206, 0.179, 0.136, 0.099, 0.092, 0.07, 0.048, 0.033, 0.029, 0.026, 0.017, 0.01, 0.007, 0.007, 0.007, 0.006, 0.005, 0.005, 0.005, 0.005, 0.005, 0.003 };
-      Assert.IsTrue(ers.RowNames.SequenceEqual(expectedVariableOrder));
-      Assert.IsTrue(ers.SequenceEqual(expectedVariableImpacts));
-    }
-
-    [TestMethod]
-    [TestCategory("Problems.DataAnalysis")]
-    [TestProperty("Time", "medium")]
-    public void RunAlpsSymRegFactoryVariableMibaWear1Test() {
-      var alpsGA = CreateAlpsGaSymRegMibaWear1Sample();
-      alpsGA.Start();
-      var ers = alpsGA.Results.FirstOrDefault(v => v.Name == "Variable impacts").Value as DoubleMatrix;
-      Assert.IsNotNull(ers);
-      Assert.IsTrue(ers.Rows == 27);
-      List<string> expectedVariableOrder = new List<string> { "Oil", "Material_Cat", "Material", "Grooving", "x8", "x1", "x14", "x11", "x19", "x10", "x5", "x9", "x17", "x6", "x18", "x7", "Source1", "x2", "x3", "x4", "x16", "x20", "x12", "x13", "x15", "x22", "x21" };
-      List<double> expectedVariableImpacts = new List<double> { 0.194, 0.184, 0.163, 0.155, 0.022, 0.019, 0.019, 0.018, 0.017, 0.016, 0.015, 0.015, 0.015, 0.014, 0.014, 0.013, 0.012, 0.011, 0.011, 0.011, 0.011, 0.011, 0.01, 0.009, 0.009, 0.008, 0.006 };
-      Assert.IsTrue(ers.RowNames.SequenceEqual(expectedVariableOrder));
-      Assert.IsTrue(ers.SequenceEqual(expectedVariableImpacts));
-    }
-
-    [TestMethod]
-    [TestCategory("Problems.DataAnalysis")]
-    [TestProperty("Time", "medium")]
-    public void RunAlpsSymRegFactoryVariableRealworldTowerTest() {
-      var alpsGA = CreateAlpsGaSymReRealworldTowerSample();
-      alpsGA.Start();
-      var ers = alpsGA.Results.FirstOrDefault(v => v.Name == "Variable impacts").Value as DoubleMatrix;
-      Assert.IsNotNull(ers);
-      Assert.IsTrue(ers.Rows == 25);
-      List<string> expectedVariableOrder = new List<string> { "x5", "x4", "x21", "x22", "x13", "x3", "x9", "x19", "x1", "x12", "x8", "x10", "x25", "x11", "x23", "x7", "x24", "x6", "x14", "x15", "x20", "x2", "x16", "x18", "x17" };
-      List<double> expectedVariableImpacts = new List<double> { 0.057, 0.051, 0.047, 0.047, 0.046, 0.045, 0.044, 0.044, 0.043, 0.043, 0.041, 0.04, 0.04, 0.038, 0.038, 0.037, 0.037, 0.036, 0.036, 0.034, 0.033, 0.031, 0.031, 0.031, 0.03 };
-      Assert.IsTrue(ers.RowNames.SequenceEqual(expectedVariableOrder));
-      Assert.IsTrue(ers.SequenceEqual(expectedVariableImpacts));
-    }
-
-    [TestMethod]
-    [TestCategory("Problems.DataAnalysis")]
-    [TestProperty("Time", "short")]
-    public void RunRandomForestPolyTenTest() {
-      var randomForestRegression = new RandomForestRegression() {
-        M = 0.4,
-        R = 0.3,
-        NumberOfTrees = 50,
-        SetSeedRandomly = false,
-        Seed = 42
-      };
-
-      var symbRegProblem = new SymbolicRegressionSingleObjectiveProblem();
-      symbRegProblem.ProblemData = new PolyTen(555000).GenerateRegressionData();
-      randomForestRegression.Problem = symbRegProblem;
-      randomForestRegression.Start();
-
-      var rfs = randomForestRegression.Results.FirstOrDefault(v => v.Name == "Random forest regression solution").Value as RandomForestRegressionSolution;
-      Assert.IsNotNull(rfs);
-      var result = new RegressionSolutionVariableImpactsCalculator().Calculate(rfs);
-
-      //Set expected impacts
-      List<Tuple<string, double>> aux = new List<Tuple<string, double>>();
-      aux.Add(new Tuple<string, double>("X6", 0.14984398650032071));
-      aux.Add(new Tuple<string, double>("X5", 0.14361275357221248));
-      aux.Add(new Tuple<string, double>("X1", 0.10607502238071009));
-      aux.Add(new Tuple<string, double>("X3", 0.1056849194554953));
-      aux.Add(new Tuple<string, double>("X4", 0.0906750779077492));
-      aux.Add(new Tuple<string, double>("X2", 0.089817766590950532));
-      aux.Add(new Tuple<string, double>("X8", 0.042797597332305481));
-      aux.Add(new Tuple<string, double>("X9", 0.038609311722408446));
-      aux.Add(new Tuple<string, double>("X10", 0.036202503161574362));
-      aux.Add(new Tuple<string, double>("X7", 0.033539038256832465));
-      Assert.IsTrue(result.SequenceEqual(aux));
-    }
-
-    [TestMethod]
-    [TestCategory("Problems.DataAnalysis")]
-    [TestProperty("Time", "short")]
-    public void RunLinearRegressionBreimanITest() {
-      LinearRegression lr = new LinearRegression();
-      var symbRegProblem = new SymbolicRegressionSingleObjectiveProblem();
-      symbRegProblem.ProblemData = new BreimanOne(1234).GenerateRegressionData();
-
-      lr.Problem = symbRegProblem;
-      lr.Start();
-
-      var lrs = lr.Results.FirstOrDefault(v => v.Name == "Linear regression solution").Value as SymbolicRegressionSolution;
-      Assert.IsNotNull(lrs);
-      var result = new RegressionSolutionVariableImpactsCalculator().Calculate(lrs);
-
-      //Set expected impacts
-      List<Tuple<string, double>> aux = new List<Tuple<string, double>>();
-      aux.Add(new Tuple<string, double>("X1", 0.43328518823918716));
-      aux.Add(new Tuple<string, double>("X2", 0.073284548674773631));
-      aux.Add(new Tuple<string, double>("X5", 0.070306657566311159));
-      aux.Add(new Tuple<string, double>("X3", 0.035352205426012917));
-      aux.Add(new Tuple<string, double>("X6", 0.031710492680145475));
-      aux.Add(new Tuple<string, double>("X4", 0.0081659530036176653));
-      aux.Add(new Tuple<string, double>("X7", 0.0070869550705255913));
-      aux.Add(new Tuple<string, double>("X9", 8.0546619615096127E-05));
-      aux.Add(new Tuple<string, double>("X8", 6.2072921147349192E-05));
-      aux.Add(new Tuple<string, double>("X10", 1.9113559758254794E-06));
-
-      Assert.IsTrue(result.SequenceEqual(aux));
-    }
-
-    private AlpsGeneticAlgorithm CreateAlpsGaSymRegMibaC1Sample() {
-      AlpsGeneticAlgorithm alpsGa = new AlpsGeneticAlgorithm();
-      #region Problem Configuration
-      var provider = new MibaFrictionRegressionInstanceProvider();
-      var instance = provider.GetDataDescriptors().Single(x => x.Name.StartsWith("CF1"));
-      var symbRegProblem = new SymbolicRegressionSingleObjectiveProblem();
-      symbRegProblem.Load(provider.LoadData(instance));
-
-      symbRegProblem.MaximumSymbolicExpressionTreeDepth.Value = 35;
-      symbRegProblem.MaximumSymbolicExpressionTreeLength.Value = 35;
-
-      var grammar = (TypeCoherentExpressionGrammar)symbRegProblem.SymbolicExpressionTreeGrammar;
-      grammar.Symbols.OfType<Exponential>().Single().Enabled = false;
-      grammar.Symbols.OfType<Logarithm>().Single().Enabled = false;
-
-      #endregion
-      #region Algorithm Configuration
-      alpsGa.Name = "ALPS Genetic Programming - Symbolic Regression";
-      alpsGa.Description = "An ALPS-GP to solve a symbolic regression problem";
-      alpsGa.Problem = symbRegProblem;
-      SamplesUtils.ConfigureAlpsGeneticAlgorithmParameters<GeneralizedRankSelector, SubtreeCrossover, MultiSymbolicExpressionTreeManipulator>(alpsGa,
-        numberOfLayers: 1000,
-        popSize: 100,
-        mutationRate: 0.25,
-        elites: 1,
-        plusSelection: false,
-        agingScheme: AgingScheme.Polynomial,
-        ageGap: 15,
-        ageInheritance: 1.0,
-        maxGens: 10);
-
-      alpsGa.SetSeedRandomly.Value = false;
-      alpsGa.Seed.Value = 1234;
-      #endregion
-      return alpsGa;
-    }
-    private AlpsGeneticAlgorithm CreateAlpsGaSymRegMibaWear1Sample() {
-      AlpsGeneticAlgorithm alpsGa = new AlpsGeneticAlgorithm();
-      #region Problem Configuration
-      var provider = new MibaFrictionRegressionInstanceProvider();
-      var instance = provider.GetDataDescriptors().Single(x => x.Name.StartsWith("Wear1"));
-      var symbRegProblem = new SymbolicRegressionSingleObjectiveProblem();
-      symbRegProblem.Load(provider.LoadData(instance));
-
-      symbRegProblem.MaximumSymbolicExpressionTreeDepth.Value = 77;
-      symbRegProblem.MaximumSymbolicExpressionTreeLength.Value = 77;
-
-      var grammar = (TypeCoherentExpressionGrammar)symbRegProblem.SymbolicExpressionTreeGrammar;
-
-      #endregion
-      #region Algorithm Configuration
-      alpsGa.Name = "ALPS Genetic Programming - Symbolic Regression";
-      alpsGa.Description = "An ALPS-GP to solve a symbolic regression problem";
-      alpsGa.Problem = symbRegProblem;
-      SamplesUtils.ConfigureAlpsGeneticAlgorithmParameters<RandomSelector, SubtreeCrossover, MultiSymbolicExpressionTreeManipulator>(alpsGa,
-        numberOfLayers: 1000,
-        popSize: 200,
-        mutationRate: 0.25,
-        elites: 1,
-        plusSelection: false,
-        agingScheme: AgingScheme.Polynomial,
-        ageGap: 15,
-        ageInheritance: 1.0,
-        maxGens: 10);
-
-      alpsGa.SetSeedRandomly.Value = false;
-      alpsGa.Seed.Value = 11121314;
-      #endregion
-      return alpsGa;
-    }
-    private AlpsGeneticAlgorithm CreateAlpsGaSymReRealworldTowerSample() {
-      AlpsGeneticAlgorithm alpsGa = new AlpsGeneticAlgorithm();
-      #region Problem Configuration
-      var provider = new RegressionRealWorldInstanceProvider();
-      var instance = provider.GetDataDescriptors().Single(x => x.Name.StartsWith("Tower"));
-      var symbRegProblem = new SymbolicRegressionSingleObjectiveProblem();
-      symbRegProblem.Load(provider.LoadData(instance));
-
-      symbRegProblem.MaximumSymbolicExpressionTreeDepth.Value = 77;
-      symbRegProblem.MaximumSymbolicExpressionTreeLength.Value = 77;
-
-      var grammar = (TypeCoherentExpressionGrammar)symbRegProblem.SymbolicExpressionTreeGrammar;
-
-      #endregion
-      #region Algorithm Configuration
-      alpsGa.Name = "ALPS Genetic Programming - Symbolic Regression";
-      alpsGa.Description = "An ALPS-GP to solve a symbolic regression problem";
-      alpsGa.Problem = symbRegProblem;
-      SamplesUtils.ConfigureAlpsGeneticAlgorithmParameters<RandomSelector, SubtreeCrossover, MultiSymbolicExpressionTreeManipulator>(alpsGa,
-        numberOfLayers: 1000,
-        popSize: 200,
-        mutationRate: 0.25,
-        elites: 1,
-        plusSelection: false,
-        agingScheme: AgingScheme.Polynomial,
-        ageGap: 15,
-        ageInheritance: 1.0,
-        maxGens: 10);
-
-      alpsGa.SetSeedRandomly.Value = false;
-      alpsGa.Seed.Value = 1111;
-      #endregion
-      return alpsGa;
-    }
-
-    //TODO: Add Function-Tests once the Branch of #2904 is done
+    private static readonly double epsilon = 0.00001;
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void ConstantModelVariableImpactTest() {
+      IRegressionProblemData problemData = LoadDefaultTowerProblem();
+      IRegressionModel model = new ConstantModel(5, "y");
+      IRegressionSolution solution = new RegressionSolution(model, problemData);
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForConstantModel();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void LinearRegressionModelVariableImpactTowerTest() {
+      IRegressionProblemData problemData = LoadDefaultTowerProblem();
+      ISymbolicExpressionTree tree = CreateLRExpressionTree(problemData);
+      IRegressionModel model = new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeInterpreter());
+      IRegressionSolution solution = new RegressionSolution(model, (IRegressionProblemData)problemData.Clone());
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForLRTower();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void LinearRegressionModelVariableImpactMibaTest() {
+      IRegressionProblemData problemData = LoadDefaultMibaProblem();
+      ISymbolicExpressionTree tree = CreateLRExpressionTree(problemData);
+      IRegressionModel model = new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeInterpreter());
+      IRegressionSolution solution = new RegressionSolution(model, (IRegressionProblemData)problemData.Clone());
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForLRMiba();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void CustomModelVariableImpactTest() {
+      IRegressionProblemData problemData = CreateDefaultProblem();
+      ISymbolicExpressionTree tree = CreateCustomExpressionTree();
+      IRegressionModel model = new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeInterpreter());
+      IRegressionSolution solution = new RegressionSolution(model, (IRegressionProblemData)problemData.Clone());
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForCustomProblem();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void CustomModelVariableImpactNoInfluenceTest() {
+      IRegressionProblemData problemData = CreateDefaultProblem();
+      ISymbolicExpressionTree tree = CreateCustomExpressionTreeNoInfluenceX1();
+      IRegressionModel model = new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeInterpreter());
+      IRegressionSolution solution = new RegressionSolution(model, (IRegressionProblemData)problemData.Clone());
+      Dictionary<string, double> expectedImpacts = GetExpectedValuesForCustomProblemNoInfluence();
+
+      CheckDefaultAsserts(solution, expectedImpacts);
+    }
+
+    #region Load RegressionProblemData
+    private IRegressionProblemData LoadDefaultTowerProblem() {
+      RegressionRealWorldInstanceProvider provider = new RegressionRealWorldInstanceProvider();
+      var instance = provider.GetDataDescriptors().Where(x => x.Name.Equals("Tower")).Single();
+      return provider.LoadData(instance);
+    }
+    private IRegressionProblemData LoadDefaultMibaProblem() {
+      MibaFrictionRegressionInstanceProvider provider = new MibaFrictionRegressionInstanceProvider();
+      var instance = provider.GetDataDescriptors().Where(x => x.Name.Equals("CF1")).Single();
+      return provider.LoadData(instance);
+    }
+    private IRegressionProblemData 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);
+      for (int i = 0; i < variableValues.GetLength(0); i++) {
+        for (int j = 0; j < variableValues.GetLength(1); j++) {
+          variableValues[i, j] = random.Next(1, 100);
+        }
+      }
+
+      Dataset dataset = new Dataset(variableNames, variableValues);
+      return new RegressionProblemData(dataset, allowedInputVariables, targetVariable);
+    }
+    #endregion
+
+    #region Create SymbolicExpressionTree
+    private ISymbolicExpressionTree CreateLRExpressionTree(IRegressionProblemData problemData) {
+      IEnumerable<int> rows = problemData.TrainingIndices;
+      var doubleVariables = problemData.AllowedInputVariables.Where(problemData.Dataset.VariableHasType<double>);
+      var factorVariableNames = problemData.AllowedInputVariables.Where(problemData.Dataset.VariableHasType<string>);
+      var factorVariables = problemData.Dataset.GetFactorVariableValues(factorVariableNames, rows);
+      double[,] binaryMatrix = problemData.Dataset.ToArray(factorVariables, rows);
+      double[,] doubleVarMatrix = problemData.Dataset.ToArray(doubleVariables.Concat(new string[] { problemData.TargetVariable }), rows);
+      var inputMatrix = binaryMatrix.HorzCat(doubleVarMatrix);
+
+      alglib.linearmodel lm = new alglib.linearmodel();
+      alglib.lrreport ar = new alglib.lrreport();
+      int nRows = inputMatrix.GetLength(0);
+      int nFeatures = inputMatrix.GetLength(1) - 1;
+      double[] coefficients = new double[nFeatures + 1]; // last coefficient is for the constant
+
+      int retVal = 1;
+      alglib.lrbuild(inputMatrix, nRows, nFeatures, out retVal, out lm, out ar);
+      if (retVal != 1) throw new ArgumentException("Error in calculation of linear regression solution");
+
+      alglib.lrunpack(lm, out coefficients, out nFeatures);
+
+      int nFactorCoeff = binaryMatrix.GetLength(1);
+      int nVarCoeff = doubleVariables.Count();
+      return LinearModelToTreeConverter.CreateTree(factorVariables, coefficients.Take(nFactorCoeff).ToArray(),
+        doubleVariables.ToArray(), coefficients.Skip(nFactorCoeff).Take(nVarCoeff).ToArray(),
+        @const: coefficients[nFeatures]);
+    }
+    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");
+    }
+    #endregion
+
+    #region Get Expected Values
+    private Dictionary<string, double> GetExpectedValuesForConstantModel() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("x1", 0);
+      expectedImpacts.Add("x10", 0);
+      expectedImpacts.Add("x11", 0);
+      expectedImpacts.Add("x12", 0);
+      expectedImpacts.Add("x13", 0);
+      expectedImpacts.Add("x14", 0);
+      expectedImpacts.Add("x15", 0);
+      expectedImpacts.Add("x16", 0);
+      expectedImpacts.Add("x17", 0);
+      expectedImpacts.Add("x18", 0);
+      expectedImpacts.Add("x19", 0);
+      expectedImpacts.Add("x2", 0);
+      expectedImpacts.Add("x20", 0);
+      expectedImpacts.Add("x21", 0);
+      expectedImpacts.Add("x22", 0);
+      expectedImpacts.Add("x23", 0);
+      expectedImpacts.Add("x24", 0);
+      expectedImpacts.Add("x25", 0);
+      expectedImpacts.Add("x3", 0);
+      expectedImpacts.Add("x4", 0);
+      expectedImpacts.Add("x5", 0);
+      expectedImpacts.Add("x6", 0);
+      expectedImpacts.Add("x7", 0);
+      expectedImpacts.Add("x8", 0);
+      expectedImpacts.Add("x9", 0);
+
+      return expectedImpacts;
+    }
+    private Dictionary<string, double> GetExpectedValuesForLRTower() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("x1", 0.639933657675427);
+      expectedImpacts.Add("x10", 0.0127006885259798);
+      expectedImpacts.Add("x11", 0.648236047877475);
+      expectedImpacts.Add("x12", 0.248350173524562);
+      expectedImpacts.Add("x13", 0.550889987109547);
+      expectedImpacts.Add("x14", 0.0882824237877192);
+      expectedImpacts.Add("x15", 0.0391276799061169);
+      expectedImpacts.Add("x16", 0.743632451088798);
+      expectedImpacts.Add("x17", 0.00254276857715308);
+      expectedImpacts.Add("x18", 0.0021548147614302);
+      expectedImpacts.Add("x19", 0.00513473927463037);
+      expectedImpacts.Add("x2", 0.0107583487931443);
+      expectedImpacts.Add("x20", 0.18085069746933);
+      expectedImpacts.Add("x21", 0.138053600700762);
+      expectedImpacts.Add("x22", 0.000339539790460086);
+      expectedImpacts.Add("x23", 0.362111965467117);
+      expectedImpacts.Add("x24", 0.0320167935572304);
+      expectedImpacts.Add("x25", 0.57460423230969);
+      expectedImpacts.Add("x3", 0.688142635515862);
+      expectedImpacts.Add("x4", 0.000176632348454664);
+      expectedImpacts.Add("x5", 0.0213915503114581);
+      expectedImpacts.Add("x6", 0.807976486909701);
+      expectedImpacts.Add("x7", 0.716217843319252);
+      expectedImpacts.Add("x8", 0.772701841392564);
+      expectedImpacts.Add("x9", 0.178418730050997);
+
+      return expectedImpacts;
+    }
+    private Dictionary<string, double> GetExpectedValuesForLRMiba() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("Grooving", 0.0380558091030508);
+      expectedImpacts.Add("Material", 0.02195836766156);
+      expectedImpacts.Add("Material_Cat", 0.000338687689067418);
+      expectedImpacts.Add("Oil", 0.363464994447857);
+      expectedImpacts.Add("x10", 0.0015309669014415);
+      expectedImpacts.Add("x11", -3.60432578908609E-05);
+      expectedImpacts.Add("x12", 0.00118953859087612);
+      expectedImpacts.Add("x13", 0.00164240977191832);
+      expectedImpacts.Add("x14", 0.000688363685380056);
+      expectedImpacts.Add("x15", -4.75067203969948E-05);
+      expectedImpacts.Add("x16", 0.00130388206125076);
+      expectedImpacts.Add("x17", 0.132351838646134);
+      expectedImpacts.Add("x2", -2.47981401556574E-05);
+      expectedImpacts.Add("x20", 0.716541716605016);
+      expectedImpacts.Add("x22", 0.174959377282835);
+      expectedImpacts.Add("x3", -2.65979754026091E-05);
+      expectedImpacts.Add("x4", -1.24764212947603E-05);
+      expectedImpacts.Add("x5", 0.001184959455798);
+      expectedImpacts.Add("x6", 0.000743336665237626);
+      expectedImpacts.Add("x7", 0.00188965927889773);
+      expectedImpacts.Add("x8", 0.00415201581536351);
+      expectedImpacts.Add("x9", 0.00365653880518491);
+
+      return expectedImpacts;
+    }
+    private Dictionary<string, double> GetExpectedValuesForCustomProblem() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("x1", -0.000573340275115796);
+      expectedImpacts.Add("x2", 0.000781819784095592);
+      expectedImpacts.Add("x3", -0.000390473234921058);
+      expectedImpacts.Add("x4", -0.00116083274627995);
+      expectedImpacts.Add("x5", -0.00036161186207545);
+
+      return expectedImpacts;
+    }
+    private Dictionary<string, double> GetExpectedValuesForCustomProblemNoInfluence() {
+      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
+      expectedImpacts.Add("x1", 0);
+      expectedImpacts.Add("x2", 0.00263393690342982);
+      expectedImpacts.Add("x3", -0.00053248037514929);
+      expectedImpacts.Add("x4", 0.00450365819257568);
+      expectedImpacts.Add("x5", -0.000550911612888904);
+
+      return expectedImpacts;
+    }
+    #endregion
+
+    private void CheckDefaultAsserts(IRegressionSolution solution, Dictionary<string, double> expectedImpacts) {
+      IRegressionProblemData problemData = solution.ProblemData;
+      IEnumerable<double> estimatedValues = solution.GetEstimatedValues(solution.ProblemData.TrainingIndices);
+
+      var solutionImpacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(solution);
+      var modelImpacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(solution.Model, problemData, estimatedValues, problemData.TrainingIndices);
+      //Both ways should return equal results
+      Assert.IsTrue(solutionImpacts.SequenceEqual(modelImpacts));
+
+      //Check if impacts are as expected
+      Assert.AreEqual(modelImpacts.Count(), expectedImpacts.Count);
+      foreach (var entry in modelImpacts.OrderBy(v => v.Item1)) {
+        Assert.IsTrue(Math.Abs(expectedImpacts[entry.Item1] - entry.Item2) < epsilon);
+      }
+    }
   }
 }
