Index: /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs
===================================================================
--- /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs	(revision 13776)
+++ /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs	(revision 13777)
@@ -366,6 +366,7 @@
       #region parametrize
 
+      UpdateAnalyzers();
       ParameterizeAnalyzers();
-      UpdateAnalyzers();
+
       ParameterizeSelectors();
       UpdateTerminators();
@@ -432,4 +433,15 @@
     #region events
 
+    protected override void RegisterProblemEvents() {
+      base.RegisterProblemEvents();
+      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
+      if (maximizationParameter != null) maximizationParameter.ValueChanged += MaximizationParameter_ValueChanged;
+    }
+    protected override void DeregisterProblemEvents() {
+      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
+      if (maximizationParameter != null) maximizationParameter.ValueChanged -= MaximizationParameter_ValueChanged;
+      base.DeregisterProblemEvents();
+    }
+
     protected override void OnProblemChanged() {
       base.OnProblemChanged();
@@ -444,5 +456,8 @@
       ParameterizeSelectors();
       ParameterizeAnalyzers();
+      ParameterizeTerminators();
       ParameterizeIterationBasedOperators();
+
+      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
 
       UpdateAnalyzers();
@@ -454,8 +469,13 @@
     protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
       base.Problem_SolutionCreatorChanged(sender, e);
+
       ParameterizeStochasticOperator(Problem.SolutionCreator);
+      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
+
+      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
+
       ParameterizeSolutionsCreator();
-    }
-
+      ParameterizeAnalyzers();
+    }
     protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
       base.Problem_EvaluatorChanged(sender, e);
@@ -475,9 +495,117 @@
       UpdateTerminators();
     }
-
     protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
       base.Problem_OperatorsChanged(sender, e);
+      ParameterizeIterationBasedOperators();
+      UpdateCrossovers();
+      UpdateMutators();
       UpdateAnalyzers();
       UpdateTerminators();
+    }
+
+    private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
+      foreach (var analyzer in e.Items) {
+        IParameter resultParameter;
+        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
+          var lookupParameter = resultParameter as ILookupParameter;
+          if (lookupParameter != null)
+            lookupParameter.ActualName = "GroupResults";
+        }
+        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
+          parameter.Depth = 1;
+        }
+      }
+    }
+    private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
+      foreach (var analyzer in e.Items) {
+        IParameter resultParameter;
+        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
+          var lookupParameter = resultParameter as ILookupParameter;
+          if (lookupParameter != null)
+            lookupParameter.ActualName = "IslandResults";
+        }
+        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
+          parameter.Depth = 2;
+        }
+      }
+    }
+    private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
+      foreach (var analyzer in e.Items) {
+        IParameter resultParameter;
+        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
+          var lookupParameter = resultParameter as ILookupParameter;
+          if (lookupParameter != null)
+            lookupParameter.ActualName = "LayerResults";
+        }
+        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
+          parameter.Depth = 1;
+        }
+      }
+    }
+    private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
+      foreach (var analyzer in e.Items) {
+        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
+          parameter.Depth = 3;
+        }
+      }
+    }
+
+    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
+      ParameterizeMainLoop();
+      ParameterizeSelectors();
+      ParameterizeAnalyzers();
+    }
+    private void MaximizationParameter_ValueChanged(object sender, EventArgs e) {
+      ParameterizeTerminators();
+    }
+    private void QualityAnalyzer_CurrentBestQualityParameter_NameChanged(object sender, EventArgs e) {
+      ParameterizeTerminators();
+    }
+    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
+      ParameterizeSelectors();
+    }
+
+    private void Elites_ValueChanged(object sender, EventArgs e) {
+      ParameterizeSelectors();
+    }
+
+    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
+      ParameterizeSelectors();
+    }
+
+    private void PopulationSize_ValueChanged(object sender, EventArgs e) {
+      ParameterizeSelectors();
+    }
+
+    private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
+      NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
+      ParameterizeAgeLimits();
+    }
+    private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
+      ParameterizeAgeLimits();
+    }
+
+    private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
+      AgeGap.ValueChanged += AgeGap_ValueChanged;
+      ParameterizeAgeLimits();
+    }
+
+    private void AgeGap_ValueChanged(object sender, EventArgs e) {
+      ParameterizeAgeLimits();
+    }
+
+    private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
+      AgingScheme.ValueChanged += AgingScheme_ValueChanged;
+      ParameterizeAgeLimits();
+    }
+    private void AgingScheme_ValueChanged(object sender, EventArgs e) {
+      ParameterizeAgeLimits();
+    }
+
+    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
+      var migrationSize = (int)Math.Ceiling(MigrationRateParameter.Value.Value * PopulationSize.Value);
+      foreach (var selector in EmigrantsSelectorParameter.ValidValues) {
+        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
+      }
     }
 
@@ -593,112 +721,7 @@
       NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged;
       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
-    }
-
-    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
-      var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value*PopulationSize.Value);
-      foreach (var selector in EmigrantsSelectorParameter.ValidValues) {
-        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
-      }
-    }
-
-    private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
-      foreach (var analyzer in e.Items) {
-        IParameter resultParameter;
-        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
-          var lookupParameter = resultParameter as ILookupParameter;
-          if (lookupParameter != null)
-            lookupParameter.ActualName = "GroupResults";
-        }
-        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
-          parameter.Depth = 1;
-        }
-      }
-    }
-
-    private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
-      foreach (var analyzer in e.Items) {
-        IParameter resultParameter;
-        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
-          var lookupParameter = resultParameter as ILookupParameter;
-          if (lookupParameter != null)
-            lookupParameter.ActualName = "IslandResults";
-        }
-        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
-          parameter.Depth = 2;
-        }
-      }
-    }
-
-    private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
-      foreach (var analyzer in e.Items) {
-        IParameter resultParameter;
-        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
-          var lookupParameter = resultParameter as ILookupParameter;
-          if (lookupParameter != null)
-            lookupParameter.ActualName = "LayerResults";
-        }
-        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
-          parameter.Depth = 1;
-        }
-      }
-    }
-
-    private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
-      foreach (var analyzer in e.Items) {
-        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
-          parameter.Depth = 3;
-        }
-      }
-    }
-
-    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
-      ParameterizeMainLoop();
-      ParameterizeSelectors();
-      ParameterizeAnalyzers();
-    }
-
-    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
-      ParameterizeSelectors();
-    }
-
-    private void Elites_ValueChanged(object sender, EventArgs e) {
-      ParameterizeSelectors();
-    }
-
-    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
-      ParameterizeSelectors();
-    }
-
-    private void PopulationSize_ValueChanged(object sender, EventArgs e) {
-      ParameterizeSelectors();
-    }
-
-    private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
-      NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
-      ParameterizeAgeLimits();
-    }
-
-    private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
-      ParameterizeAgeLimits();
-    }
-
-    private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
-      AgeGap.ValueChanged += AgeGap_ValueChanged;
-      ParameterizeAgeLimits();
-    }
-
-    private void AgeGap_ValueChanged(object sender, EventArgs e) {
-      ParameterizeAgeLimits();
-    }
-
-    private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
-      AgingScheme.ValueChanged += AgingScheme_ValueChanged;
-      ParameterizeAgeLimits();
-    }
-
-    private void AgingScheme_ValueChanged(object sender, EventArgs e) {
-      ParameterizeAgeLimits();
-    }
-
+      qualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged;
+
+    }
     private void ParameterizeAgeLimits() {
       var scheme = AgingScheme.Value;
