Index: /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAverageMaxSymbolicExpressionTreeSizeAnalyzer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAverageMaxSymbolicExpressionTreeSizeAnalyzer.cs	(revision 3817)
+++ /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAverageMaxSymbolicExpressionTreeSizeAnalyzer.cs	(revision 3817)
@@ -0,0 +1,133 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System.Collections.Generic;
+using HeuristicLab.Analysis;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
+using System;
+using HeuristicLab.Optimization.Operators;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers {
+  /// <summary>
+  /// An operator that tracks the min average and max tree size.
+  /// </summary>
+  [Item("MinAverageMaxSymbolicExpressionTreeSizeAnalyzer", "An operator that tracks the min avgerage and max tree size.")]
+  [StorableClass]
+  public sealed class MinAverageMaxSymbolicExpressionTreeSizeAnalyzer : AlgorithmOperator, ISymbolicExpressionTreeAnalyzer {
+    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
+    private const string SymbolicExpressionTreeSizeParameterName = "SymbolicExpressionTreeSize";
+    private const string SymbolicExpressionTreeSizesParameterName = "Symbolic expression tree size";
+    private const string MinTreeSizeParameterName = "Min tree size";
+    private const string AverageTreeSizeParameterName = "Average tree size";
+    private const string MaxTreeSizeParameterName = "Max tree size";
+    private const string ResultsParameterName = "Results";
+
+    #region parameter properties
+    public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
+      get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
+    }
+    public ScopeTreeLookupParameter<DoubleValue> SymbolicExpressionTreeSizeParameter {
+      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[SymbolicExpressionTreeSizeParameterName]; }
+    }
+    public ValueLookupParameter<DataTable> SymbolicExpressionTreeSizesParameter {
+      get { return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeSizesParameterName]; }
+    }
+    public ValueLookupParameter<VariableCollection> ResultsParameter {
+      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
+    }
+
+    [Storable]
+    private MinAverageMaxValueAnalyzer valueAnalyzer;
+    [Storable]
+    private UniformSubScopesProcessor subScopesProcessor;
+
+    #endregion
+    public MinAverageMaxSymbolicExpressionTreeSizeAnalyzer()
+      : base() {
+      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose size should be calculated."));
+      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(SymbolicExpressionTreeSizeParameterName, "The tree size of the symbolic expression tree."));
+      Parameters.Add(new ValueLookupParameter<DataTable>(SymbolicExpressionTreeSizesParameterName, "The data table to store the tree sizes."));
+      Parameters.Add(new ValueLookupParameter<VariableCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
+
+      subScopesProcessor = new UniformSubScopesProcessor();
+      SymbolicExpressionTreeSizeCalculator sizeCalculator = new SymbolicExpressionTreeSizeCalculator();
+      valueAnalyzer = new MinAverageMaxValueAnalyzer();
+
+      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
+      sizeCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
+      sizeCalculator.SymbolicExpressionTreeSizeParameter.ActualName = SymbolicExpressionTreeSizeParameter.Name;
+      valueAnalyzer.ValueParameter.ActualName = sizeCalculator.SymbolicExpressionTreeSizeParameter.Name;
+      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeSizeParameter.Depth;
+      valueAnalyzer.AverageValueParameter.ActualName = AverageTreeSizeParameterName;
+      valueAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
+      valueAnalyzer.MaxValueParameter.ActualName = MaxTreeSizeParameterName;
+      valueAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
+      valueAnalyzer.MinValueParameter.ActualName = MinTreeSizeParameterName;
+      valueAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
+      valueAnalyzer.ValuesParameter.ActualName = SymbolicExpressionTreeSizesParameter.Name;
+
+      OperatorGraph.InitialOperator = subScopesProcessor;
+      subScopesProcessor.Operator = sizeCalculator;
+      sizeCalculator.Successor = null;
+      subScopesProcessor.Successor = valueAnalyzer;
+      valueAnalyzer.Successor = null;
+
+      Initialize();
+    }
+
+    [StorableConstructor]
+    private MinAverageMaxSymbolicExpressionTreeSizeAnalyzer(bool deserializing) : base() { }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void Initialize() {
+      SymbolicExpressionTreeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeParameter_DepthChanged);
+      SymbolicExpressionTreeSizeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeSizeParameter_DepthChanged);
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      MinAverageMaxSymbolicExpressionTreeSizeAnalyzer clone = (MinAverageMaxSymbolicExpressionTreeSizeAnalyzer)base.Clone(cloner);
+      clone.Initialize();
+      return clone;
+    }
+
+    private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) {
+      OnDepthParameterChanged();
+    }
+
+    private void SymbolicExpressionTreeSizeParameter_DepthChanged(object sender, EventArgs e) {
+      OnDepthParameterChanged();
+    }
+
+    private void OnDepthParameterChanged() {
+      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth;
+      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
+    }
+  }
+}
Index: unk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAvgMaxSymbolicExpressionTreeSizeAnalyzer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAvgMaxSymbolicExpressionTreeSizeAnalyzer.cs	(revision 3816)
+++ 	(revision )
@@ -1,133 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System.Linq;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Operators;
-using HeuristicLab.Optimization;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using System.Collections.Generic;
-using HeuristicLab.Analysis;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
-using System;
-using HeuristicLab.Optimization.Operators;
-
-namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers {
-  /// <summary>
-  /// An operator that tracks the min avgerage and max tree size.
-  /// </summary>
-  [Item("MinAvgMaxSymbolicExpressionTreeSizeAnalyzer", "An operator that tracks the min avgerage and max tree size.")]
-  [StorableClass]
-  public sealed class MinAvgMaxSymbolicExpressionTreeSizeAnalyzer : AlgorithmOperator, ISymbolicExpressionTreeAnalyzer {
-    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
-    private const string SymbolicExpressionTreeSizeParameterName = "SymbolicExpressionTreeSize";
-    private const string SymbolicExpressionTreeSizesParameterName = "Symbolic expression tree size";
-    private const string MinTreeSizeParameterName = "Min tree size";
-    private const string AverageTreeSizeParameterName = "Average tree size";
-    private const string MaxTreeSizeParameterName = "Max tree size";
-    private const string ResultsParameterName = "Results";
-
-    #region parameter properties
-    public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
-      get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
-    }
-    public ScopeTreeLookupParameter<DoubleValue> SymbolicExpressionTreeSizeParameter {
-      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[SymbolicExpressionTreeSizeParameterName]; }
-    }
-    public ValueLookupParameter<DataTable> SymbolicExpressionTreeSizesParameter {
-      get { return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeSizesParameterName]; }
-    }
-    public ValueLookupParameter<VariableCollection> ResultsParameter {
-      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
-    }
-
-    [Storable]
-    private MinAverageMaxValueAnalyzer valueAnalyzer;
-    [Storable]
-    private UniformSubScopesProcessor subScopesProcessor;
-
-    #endregion
-    public MinAvgMaxSymbolicExpressionTreeSizeAnalyzer()
-      : base() {
-      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose size should be calculated."));
-      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(SymbolicExpressionTreeSizeParameterName, "The tree size of the symbolic expression tree."));
-      Parameters.Add(new ValueLookupParameter<DataTable>(SymbolicExpressionTreeSizesParameterName, "The data table to store the tree sizes."));
-      Parameters.Add(new ValueLookupParameter<VariableCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
-
-      subScopesProcessor = new UniformSubScopesProcessor();
-      SymbolicExpressionTreeSizeCalculator sizeCalculator = new SymbolicExpressionTreeSizeCalculator();
-      valueAnalyzer = new MinAverageMaxValueAnalyzer();
-
-      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
-      sizeCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
-      sizeCalculator.SymbolicExpressionTreeSizeParameter.ActualName = SymbolicExpressionTreeSizeParameter.Name;
-      valueAnalyzer.ValueParameter.ActualName = sizeCalculator.SymbolicExpressionTreeSizeParameter.Name;
-      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeSizeParameter.Depth;
-      valueAnalyzer.AverageValueParameter.ActualName = AverageTreeSizeParameterName;
-      valueAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
-      valueAnalyzer.MaxValueParameter.ActualName = MaxTreeSizeParameterName;
-      valueAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
-      valueAnalyzer.MinValueParameter.ActualName = MinTreeSizeParameterName;
-      valueAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
-      valueAnalyzer.ValuesParameter.ActualName = SymbolicExpressionTreeSizesParameter.Name;
-
-      OperatorGraph.InitialOperator = subScopesProcessor;
-      subScopesProcessor.Operator = sizeCalculator;
-      sizeCalculator.Successor = null;
-      subScopesProcessor.Successor = valueAnalyzer;
-      valueAnalyzer.Successor = null;
-
-      Initialize();
-    }
-
-    [StorableConstructor]
-    private MinAvgMaxSymbolicExpressionTreeSizeAnalyzer(bool deserializing) : base() { }
-
-    [StorableHook(HookType.AfterDeserialization)]
-    private void Initialize() {
-      SymbolicExpressionTreeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeParameter_DepthChanged);
-      SymbolicExpressionTreeSizeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeSizeParameter_DepthChanged);
-    }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      MinAvgMaxSymbolicExpressionTreeSizeAnalyzer clone = (MinAvgMaxSymbolicExpressionTreeSizeAnalyzer)base.Clone(cloner);
-      clone.Initialize();
-      return clone;
-    }
-
-    private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) {
-      OnDepthParameterChanged();
-    }
-
-    private void SymbolicExpressionTreeSizeParameter_DepthChanged(object sender, EventArgs e) {
-      OnDepthParameterChanged();
-    }
-
-    private void OnDepthParameterChanged() {
-      valueAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth;
-      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
-    }
-  }
-}
Index: /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj	(revision 3816)
+++ /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj	(revision 3817)
@@ -83,5 +83,5 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Analyzers\MinAvgMaxSymbolicExpressionTreeSizeAnalyzer.cs" />
+    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeSizeAnalyzer.cs" />
     <Compile Include="Analyzers\SymbolicExpressionTreeSizeCalculator.cs" />
     <Compile Include="ArchitectureManipulators\ArgumentCreater.cs" />
