Index: /branches/2904_CalculateImpacts/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs
===================================================================
--- /branches/2904_CalculateImpacts/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs	(revision 16033)
+++ /branches/2904_CalculateImpacts/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs	(revision 16034)
@@ -106,7 +106,6 @@
       ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle,
       FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best,
-      DataPartitionEnum data = DataPartitionEnum.Training,
-      Func<double, string, bool> progressCallback = null) {
-      return CalculateImpacts(solution.Model, solution.ProblemData, solution.EstimatedValues, replacementMethod, factorReplacementMethod, data, progressCallback);
+      DataPartitionEnum data = DataPartitionEnum.Training) {
+      return CalculateImpacts(solution.Model, solution.ProblemData, solution.EstimatedValues, replacementMethod, factorReplacementMethod, data);
     }
 
@@ -117,6 +116,5 @@
       ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle,
       FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best,
-      DataPartitionEnum data = DataPartitionEnum.Training,
-      Func<double, string, bool> progressCallback = null) {
+      DataPartitionEnum data = DataPartitionEnum.Training) {
       IEnumerable<int> rows;
 
@@ -135,5 +133,43 @@
       }
 
-      return CalculateImpacts(model, problemData, estimatedValues, rows, replacementMethod, factorReplacementMethod, progressCallback);
+      return CalculateImpacts(model, problemData, estimatedValues, rows, replacementMethod, factorReplacementMethod);
+    }
+
+    public static double CalculateImpact(string variableName, IRegressionModel model, IRegressionProblemData problemData, IEnumerable<double> estimatedValues, DataPartitionEnum dataPartition, ReplacementMethodEnum replMethod, FactorReplacementMethodEnum factorReplMethod) {
+      double impact = 0;
+
+      IEnumerable<int> rows;
+      switch (dataPartition) {
+        case DataPartitionEnum.All:
+          rows = problemData.AllIndices;
+          break;
+        case DataPartitionEnum.Test:
+          rows = problemData.TestIndices;
+          break;
+        case DataPartitionEnum.Training:
+          rows = problemData.TrainingIndices;
+          break;
+        default:
+          throw new NotSupportedException("DataPartition not supported");
+      }
+
+      OnlineCalculatorError error;
+      IEnumerable<double> targetValuesPartition = rows.Select(v => problemData.TargetVariableValues.ElementAt(v));
+      IEnumerable<double> estimatedValuesPartition = rows.Select(v => estimatedValues.ElementAt(v));
+      var originalCalculatorValue = CalculateVariableImpact(targetValuesPartition, estimatedValuesPartition, out error);
+      if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during calculation.");
+
+
+      var modifiableDataset = ((Dataset)(problemData.Dataset).Clone()).ToModifiable();
+
+      // calculate impacts for double variables
+      if (problemData.Dataset.VariableHasType<double>(variableName)) {
+        impact = CalculateImpactForNumericalVariables(variableName, model, modifiableDataset, rows, targetValuesPartition, originalCalculatorValue, replMethod);
+      } else if (problemData.Dataset.VariableHasType<string>(variableName)) {
+        impact = CalculateImpactForFactorVariables(variableName, model, problemData.Dataset, modifiableDataset, rows, targetValuesPartition, originalCalculatorValue, factorReplMethod);
+      } else {
+        throw new NotSupportedException("Variable not supported");
+      }
+      return impact;
     }
 
@@ -144,6 +180,5 @@
      IEnumerable<int> rows,
      ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle,
-     FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best,
-     Func<double, string, bool> progressCallback = null) {
+     FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best) {
       //Calculate original quality-values (via calculator, default is R²)
       OnlineCalculatorError error;
@@ -157,13 +192,5 @@
       var allowedInputVariables = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).ToList();
 
-      int curIdx = 0;
-      int count = allowedInputVariables.Count(v => problemData.Dataset.VariableHasType<double>(v) || problemData.Dataset.VariableHasType<string>(v));
-
       foreach (var inputVariable in allowedInputVariables) {
-        //Report the current progress in percent. If the callback returns true, it means the execution shall be stopped
-        if (progressCallback != null) {
-          curIdx++;
-          if (progressCallback((double)curIdx / count, string.Format("Calculating impact for variable {0} ({1} of {2})", inputVariable, curIdx, count))) { return null; }
-        }
         impacts[inputVariable] = CalculateImpact(inputVariable, model, problemData.Dataset, rows, targetValuesPartition, originalCalculatorValue, replacementMethod, factorReplacementMethod);
       }
@@ -204,19 +231,4 @@
       }
       return impact;
