Index: branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/Algorithms/LocalAnalysis.cs
===================================================================
--- branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Algorithms/LocalAnalysis.cs	(revision 8172)
+++ branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/Algorithms/LocalAnalysis.cs	(revision 13583)
@@ -20,21 +20,20 @@
 #endregion
 
-using System;
-using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Data;
+using HeuristicLab.Operators;
 using HeuristicLab.Optimization;
 using HeuristicLab.Optimization.Operators;
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.PluginInfrastructure;
 using HeuristicLab.Random;
+using System;
+using System.Linq;
 
 namespace HeuristicLab.Analysis.FitnessLandscape {
   [Item("Local Analysis", "A local analysis algorithm.")]
-  [Creatable("Algorithms")]
   [StorableClass]
-  public sealed class LocalAnalysis : HeuristicOptimizationEngineAlgorithm, IStorableContent {
+  public abstract class LocalAnalysis<T> : HeuristicOptimizationEngineAlgorithm, IStorableContent where T : class, IOperator, new() {
     public string Filename { get; set; }
 
@@ -50,39 +49,38 @@
 
     #region Parameter Properties
-    private ValueParameter<IntValue> SeedParameter {
-      get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
-    }
-    private ValueParameter<BoolValue> SetSeedRandomlyParameter {
-      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
+    public IFixedValueParameter<IntValue> SeedParameter {
+      get { return (IFixedValueParameter<IntValue>)Parameters["Seed"]; }
+    }
+    public IFixedValueParameter<BoolValue> SetSeedRandomlyParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
     }
     public IConstrainedValueParameter<IManipulator> MutatorParameter {
       get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
     }
-    public IConstrainedValueParameter<ISelector> SelectorParameter {
-      get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
-    }
-    private ValueParameter<IntValue> MaximumIterationsParameter {
-      get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; }
-    }
-    private ValueParameter<IntValue> SampleSizeParameter {
-      get { return (ValueParameter<IntValue>)Parameters["SampleSize"]; }
-    }
-    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
-      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
+    public IFixedValueParameter<IntValue> MaximumIterationsParameter {
+      get { return (IFixedValueParameter<IntValue>)Parameters["MaximumIterations"]; }
+    }
+    public IValueParameter<MultiAnalyzer> AnalyzerParameter {
+      get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
+    }
+    public IFixedValueParameter<T> SelectorParameter {
+      get { return (IFixedValueParameter<T>)Parameters["Selector"]; }
     }
     #endregion
 
     #region Properties
-    private RandomCreator RandomCreator {
+    protected RandomCreator RandomCreator {
       get { return (RandomCreator)OperatorGraph.InitialOperator; }
     }
-    private SolutionsCreator SolutionsCreator {
-      get { return (SolutionsCreator)RandomCreator.Successor; }
-    }
-    private LocalAnalysisMainLoop MainLoop {
+    protected VariableCreator VariableCreator {
+      get { return (VariableCreator)RandomCreator.Successor; }
+    }
+    protected SolutionsCreator SolutionsCreator {
+      get { return (SolutionsCreator)VariableCreator.Successor; }
+    }
+    protected LocalAnalysisMainLoop MainLoop {
       get { return (LocalAnalysisMainLoop)SolutionsCreator.Successor; }
     }
-    [Storable]
-    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
+
     [Storable]
     private QualityTrailMultiAnalyzer qualityTrailAnalyzer;
@@ -90,22 +88,21 @@
 
     [StorableConstructor]
-    private LocalAnalysis(bool deserializing) : base(deserializing) { }
-    private LocalAnalysis(LocalAnalysis original, Cloner cloner)
+    protected LocalAnalysis(bool deserializing) : base(deserializing) { }
+    protected LocalAnalysis(LocalAnalysis<T> original, Cloner cloner)
       : base(original, cloner) {
-      qualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(original.qualityAnalyzer);
-      qualityTrailAnalyzer = (QualityTrailMultiAnalyzer)cloner.Clone(original.qualityTrailAnalyzer);
-      Initialize();
-    }
-    public LocalAnalysis()
+      qualityTrailAnalyzer = cloner.Clone(original.qualityTrailAnalyzer);
+      RegisterEventHandlers();
+    }
+    protected LocalAnalysis(T selector)
       : base() {
-      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
-      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
+      Parameters.Add(new FixedValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
+      Parameters.Add(new FixedValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
       Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "Mutation operator."));
-      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "Selection operator."));
-      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(10000)));
-      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(1)));
+      Parameters.Add(new FixedValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(10000)));
       Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.", new MultiAnalyzer()));
+      Parameters.Add(new FixedValueParameter<T>("Selector", "Selection operator.", selector));
 
       RandomCreator randomCreator = new RandomCreator();
+      VariableCreator variableCreator = new VariableCreator();
       SolutionsCreator solutionsCreator = new SolutionsCreator();
       LocalAnalysisMainLoop laMainLoop = new LocalAnalysisMainLoop();
@@ -117,5 +114,7 @@
       randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
       randomCreator.SetSeedRandomlyParameter.Value = null;
-      randomCreator.Successor = solutionsCreator;
+      randomCreator.Successor = variableCreator;
+
+      variableCreator.Successor = solutionsCreator;
 
       solutionsCreator.NumberOfSolutions = new IntValue(1);
@@ -129,146 +128,85 @@
       laMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
 
-      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
       qualityTrailAnalyzer = new QualityTrailMultiAnalyzer();