Index: /trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj	(revision 3816)
+++ /trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj	(revision 3817)
@@ -92,5 +92,4 @@
     <Compile Include="Assigner.cs" />
     <Compile Include="AlgorithmOperator.cs" />
-    <Compile Include="StochasticMultiBranchOfT.cs" />
     <Compile Include="MultiOperator.cs" />
     <Compile Include="Operator.cs" />
Index: /trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs
===================================================================
--- /trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs	(revision 3816)
+++ /trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs	(revision 3817)
@@ -34,4 +34,111 @@
   /// Selects one of its branches (if there are any) given a list of relative probabilities.
   /// </summary>
+  [Item("StochasticMultiBranch<T>", "Selects one of its branches (if there are any) given a list of relative probabilities.")]
+  [StorableClass]
+  public abstract class StochasticMultiBranch<T> : CheckedMultiOperator<T> where T : class, IOperator {
+    /// <summary>
+    /// Should return true if the StochasticMultiOperator should create a new child operation with the selected successor
+    /// or if it should create a new operation. If you need to shield the parameters of the successor you should return true here.
+    /// </summary>
+    protected abstract bool CreateChildOperation { get; }
+
+    public ValueLookupParameter<DoubleArray> ProbabilitiesParameter {
+      get { return (ValueLookupParameter<DoubleArray>)Parameters["Probabilities"]; }
+    }
+    public ILookupParameter<IRandom> RandomParameter {
+      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
+    }
+
+    public DoubleArray Probabilities {
+      get { return ProbabilitiesParameter.Value; }
+      set { ProbabilitiesParameter.Value = value; }
+    }
+
+    [StorableConstructor]
+    protected StochasticMultiBranch(bool deserializing) : base(deserializing) { }
+    /// <summary>
+    /// Initializes a new instance of <see cref="StochasticMultiOperator"/> with two parameters
+    /// (<c>Probabilities</c> and <c>Random</c>).
+    /// </summary>
+    public StochasticMultiBranch()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<DoubleArray>("Probabilities", "The array of relative probabilities for each operator.", new DoubleArray()));
+      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
+    }
+
+    protected override void Operators_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
+      base.Operators_ItemsRemoved(sender, e);
+      if (Probabilities != null && Probabilities.Length > Operators.Count) {
+        List<double> probs = new List<double>(Probabilities.Cast<double>());
+        var sorted = e.Items.OrderByDescending(x => x.Index);
+        foreach (IndexedItem<T> item in sorted)
+          if (probs.Count > item.Index) probs.RemoveAt(item.Index);
+        Probabilities = new DoubleArray(probs.ToArray());
+      }
+    }
+
+    protected override void Operators_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
+      base.Operators_ItemsAdded(sender, e);
+      if (Probabilities != null && Probabilities.Length < Operators.Count) {
+        double avg = (Probabilities.Where(x => x > 0).Count() > 0) ? (Probabilities.Where(x => x > 0).Average()) : (1);
+        // add the average of all probabilities in the respective places (the new operators)
+        var added = e.Items.OrderBy(x => x.Index).ToList();
+        int insertCount = 0;
+        DoubleArray probs = new DoubleArray(Operators.Count);
+        for (int i = 0; i < Operators.Count; i++) {
+          if (insertCount < added.Count && i == added[insertCount].Index) {
+            probs[i] = avg;
+            insertCount++;
+          } else if (i - insertCount < Probabilities.Length) {
+            probs[i] = Probabilities[i - insertCount];
+          } else probs[i] = avg;
+        }
+        Probabilities = probs;
+      }
+    }
+
+    /// <summary>
+    /// Applies an operator of the branches to the current scope with a 
+    /// specific probability.
+    /// </summary>
+    /// <exception cref="InvalidOperationException">Thrown when the list of probabilites does not
+    /// match the number of operators, the list of selected operators is empty, 
+    /// or all selected operators have zero probabitlity.</exception>
+    /// <returns>A new operation with the operator that was selected followed by the current operator's successor.</returns>
+    public override IOperation Apply() {
+      IRandom random = RandomParameter.ActualValue;
+      DoubleArray probabilities = ProbabilitiesParameter.ActualValue;
+      if (probabilities.Length != Operators.Count) {
+        throw new InvalidOperationException(Name + ": The list of probabilities has to match the number of operators");
+      }
+      IOperator successor = null;
+      var checkedOperators = Operators.CheckedItems;
+      if (checkedOperators.Count() > 0) {
+        // select a random operator from the checked operators
+        double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum();
+        if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability.");
+        double r = random.NextDouble() * sum;
+        sum = 0;
+        foreach (var indexedItem in checkedOperators) {
+          sum += probabilities[indexedItem.Index];
+          if (sum > r) {
+            successor = indexedItem.Value;
+            break;
+          }
+        }
+      }
+      OperationCollection next = new OperationCollection(base.Apply());
+      if (successor != null) {
+        if (CreateChildOperation)
+          next.Insert(0, ExecutionContext.CreateChildOperation(successor));
+        else next.Insert(0, ExecutionContext.CreateOperation(successor));
+      }
+      return next;
+    }
+  }
+
+  /// <summary>
+  /// Selects one of its branches (if there are any) given a list of relative probabilities.
+  /// </summary>
   [Item("StochasticMultiBranch", "Selects one of its branches (if there are any) given a list of relative probabilities.")]
   [StorableClass]
