Index: /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs	(revision 5747)
+++ /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs	(revision 5748)
@@ -41,4 +41,5 @@
     private const string VariableFrequenciesParameterName = "VariableFrequencies";
     private const string AggregateLaggedVariablesParameterName = "AggregateLaggedVariables";
+    private const string VariableImpactsParameterName = "VariableImpacts";
 
     #region parameter properties
@@ -46,4 +47,7 @@
       get { return (ILookupParameter<DataTable>)Parameters[VariableFrequenciesParameterName]; }
     }
+    public ILookupParameter<DoubleMatrix> VariableImpactsParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters[VariableImpactsParameterName]; }
+    }
     public IValueLookupParameter<BoolValue> AggregateLaggedVariablesParameter {
       get { return (IValueLookupParameter<BoolValue>)Parameters[AggregateLaggedVariablesParameterName]; }
@@ -51,10 +55,7 @@
     #endregion
     #region properties
-    public DataTable VariableFrequencies {
-      get { return VariableFrequenciesParameter.ActualValue; }
-      set { VariableFrequenciesParameter.ActualValue = value; }
-    }
     public BoolValue AggregateLaggedVariables {
       get { return AggregateLaggedVariablesParameter.ActualValue; }
+      set { AggregateLaggedVariablesParameter.Value = value; }
     }
     #endregion
@@ -67,38 +68,61 @@
       : base() {
       Parameters.Add(new LookupParameter<DataTable>(VariableFrequenciesParameterName, "The relative variable reference frequencies aggregated over all trees in the population."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>(VariableImpactsParameterName, "The relative variable relevance calculated as the average relative variable frequency over the whole run."));
       Parameters.Add(new ValueLookupParameter<BoolValue>(AggregateLaggedVariablesParameterName, "Switch that determines whether all references to a variable should be aggregated regardless of time-offsets. Turn off to analyze all variable references with different time offsets separately.", new BoolValue(true)));
     }
+
     public override IDeepCloneable Clone(Cloner cloner) {
       return new SymbolicDataAnalysisVariableFrequencyAnalyzer(this, cloner);
     }
-
 
     public override IOperation Apply() {
       ItemArray<ISymbolicExpressionTree> expressions = SymbolicExpressionTreeParameter.ActualValue;
       ResultCollection results = ResultCollection;
-
-      if (VariableFrequencies == null) {
-        VariableFrequencies = new DataTable("Variable frequencies", "Relative frequency of variable references aggregated over the whole population.");
-        VariableFrequencies.VisualProperties.XAxisTitle = "Generation";
-        VariableFrequencies.VisualProperties.YAxisTitle = "Relative Variable Frequency";
-        results.Add(new Result("Variable frequencies", VariableFrequencies));
-      }
-
+      DoubleMatrix impacts;
+      DataTable datatable;
+      if (VariableFrequenciesParameter.ActualValue == null) {
+        datatable = new DataTable("Variable frequencies", "Relative frequency of variable references aggregated over the whole population.");
+        datatable.VisualProperties.XAxisTitle = "Generation";
+        datatable.VisualProperties.YAxisTitle = "Relative Variable Frequency";
+        impacts = new DoubleMatrix();
+        VariableFrequenciesParameter.ActualValue = datatable;
+        VariableImpactsParameter.ActualValue = impacts;
+        results.Add(new Result("Variable frequencies", "Relative frequency of variable references aggregated over the whole population.", datatable));
+        results.Add(new Result("Variable impacts", "The relative variable relevance calculated as the average relative variable frequency over the whole run.", impacts));
+      }
+
+      impacts = VariableImpactsParameter.ActualValue;
+      datatable = VariableFrequenciesParameter.ActualValue;
       // all rows must have the same number of values so we can just take the first
-      int numberOfValues = VariableFrequencies.Rows.Select(r => r.Values.Count).DefaultIfEmpty().First();
+      int numberOfValues = datatable.Rows.Select(r => r.Values.Count).DefaultIfEmpty().First();
 
       foreach (var pair in SymbolicDataAnalysisVariableFrequencyAnalyzer.CalculateVariableFrequencies(expressions, AggregateLaggedVariables.Value)) {
-        if (!VariableFrequencies.Rows.ContainsKey(pair.Key)) {
+        if (!datatable.Rows.ContainsKey(pair.Key)) {
           // initialize a new row for the variable and pad with zeros
           DataRow row = new DataRow(pair.Key, "", Enumerable.Repeat(0.0, numberOfValues));
           row.VisualProperties.StartIndexZero = true;
-          VariableFrequencies.Rows.Add(row);
-        }
-        VariableFrequencies.Rows[pair.Key].Values.Add(pair.Value);
+          datatable.Rows.Add(row);
+        }
+        datatable.Rows[pair.Key].Values.Add(pair.Value);
       }
 
       // add a zero for each data row that was not modified in the previous loop 
-      foreach (var row in VariableFrequencies.Rows.Where(r => r.Values.Count != numberOfValues + 1))
+      foreach (var row in datatable.Rows.Where(r => r.Values.Count != numberOfValues + 1))
         row.Values.Add(0.0);
+
+      // update variable impacts matrix
+      var orderedImpacts = (from row in datatable.Rows
+                            select new { Name = row.Name, Impact = datatable.Rows[row.Name].Values.Average() })
+                           .OrderByDescending(p => p.Impact)
+                           .ToList();
+      var matrix = (IStringConvertibleMatrix)impacts;
+      matrix.Rows = orderedImpacts.Count;
+      matrix.RowNames = orderedImpacts.Select(x => x.Name);
+      matrix.Columns = 1;
+      matrix.ColumnNames = new string[] { "Relative variable relevance" };
+      int i = 0;
+      foreach (var p in orderedImpacts) {
+        matrix.SetValue(p.Impact.ToString(), i++, 0);
+      }
 
       return base.Apply();