-      ParameterizeAnalyzers();
-      UpdateAnalyzers();
-
-      Initialize();
-    }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new LocalAnalysis(this, cloner);
+      qualityTrailAnalyzer.UpdateIntervalParameter.Value = null;
+      qualityTrailAnalyzer.UpdateIntervalParameter.ActualName = "MaximumIterations";
+      AnalyzerParameter.Value.Operators.Add(qualityTrailAnalyzer, true);
+
+      RegisterEventHandlers();
     }
 
     public override void Prepare() {
-      if (Problem != null)
-        base.Prepare();
+      if (Problem != null) base.Prepare();
     }
 
     #region Events
     protected override void OnProblemChanged() {
-      ParameterizeStochasticOperator(Problem.SolutionCreator);
-      ParameterizeStochasticOperator(Problem.Evaluator);
-      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
-      ParameterizeSolutionsCreator();
-      ParameterizeMainLoop();
+      base.OnProblemChanged();
       UpdateMutators();
-      UpdateSelectors();
-      UpdateAnalyzers();
-      ParameterizeSelector();
-      ParameterizeAnalyzers();
-      ParameterizeIterationBasedOperators();
-      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
-      base.OnProblemChanged();
+      Parameterize();
+      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     }
     protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
-      ParameterizeStochasticOperator(Problem.SolutionCreator);
-      ParameterizeSolutionsCreator();
       base.Problem_SolutionCreatorChanged(sender, e);
+      Parameterize();
     }
     protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
-      ParameterizeStochasticOperator(Problem.Evaluator);
-      ParameterizeSolutionsCreator();
-      ParameterizeMainLoop();
-      ParameterizeSelector();
-      ParameterizeAnalyzers();
-      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
       base.Problem_EvaluatorChanged(sender, e);
+      Parameterize();
+      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     }
     protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
-      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
       UpdateMutators();
-      UpdateSelectors();
-      UpdateAnalyzers();
-      ParameterizeMainLoop();
-      ParameterizeSelector();
-      ParameterizeAnalyzers();
-      ParameterizeIterationBasedOperators();
+      Parameterize();
       base.Problem_OperatorsChanged(sender, e);
     }
     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
-      ParameterizeMainLoop();
-      ParameterizeSelector();
-    }
-    private void MutatorParameter_ValueChanged(object sender, EventArgs e) {
-      ParameterizeMainLoop();
-      ParameterizeSelector();
-      ParameterizeAnalyzers();
+      Parameterize();
     }
     #endregion
 
     #region Helpers
-    [StorableHook(HookType.AfterDeserialization)]
-    private void Initialize() {
+    private void RegisterEventHandlers() {
       if (Problem != null) {
-        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
-      }
-      MutatorParameter.ValueChanged += MutatorParameter_ValueChanged;
-    }
-    private void UpdateSelectors() {
-      SelectorParameter.ValidValues.Clear();
-      foreach (var s in ApplicationManager.Manager.GetInstances<ISelector>())
-        SelectorParameter.ValidValues.Add(s);
-    }
+        Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
+      }
+    }
+
     private void UpdateMutators() {
+      var selected = MutatorParameter.Value;
       MutatorParameter.ValidValues.Clear();
       foreach (var m in Problem.Operators.OfType<IManipulator>()) {
         MutatorParameter.ValidValues.Add(m);
-      }
-    }
-    private void UpdateAnalyzers() {
-      AnalyzerParameter.Value.Operators.Clear();
-      if (Problem != null) {
-        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
-          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
-            param.Depth = 0;
-          AnalyzerParameter.Value.Operators.Add(analyzer);
-        }
-      }
-      AnalyzerParameter.Value.Operators.Add(qualityAnalyzer);
-      AnalyzerParameter.Value.Operators.Add(qualityTrailAnalyzer);
-    }
-    private void ParameterizeSolutionsCreator() {
-      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
-      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
-    }
-    private void ParameterizeMainLoop() {
+        if (selected != null && selected.GetType() == m.GetType()) MutatorParameter.Value = m;
+      }
+    }
+
+    protected virtual void Parameterize() {
+      if (Problem == null) return;
+
       MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
       MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
       MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
-    }
-    private void ParameterizeStochasticOperator(IOperator op) {
-      if (op is IStochasticOperator)
-        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
-    }
-    private void ParameterizeSelector() {
-      if (Problem != null) {
-        foreach (var op in SelectorParameter.ValidValues) {
-          op.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
-          op.CopySelected = new BoolValue(false);
-          ISingleObjectiveSelector sos = op as ISingleObjectiveSelector;
-          if (sos != null) {
-            sos.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
-            sos.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
-          }
-          IStochasticOperator so = op as IStochasticOperator;
-          if (so != null) {
-            so.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
-          }
-        }
-      }
-    }
-    private void ParameterizeAnalyzers() {
-      qualityAnalyzer.ResultsParameter.ActualName = "Results";
-      if (Problem != null) {
-        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
-        qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
-      }
-    }
-    private void ParameterizeIterationBasedOperators() {
-      if (Problem != null) {
-        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
-          op.IterationsParameter.ActualName = "Iterations";
-          op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
+      foreach (var sOp in Problem.Operators.OfType<IStochasticOperator>()) {
+        sOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
+      }
+      foreach (var iOp in Problem.Operators.OfType<IIterationBasedOperator>()) {
+        iOp.IterationsParameter.ActualName = "Iterations";
+        iOp.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
+      }
+      var sEval = Problem.Evaluator as IStochasticOperator;
+      if (sEval != null) sEval.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
+      var sCrea = Problem.SolutionCreator as IStochasticOperator;
+      if (sCrea != null) sCrea.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
+      var sSel = SelectorParameter.Value as IStochasticOperator;
+      if (sSel != null) sSel.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
+      var sel = SelectorParameter.Value as ISelector;
+      if (sel != null) {
+        sel.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
+        sel.CopySelected = new BoolValue(false);
+        var sos = sel as ISingleObjectiveSelector;
+        if (sos != null) {
+          sos.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
+          sos.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
         }
       }