Index: unk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranchOfT.cs
===================================================================
--- /trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranchOfT.cs	(revision 3816)
+++ 	(revision )
@@ -1,139 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Collections;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.PluginInfrastructure;
-
-namespace HeuristicLab.Operators {
-  /// <summary>
-  /// Selects one of its branches (if there are any) given a list of relative probabilities.
-  /// </summary>
-  [Item("StochasticMultiBranch<T>", "Selects one of its branches (if there are any) given a list of relative probabilities.")]
-  [StorableClass]
-  public abstract class StochasticMultiBranch<T> : CheckedMultiOperator<T> where T : class, IOperator {
-    /// <summary>
-    /// Should return true if the StochasticMultiOperator should create a new child operation with the selected successor
-    /// or if it should create a new operation. If you need to shield the parameters of the successor you should return true here.
-    /// </summary>
-    protected abstract bool CreateChildOperation { get; }
-
-    public ValueLookupParameter<DoubleArray> ProbabilitiesParameter {
-      get { return (ValueLookupParameter<DoubleArray>)Parameters["Probabilities"]; }
-    }
-    public ILookupParameter<IRandom> RandomParameter {
-      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
-    }
-
-    public DoubleArray Probabilities {
-      get { return ProbabilitiesParameter.Value; }
-      set { ProbabilitiesParameter.Value = value; }
-    }
-
-    [StorableConstructor]
-    protected StochasticMultiBranch(bool deserializing) : base(deserializing) { }
-    /// <summary>
-    /// Initializes a new instance of <see cref="StochasticMultiOperator"/> with two parameters
-    /// (<c>Probabilities</c> and <c>Random</c>).
-    /// </summary>
-    public StochasticMultiBranch()
-      : base() {
-      Parameters.Add(new ValueLookupParameter<DoubleArray>("Probabilities", "The array of relative probabilities for each operator.", new DoubleArray()));
-      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
-    }
-
-    protected override void Operators_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
-      base.Operators_ItemsRemoved(sender, e);
-      if (Probabilities != null && Probabilities.Length > Operators.Count) {
-        List<double> probs = new List<double>(Probabilities.Cast<double>());
-        var sorted = e.Items.OrderByDescending(x => x.Index);
-        foreach (IndexedItem<T> item in sorted)
-          if (probs.Count > item.Index) probs.RemoveAt(item.Index);
-        Probabilities = new DoubleArray(probs.ToArray());
-      }
-    }
-
-    protected override void Operators_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
-      base.Operators_ItemsAdded(sender, e);
-      if (Probabilities != null && Probabilities.Length < Operators.Count) {
-        double avg = (Probabilities.Where(x => x > 0).Count() > 0) ? (Probabilities.Where(x => x > 0).Average()) : (1);
-        // add the average of all probabilities in the respective places (the new operators)
-        var added = e.Items.OrderBy(x => x.Index).ToList();
-        int insertCount = 0;
-        DoubleArray probs = new DoubleArray(Operators.Count);
-        for (int i = 0; i < Operators.Count; i++) {
-          if (insertCount < added.Count && i == added[insertCount].Index) {
-            probs[i] = avg;
-            insertCount++;
-          } else if (i - insertCount < Probabilities.Length) {
-            probs[i] = Probabilities[i - insertCount];
-          } else probs[i] = avg;
-        }
-        Probabilities = probs;
-      }
-    }
-
-    /// <summary>
-    /// Applies an operator of the branches to the current scope with a 
-    /// specific probability.
-    /// </summary>
-    /// <exception cref="InvalidOperationException">Thrown when the list of probabilites does not
-    /// match the number of operators, the list of selected operators is empty, 
-    /// or all selected operators have zero probabitlity.</exception>
-    /// <returns>A new operation with the operator that was selected followed by the current operator's successor.</returns>
-    public override IOperation Apply() {
-      IRandom random = RandomParameter.ActualValue;
-      DoubleArray probabilities = ProbabilitiesParameter.ActualValue;
-      if (probabilities.Length != Operators.Count) {
-        throw new InvalidOperationException(Name + ": The list of probabilities has to match the number of operators");
-      }
-      IOperator successor = null;
-      var checkedOperators = Operators.CheckedItems;
-      if (checkedOperators.Count() > 0) {
-        // select a random operator from the checked operators
-        double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum();
-        if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability.");
-        double r = random.NextDouble() * sum;
-        sum = 0;
-        foreach (var indexedItem in checkedOperators) {
-          sum += probabilities[indexedItem.Index];
-          if (sum > r) {
-            successor = indexedItem.Value;
-            break;
-          }
-        }
-      }
-      OperationCollection next = new OperationCollection(base.Apply());
-      if (successor != null) {
-        if (CreateChildOperation)
-          next.Insert(0, ExecutionContext.CreateChildOperation(successor));
-        else next.Insert(0, ExecutionContext.CreateOperation(successor));
-      }
-      return next;
-    }
-  }
-}
Index: /trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs	(revision 3816)
+++ /trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs	(revision 3817)
@@ -301,5 +301,5 @@
       operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>());
       operators.Add(new BestAntTrailAnalyzer());
-      operators.Add(new MinAvgMaxSymbolicExpressionTreeSizeAnalyzer());
+      operators.Add(new MinAverageMaxSymbolicExpressionTreeSizeAnalyzer());
       ParameterizeAnalyzers();
       ParameterizeOperators();
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs	(revision 3816)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs	(revision 3817)
@@ -369,5 +369,5 @@
       operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>());
       operators.Add(new ValidationBestScaledSymbolicRegressionSolutionAnalyzer());
-      operators.Add(new MinAvgMaxSymbolicExpressionTreeSizeAnalyzer());
+      operators.Add(new MinAverageMaxSymbolicExpressionTreeSizeAnalyzer());
       operators.Add(new SymbolicRegressionVariableFrequencyAnalyzer());
       ParameterizeOperators();
