Index: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCreator.cs
===================================================================
--- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCreator.cs	(revision 12951)
+++ branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCreator.cs	(revision 12952)
@@ -22,4 +22,5 @@
 using System;
 using System.Linq;
+using HeuristicLab.Analysis;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -27,4 +28,6 @@
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.EvolutionTracking;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization.Operators;
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
@@ -99,4 +102,21 @@
       var schemaCleanupOperator = new SchemaCleanupOperator();
 
+      var changedTreesReducer = new DataReducer();
+      changedTreesReducer.ParameterToReduce.ActualName = schemaEvaluator.ChangedTreesParameter.ActualName;
+      changedTreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
+      changedTreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
+      changedTreesReducer.TargetParameter.ActualName = "NumberOfChangedTrees";
+
+      var valuesCollector = new DataTableValuesCollector();
+      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfChangedTrees"));
+      valuesCollector.DataTableParameter.ActualName = "Diversification";
+
+      var resultCollector = new ResultsCollector();
+      resultCollector.CollectedValues.Add(new LookupParameter<DataTable>("Diversification"));
+
+      var reduceChangedTrees = ExecutionContext.CreateChildOperation(changedTreesReducer);
+      var collectValues = ExecutionContext.CreateChildOperation(valuesCollector);
+      var collectResults = ExecutionContext.CreateChildOperation(resultCollector);
+
       var oc = new OperationCollection();
 
@@ -114,6 +134,12 @@
         var nodesToReplace = indices.Where(x => x >= 2).Select(x => nodes[x]).ToList();
         for (int i = nodesToReplace.Count - 1; i >= 0; --i) {
+          var node = nodesToReplace[i];
+
+          // do not replace the node with a wildcard if it would result in a length < MinimumSchemaLength
+          if ((schema.Length - node.GetLength() + 1) < MinimumSchemaLength)
+            continue;
+
           var replacement = anySubtreeSymbol.CreateTreeNode();
-          ReplaceSubtree(nodesToReplace[i], replacement, false);
+          ReplaceSubtree(node, replacement, false);
           replaced = true;
         }
@@ -131,5 +157,5 @@
       var cleanup = ExecutionContext.CreateChildOperation(schemaCleanupOperator);
       // return an operation collection containing all the scope operations + base.Apply()
-      return new OperationCollection { oc, cleanup, base.Apply() };
+      return new OperationCollection { oc, reduceChangedTrees, collectValues, collectResults, cleanup, base.Apply() };
     }
 
Index: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaEvaluator.cs
===================================================================
--- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaEvaluator.cs	(revision 12951)
+++ branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaEvaluator.cs	(revision 12952)
@@ -35,4 +35,5 @@
   [StorableClass]
   public class SchemaEvaluator : EvolutionTrackingOperator<ISymbolicExpressionTree> {
+    #region parameter names
     private const string MinimumSchemaFrequencyParameterName = "MinimumSchemaFrequency";
     private const string MinimumPhenotypicSimilarityParameterName = "MinimumPhenotypicSimilarity";
@@ -48,6 +49,73 @@
     private const string MutatorParameterName = "Mutator";
     private const string RandomReplacementParameterName = "RandomReplacement";
+    private const string ChangedTreesParameterName = "ChangedTrees";
+    #endregion
+
+    #region parameters
+    public ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>> EvaluatorParameter {
+      get { return (ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>>)Parameters[EvaluatorParameterName]; }
+    }
+    public ILookupParameter<IRegressionProblemData> ProblemDataParameter {
+      get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; }
+    }
+    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> InterpreterParameter {
+      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[InterpreterParameterName]; }
+    }
+    public ILookupParameter<DoubleLimit> EstimationLimitsParameter {
+      get { return (ILookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
+    }
+    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
+    }
+    public ILookupParameter<BoolValue> RandomReplacementParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters[RandomReplacementParameterName]; }
+    }
+    public ILookupParameter<ISymbolicExpressionTreeManipulator> MutatorParameter {
+      get { return (ILookupParameter<ISymbolicExpressionTreeManipulator>)Parameters[MutatorParameterName]; }
+    }
+    public ILookupParameter<IRandom> RandomParameter {
+      get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; }
+    }
+    public ILookupParameter<IntValue> PopulationSizeParameter {
+      get { return (ILookupParameter<IntValue>)Parameters[PopulationSizeParameterName]; }
+    }
+    public ILookupParameter<ISymbolicExpressionTree> SchemaParameter {
+      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SchemaParameterName]; }
+    }
+    public ILookupParameter<PercentValue> MinimumSchemaFrequencyParameter {
+      get { return (ILookupParameter<PercentValue>)Parameters[MinimumSchemaFrequencyParameterName]; }
+    }
+    public ILookupParameter<PercentValue> ReplacementRatioParameter {
+      get { return (ILookupParameter<PercentValue>)Parameters[ReplacementRatioParameterName]; }
+    }
+    public ILookupParameter<PercentValue> MinimumPhenotypicSimilarityParameter {
+      get { return (ILookupParameter<PercentValue>)Parameters[MinimumPhenotypicSimilarityParameterName]; }
+    }
+    public LookupParameter<IntValue> ChangedTreesParameter {
+      get { return (LookupParameter<IntValue>)Parameters[ChangedTreesParameterName]; }
+    }
+
+    #endregion
+
+    #region parameter properties
+    public PercentValue MinimumSchemaFrequency {
+      get { return MinimumSchemaFrequencyParameter.ActualValue; }
+    }
+
+    public PercentValue ReplacementRatio {
+      get { return ReplacementRatioParameter.ActualValue; }
+    }
+
+    public PercentValue MinimumPhenotypicSimilarity {
+      get { return MinimumPhenotypicSimilarityParameter.ActualValue; }
+    }
+
+    public BoolValue RandomReplacement {
+      get { return RandomReplacementParameter.ActualValue; }
+    }
+    #endregion
 
     private readonly SymbolicExpressionTreePhenotypicSimilarityCalculator calculator = new SymbolicExpressionTreePhenotypicSimilarityCalculator();