-    }
-
-    private static void PrepareData(IEnumerable<int> rows,
-      IRegressionProblemData problemData,
-      IEnumerable<double> estimatedValues,
-      out IEnumerable<double> targetValues,
-      out double originalValue) {
-      OnlineCalculatorError error;
-
-      var targetVariableValueList = problemData.TargetVariableValues.ToList();
-      targetValues = rows.Select(v => targetVariableValueList.ElementAt(v));
-      var estimatedValuesPartition = rows.Select(v => estimatedValues.ElementAt(v));
-      originalValue = CalculateVariableImpact(targetValues, estimatedValuesPartition, out error);
-
-      if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during calculation.");
     }
 
Index: /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
===================================================================
--- /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj	(revision 16033)
+++ /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj	(revision 16034)
@@ -52,5 +52,5 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>..\..\..\trunk\bin\</OutputPath>
+    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
Index: /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
===================================================================
--- /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs	(revision 16033)
+++ /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs	(revision 16034)
@@ -33,5 +33,4 @@
   [Content(typeof(IRegressionSolution))]
   public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView {
-    private CancellationTokenSource cancellationToken = new CancellationTokenSource();
     private enum SortingCriteria {
       ImpactValue,
@@ -39,4 +38,5 @@
       VariableName
     }
+    private CancellationTokenSource cancellationToken = new CancellationTokenSource();
     private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>();
 
@@ -64,5 +64,4 @@
       Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
     }
-
     protected override void DeregisterContentEvents() {
       base.DeregisterContentEvents();
@@ -74,9 +73,7 @@
       OnContentChanged();
     }
-
     protected virtual void Content_ModelChanged(object sender, EventArgs e) {
       OnContentChanged();
     }
-
     protected override void OnContentChanged() {
       base.OnContentChanged();
@@ -87,18 +84,14 @@
       }
     }
-
     private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
       cancellationToken.Cancel();
     }
 
-
     private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) {
       UpdateVariableImpact();
     }
-
     private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) {
       UpdateVariableImpact();
     }
-
     private void sortByComboBox_SelectedIndexChanged(object sender, EventArgs e) {
       //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice)
@@ -109,9 +102,7 @@
       UpdateOrdering();
     }
-
     private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) {
       UpdateOrdering();
     }
-
 
     private async void UpdateVariableImpact() {
@@ -135,16 +126,9 @@
 
       cancellationToken = new CancellationTokenSource();
-      //Remember the original ordering of the variables
+
       try {
-        var impacts = await Task.Run(() => RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, replMethod, factorReplMethod, dataPartition,
-          (i, s) => {
-            progress.ProgressValue = i;
-            progress.Status = s;
-            return cancellationToken.Token.IsCancellationRequested;
-          }), cancellationToken.Token);
-
-        if (cancellationToken.Token.IsCancellationRequested) { return; }
         var problemData = Content.ProblemData;
         var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction));
+        //Remember the original ordering of the variables
         var originalVariableOrdering = problemData.Dataset.VariableNames
           .Where(v => inputvariables.Contains(v))
@@ -152,10 +136,39 @@
           .ToList();
 
+        List<Tuple<string, double>> impacts = null;
+        await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); });
+        if (impacts == null) { return; }
+
         rawVariableImpacts.Clear();
         originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(new Tuple<string, double>(v, impacts.First(vv => vv.Item1 == v).Item2)));
         UpdateOrdering();
-      } finally {
+      }
+      finally {
         ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this);
       }
+    }
+    private List<Tuple<string, double>> CalculateVariableImpacts(List<string> originalVariableOrdering,
+      IRegressionModel model,
+      IRegressionProblemData problemData,
+      IEnumerable<double> estimatedValues,
+      RegressionSolutionVariableImpactsCalculator.DataPartitionEnum dataPartition,
+      RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum replMethod,
+      RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum factorReplMethod,
+      CancellationToken token,
+      IProgress progress) {
+      List<Tuple<string, double>> impacts = new List<Tuple<string, double>>();
+      int count = originalVariableOrdering.Count;
+      int i = 0;
+
+      foreach (var variable in originalVariableOrdering) {
+        if (cancellationToken.Token.IsCancellationRequested) { return null; }
+        progress.ProgressValue = (double)++i / count;
+        progress.Status = string.Format("Calculating impact for variable {0} ({1} of {2})", variable, i, count);
+
+        double impact = RegressionSolutionVariableImpactsCalculator.CalculateImpact(variable, model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod);
+        impacts.Add(new Tuple<string, double>(variable, impact));
+      }
+
+      return impacts;
     }
 