+    private readonly QueryMatch qm;
 
     private readonly ISymbolicExpressionTreeNodeEqualityComparer comp = new SymbolicExpressionTreeNodeEqualityComparer {
@@ -57,65 +125,10 @@
     };
 
-    private readonly QueryMatch qm;
-
-    #region parameters
-    public ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>> EvaluatorParameter {
-      get { return (ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>>)Parameters[EvaluatorParameterName]; }
-    }
-    public ILookupParameter<IRegressionProblemData> ProblemDataParameter {
-      get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; }
-    }
-    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> InterpreterParameter {
-      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[InterpreterParameterName]; }
-    }
-    public ILookupParameter<DoubleLimit> EstimationLimitsParameter {
-      get { return (ILookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
-    }
-    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
-      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
-    }
-    public ILookupParameter<BoolValue> RandomReplacementParameter {
-      get { return (ILookupParameter<BoolValue>)Parameters[RandomReplacementParameterName]; }
-    }
-    public ILookupParameter<ISymbolicExpressionTreeManipulator> MutatorParameter {
-      get { return (ILookupParameter<ISymbolicExpressionTreeManipulator>)Parameters[MutatorParameterName]; }
-    }
-    public ILookupParameter<IRandom> RandomParameter {
-      get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; }
-    }
-    public ILookupParameter<IntValue> PopulationSizeParameter {
-      get { return (ILookupParameter<IntValue>)Parameters[PopulationSizeParameterName]; }
-    }
-    public ILookupParameter<ISymbolicExpressionTree> SchemaParameter {
-      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SchemaParameterName]; }
-    }
-    public ILookupParameter<PercentValue> MinimumSchemaFrequencyParameter {
-      get { return (ILookupParameter<PercentValue>)Parameters[MinimumSchemaFrequencyParameterName]; }
-    }
-    public ILookupParameter<PercentValue> ReplacementRatioParameter {
-      get { return (ILookupParameter<PercentValue>)Parameters[ReplacementRatioParameterName]; }
-    }
-    public ILookupParameter<PercentValue> MinimumPhenotypicSimilarityParameter {
-      get { return (ILookupParameter<PercentValue>)Parameters[MinimumPhenotypicSimilarityParameterName]; }
-    }
-    #endregion
-
-    #region parameter properties
-    public PercentValue MinimumSchemaFrequency {
-      get { return MinimumSchemaFrequencyParameter.ActualValue; }
-    }
-
-    public PercentValue ReplacementRatio {
-      get { return ReplacementRatioParameter.ActualValue; }
-    }
-
-    public PercentValue MinimumPhenotypicSimilarity {
-      get { return MinimumPhenotypicSimilarityParameter.ActualValue; }
-    }
-
-    public BoolValue RandomReplacement {
-      get { return RandomReplacementParameter.ActualValue; }
-    }
-    #endregion
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (!Parameters.ContainsKey(ChangedTreesParameterName))
+        Parameters.Add(new LookupParameter<IntValue>(ChangedTreesParameterName));
+    }
 
     public SchemaEvaluator() {
@@ -135,4 +148,5 @@
       Parameters.Add(new LookupParameter<ISymbolicExpressionTreeManipulator>(MutatorParameterName));
       Parameters.Add(new LookupParameter<BoolValue>(RandomReplacementParameterName));
+      Parameters.Add(new LookupParameter<IntValue>(ChangedTreesParameterName));
     }
 
@@ -171,16 +185,19 @@
                                               select ind);
 
-      if (matchingIndividuals.Count < MinimumSchemaFrequency.Value * individuals.Count)
+      if (matchingIndividuals.Count < MinimumSchemaFrequency.Value * individuals.Count) {
+        ChangedTreesParameter.ActualValue = new IntValue(0);
         return base.Apply();
+      }
 
       var similarity = CalculatePhenotypicSimilarity(matchingIndividuals, calculator);
-      if (similarity < MinimumPhenotypicSimilarity.Value)
+      if (similarity < MinimumPhenotypicSimilarity.Value) {
+        ChangedTreesParameter.ActualValue = new IntValue(0);
         return base.Apply();
+      }
 
       var oc = new OperationCollection();
-
       int n = (int)Math.Round(matchingIndividuals.Count * ReplacementRatio.Value);
-      var individualsToReplace = RandomReplacement.Value ? matchingIndividuals.SampleRandomWithoutRepetition(random, n)
-                                                         : matchingIndividuals.OrderBy(x => (DoubleValue)x.Variables["Quality"].Value).Take(n);
+      var individualsToReplace = RandomReplacement.Value ? matchingIndividuals.SampleRandomWithoutRepetition(random, n).ToList()
+                                                         : matchingIndividuals.OrderBy(x => (DoubleValue)x.Variables["Quality"].Value).Take(n).ToList();
       foreach (var ind in individualsToReplace) {
         var mutatorOp = ExecutionContext.CreateChildOperation(mutator, ind);
@@ -191,5 +208,5 @@
         oc.Add(updateEstimatedValuesOp);
       }
-
+      ChangedTreesParameter.ActualValue = new IntValue(individualsToReplace.Count);
       return new OperationCollection(oc, base.Apply());
     }
