Index: trunk/sources/HeuristicLab.FixedOperators/3.2/CreateChildrenHardWired.cs
===================================================================
--- trunk/sources/HeuristicLab.FixedOperators/3.2/CreateChildrenHardWired.cs	(revision 1646)
+++ trunk/sources/HeuristicLab.FixedOperators/3.2/CreateChildrenHardWired.cs	(revision 1661)
@@ -88,5 +88,5 @@
         while (s.SubScopes.Count > 0)
           s.RemoveSubScope(s.SubScopes[0]);
-       
+
         counter++;
       } // foreach
Index: trunk/sources/HeuristicLab.FixedOperators/3.2/CreateReplacement.cs
===================================================================
--- trunk/sources/HeuristicLab.FixedOperators/3.2/CreateReplacement.cs	(revision 1646)
+++ trunk/sources/HeuristicLab.FixedOperators/3.2/CreateReplacement.cs	(revision 1661)
@@ -42,7 +42,4 @@
     Sorter sorter;
 
-    IRandom random;
-    DoubleData probability;
-
     public override string Description {
       get { return @"Implements the control structures of CreateReplacement hard wired. Operators are delegated."; }
@@ -63,8 +60,4 @@
       ls.GetVariableInfo("Selected").ActualName = "Elites";
       rs.GetVariableInfo("Selected").ActualName = "Elites";
-
-      // variables infos
-      //AddVariableInfo(new VariableInfo("Random", "Pseudo random number generator", typeof(IRandom), VariableKind.In));
-      //AddVariableInfo(new VariableInfo("Elites", "Number of selected sub-scopes", typeof(IntData), VariableKind.In));
     }
 
@@ -73,5 +66,5 @@
       ls.Execute(scope.SubScopes[0]);
       rr.Execute(scope.SubScopes[0]);
-      
+
       rs.Execute(scope.SubScopes[1]);
       lr.Execute(scope.SubScopes[1]);
Index: trunk/sources/HeuristicLab.FixedOperators/3.2/FixedAllSGAMain.cs
===================================================================
--- trunk/sources/HeuristicLab.FixedOperators/3.2/FixedAllSGAMain.cs	(revision 1661)
+++ trunk/sources/HeuristicLab.FixedOperators/3.2/FixedAllSGAMain.cs	(revision 1661)
@@ -0,0 +1,251 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 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.Text;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Permutation;
+using HeuristicLab.Evolutionary;
+using HeuristicLab.Operators;
+using HeuristicLab.Routing.TSP;
+using HeuristicLab.Logging;
+using System.Diagnostics;
+
+namespace HeuristicLab.FixedOperators {
+  class FixedAllSGAMain : CombinedOperator {
+    public override string Description {
+      get { return @"Implements the functionality of SGAMain with fixed control structures. Operators like selection, crossover, mutation and evaluation are delegated."; }
+    }
+
+    ChildrenInitializer ci;
+    OperatorBase crossover;
+    OperatorBase mutator;
+    OperatorBase evaluator;
+    IRandom random;
+    DoubleData probability;
+
+    long[] timesExecuteCreateChildren;
+
+    public FixedAllSGAMain()
+      : base() {
+      AddVariableInfo(new VariableInfo("Selector", "Selection strategy for SGA", typeof(OperatorBase), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MaximumGenerations", "Maximum number of generations to create", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Generations", "Number of processed generations", typeof(IntData), VariableKind.In | VariableKind.Out));
+      Name = "FixedAllSGAMain";
+      InitCreateChildrenHW();
+
+    }
+
+    private void InitCreateChildrenHW() {
+      // variables infos
+      AddVariableInfo(new VariableInfo("Random", "Pseudo random number generator", typeof(IRandom), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MutationRate", "Probability to choose first branch", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Crossover", "Crossover strategy for SGA", typeof(OperatorBase), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Mutator", "Mutation strategy for SGA", typeof(OperatorBase), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Evaluator", "Evaluation strategy for SGA", typeof(OperatorBase), VariableKind.In));
+      AddVariableInfo(new VariableInfo("EvaluatedSolutions", "Number of evaluated solutions", typeof(IntData), VariableKind.In | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("Maximization", "Sort in descending order", typeof(BoolData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Quality", "Sorting value", typeof(DoubleData), VariableKind.In));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      Stopwatch swApply = new Stopwatch();
+      swApply.Start();
+      //base.Apply(scope); // noch nachfragen ob das auch in ordnung wäre
+      for (int i = 0; i < SubOperators.Count; i++) {
+        if (scope.GetVariable(SubOperators[i].Name) != null)
+          scope.RemoveVariable(SubOperators[i].Name);
+        scope.AddVariable(new Variable(SubOperators[i].Name, SubOperators[i]));
+      }
+
+      OperatorBase selector = (OperatorBase)GetVariableValue("Selector", scope, true);
+      OperatorBase createReplacement = new CreateReplacement();
+      QualityLogger ql = new QualityLogger();
+
+      BestAverageWorstQualityCalculator bawqc = new BestAverageWorstQualityCalculator();
+      DataCollector dc = new DataCollector();
+      ItemList<StringData> names = dc.GetVariable("VariableNames").GetValue<ItemList<StringData>>();
+      names.Add(new StringData("BestQuality"));
+      names.Add(new StringData("AverageQuality"));
+      names.Add(new StringData("WorstQuality"));
+
+      LinechartInjector lci = new LinechartInjector();
+      lci.GetVariableInfo("Linechart").ActualName = "Quality Linechart";
+      lci.GetVariable("NumberOfLines").GetValue<IntData>().Data = 3;
+
+      Counter c = new Counter();
+      c.GetVariableInfo("Value").ActualName = "Generations";
+
+      LessThanComparator ltc = new LessThanComparator();
+      ltc.GetVariableInfo("LeftSide").ActualName = "Generations";
+      ltc.GetVariableInfo("RightSide").ActualName = "MaximumGenerations";
+      ltc.GetVariableInfo("Result").ActualName = "GenerationsCondition";
+
+      IntData maxGenerations = GetVariableValue<IntData>("MaximumGenerations", scope, true);
+      IntData nrOfGenerations = GetVariableValue<IntData>("Generations", scope, true);
+
+      InitializeExecuteCreateChildren(scope);
+      IntData evaluatedSolutions = GetVariableValue<IntData>("EvaluatedSolutions", scope, true);
+      Stopwatch watch = new Stopwatch();
+      long[] times = new long[10];
+      timesExecuteCreateChildren = new long[10];
+      for (int i = 0; i < maxGenerations.Data; i++) {
+        watch.Start();
+        selector.Execute(scope);
+        watch.Stop();
+        times[0] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        ExecuteCreateChildren(scope.SubScopes[1], evaluatedSolutions);
+        watch.Stop();
+        times[1] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        createReplacement.Execute(scope);
+        watch.Stop();
+        times[2] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        ql.Execute(scope);
+        watch.Stop();
+        times[3] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        bawqc.Execute(scope);
+        watch.Stop();
+        times[4] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        dc.Execute(scope);
+        watch.Stop();
+        times[5] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        lci.Execute(scope);
+        watch.Stop();
+        times[6] += watch.ElapsedTicks;
+        watch.Reset();
+        watch.Start();
+        nrOfGenerations.Data++;
+      }
+
+      swApply.Stop();
+      Console.WriteLine("SGAMain.Apply(): {0}", swApply.Elapsed);
+      return null;
+    } // Apply
+
+    /// <summary>
+    /// Initializes some variables needed before the execution of create children
+    /// </summary>
+    /// <param name="scope"></param>
+    private void InitializeExecuteCreateChildren(IScope scope) {
+      crossover = (OperatorBase)GetVariableValue("Crossover", scope, true);
+      mutator = (OperatorBase)GetVariableValue("Mutator", scope, true);
+      evaluator = GetVariableValue<OperatorBase>("Evaluator", scope, true);
+
+      random = GetVariableValue<IRandom>("Random", scope, true);
+      probability = GetVariableValue<DoubleData>("MutationRate", scope, true);
+
+      ci = new ChildrenInitializer();
+    }
+
+    private void ExecuteCreateChildren(IScope scope, IntData evaluatedSolutions) {
+      //Stopwatch watch = new Stopwatch();
+      //long[] times = new long[10];
+      // ChildrenInitializer
+      //watch.Start();
+      ci.Apply(scope);
+      //watch.Stop();
+      //timesExecuteCreateChildren[0] += watch.ElapsedTicks;
+      //watch.Reset();
+      // UniformSequentialSubScopesProcessor
+      foreach (IScope s in scope.SubScopes) {
+        //watch.Start();
+        if (crossover.Execute(s) != null)
+          throw new InvalidOperationException("ERROR: no support for combined operators!");
+        //watch.Stop();
+        //timesExecuteCreateChildren[1] += watch.ElapsedTicks;
+        //watch.Reset();
+
+
+        // Stochastic Branch
+        if (random.NextDouble() < probability.Data) {
+          //watch.Start();
+          if (mutator.Execute(s) != null)
+            throw new InvalidOperationException("ERROR: no support for combined operators!");
+          //watch.Stop();
+          //timesExecuteCreateChildren[2] += watch.ElapsedTicks;
+          //watch.Reset();
+
+        }
+
+        //watch.Start();
+        if (evaluator.Execute(s) != null)
+          throw new InvalidOperationException("ERROR: no support for combined operators!");
+        //watch.Stop();
+        //timesExecuteCreateChildren[3] += watch.ElapsedTicks;
+        //watch.Reset();
+
+        // subscopes remover
+        //watch.Start();
+        while (s.SubScopes.Count > 0)
+          s.RemoveSubScope(s.SubScopes[0]);
+        //watch.Stop();
+        //timesExecuteCreateChildren[4] += watch.ElapsedTicks;
+        //watch.Reset();
+
+        evaluatedSolutions.Data++;
+      } // foreach
+
+      // sort scopes
+      bool descending = GetVariableValue<BoolData>("Maximization", scope, true).Data;
+
+      double[] keys = new double[scope.SubScopes.Count];
+      int[] sequence = new int[keys.Length];
+
+      for (int i = 0; i < keys.Length; i++) {
+        keys[i] = scope.SubScopes[i].GetVariableValue<DoubleData>("Quality", false).Data;
+        sequence[i] = i;
+      }
+
+      Array.Sort<double, int>(keys, sequence);
+
+      if (descending) {
+        int temp;
+        for (int i = 0; i < sequence.Length / 2; i++) {
+          temp = sequence[i];
+          sequence[i] = sequence[sequence.Length - 1 - i];
+          sequence[sequence.Length - 1 - i] = temp;
+        }
+      }
+      scope.ReorderSubScopes(sequence);
+      //watch.Stop();
+      //timesExecuteCreateChildren[5] += watch.ElapsedTicks;
+      //watch.Reset();
+
+      return;
+    } // ExecuteCreateChildrenHW
+
+  } // class AllFixedSGAMain
+} // namespace HeuristicLab.FixedOperators
Index: trunk/sources/HeuristicLab.FixedOperators/3.2/FixedSGAMain.cs
===================================================================
--- trunk/sources/HeuristicLab.FixedOperators/3.2/FixedSGAMain.cs	(revision 1646)
+++ trunk/sources/HeuristicLab.FixedOperators/3.2/FixedSGAMain.cs	(revision 1661)
@@ -32,11 +32,19 @@
 using HeuristicLab.Logging;
 using System.Diagnostics;
+using HeuristicLab.Selection;
 
 namespace HeuristicLab.FixedOperators {
   class FixedSGAMain : CombinedOperator {
     public override string Description {
-      get { return @"Implements the SGAMain with hardwired control structures. Operators are delegated."; }
-    }
-
+      get { return @"Implements the functionality of SGAMain with fixed control structures. Operators like selection, crossover, mutation and evaluation are delegated."; }
+    }
+
+    // Shared
+    Sorter sorter;
+
+    // CreateChildren
+    Counter counter;
+    IRandom random;
+    DoubleData probability;
     ChildrenInitializer ci;
     OperatorBase crossover;
@@ -44,8 +52,12 @@
     OperatorBase evaluator;
     SubScopesRemover sr;
-    Counter counter;
-    Sorter sorter;
-    IRandom random;
-    DoubleData probability;
+
+    // CreateReplacement
+    LeftSelector ls;
+    RightReducer rr;
+    RightSelector rs;
+    LeftReducer lr;
+    MergingReducer mr;
+
 
     long[] timesExecuteCreateChildren;
@@ -57,10 +69,29 @@
       AddVariableInfo(new VariableInfo("Generations", "Number of processed generations", typeof(IntData), VariableKind.In | VariableKind.Out));
       Name = "FixedSGAMain";
-      //InitCreateChildrenHWCS();
-      InitCreateChildrenHW();
-
-    }
-
-    private void InitCreateChildrenHW() {
+
+      sorter = new Sorter();
+      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
+      sorter.GetVariableInfo("Value").ActualName = "Quality";
+
+      InitVariablesForCreateChildren();
+      InitVariablesForCreateReplacement();
+    }
+
+    private void InitVariablesForCreateReplacement() {
+      ls = new LeftSelector();
+      rr = new RightReducer();
+      rs = new RightSelector();
+      lr = new LeftReducer();
+      mr = new MergingReducer();
+
+      ls.GetVariableInfo("Selected").ActualName = "Elites";
+      rs.GetVariableInfo("Selected").ActualName = "Elites";
+
+    }
+
+    protected void InitVariablesForCreateChildren() {
+      // variables for create children
+      ci = new ChildrenInitializer();
+
       // variables infos
       AddVariableInfo(new VariableInfo("Random", "Pseudo random number generator", typeof(IRandom), VariableKind.In));
@@ -69,19 +100,4 @@
       AddVariableInfo(new VariableInfo("Mutator", "Mutation strategy for SGA", typeof(OperatorBase), VariableKind.In));
       AddVariableInfo(new VariableInfo("Evaluator", "Evaluation strategy for SGA", typeof(OperatorBase), VariableKind.In));
-      AddVariableInfo(new VariableInfo("EvaluatedSolutions", "Number of evaluated solutions", typeof(IntData), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("Maximization", "Sort in descending order", typeof(BoolData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Quality", "Sorting value", typeof(DoubleData), VariableKind.In));
-    }
-
-    private void InitCreateChildrenHWCS() {
-      // variables for create children
-      ci = new ChildrenInitializer();
-
-      // variables infos
-      AddVariableInfo(new VariableInfo("Random", "Pseudo random number generator", typeof(IRandom), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MutationRate", "Probability to choose first branch", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Crossover", "Crossover strategy for SGA", typeof(OperatorBase), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Mutator", "Mutation strategy for SGA", typeof(OperatorBase), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Evaluator", "Evaluation strategy for SGA", typeof(OperatorBase), VariableKind.In));
 
       sr = new SubScopesRemover();
@@ -90,8 +106,4 @@
       counter = new Counter();
       counter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
-
-      sorter = new Sorter();
-      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
-      sorter.GetVariableInfo("Value").ActualName = "Quality";
     }
 
@@ -107,6 +119,4 @@
 
       OperatorBase selector = (OperatorBase)GetVariableValue("Selector", scope, true);
-      OperatorBase createChildren = new CreateChildren();
-      OperatorBase createReplacement = new CreateReplacement();
       QualityLogger ql = new QualityLogger();
 
@@ -122,7 +132,4 @@
       lci.GetVariable("NumberOfLines").GetValue<IntData>().Data = 3;
 
-      Counter c = new Counter();
-      c.GetVariableInfo("Value").ActualName = "Generations";
-
       LessThanComparator ltc = new LessThanComparator();
       ltc.GetVariableInfo("LeftSide").ActualName = "Generations";
@@ -134,10 +141,9 @@
 
       InitializeExecuteCreateChildren(scope);
-      IntData evaluatedSolutions = GetVariableValue<IntData>("EvaluatedSolutions", scope, true);
       Stopwatch watch = new Stopwatch();
       long[] times = new long[10];
       timesExecuteCreateChildren = new long[10];
-      for (int i = 0; i < maxGenerations.Data; i++) {
-          watch.Start();
+      for (int i = nrOfGenerations.Data; i < maxGenerations.Data && !Canceled; i++) {
+        watch.Start();
         selector.Execute(scope);
         watch.Stop();
@@ -145,13 +151,10 @@
         watch.Reset();
         watch.Start();
-        // if uncomment, adapt constructor
-        //createChildren.Execute(scope.SubScopes[1]);
-        //ExecuteCreateChildrenHWCS(scope.SubScopes[1]);
-        ExecuteCreateChildrenHW(scope.SubScopes[1], evaluatedSolutions);
+        ExecuteCreateChildrenWithFixedControlStructures(scope.SubScopes[1]);
         watch.Stop();
         times[1] += watch.ElapsedTicks;
         watch.Reset();
         watch.Start();
-        createReplacement.Execute(scope);
+        ExecuteCreateReplacementWithFixedConstrolStructures(scope);
         watch.Stop();
         times[2] += watch.ElapsedTicks;
@@ -183,6 +186,12 @@
       swApply.Stop();
       Console.WriteLine("SGAMain.Apply(): {0}", swApply.Elapsed);
+
+      if (Canceled)
+        return new AtomicOperation(this, scope);
+
       return null;
     } // Apply
+
+  
 
     /// <summary>
@@ -201,5 +210,5 @@
     }
 
-    private void ExecuteCreateChildrenHWCS(IScope scope) {
+    protected void ExecuteCreateChildrenWithFixedControlStructures(IScope scope) {
       // ChildrenInitializer
       ci.Apply(scope);
@@ -218,81 +227,15 @@
     } // ExecuteCreateChildrenHWCS
 
-    private void ExecuteCreateChildrenHW(IScope scope, IntData evaluatedSolutions){
-      //Stopwatch watch = new Stopwatch();
-      //long[] times = new long[10];
-      // ChildrenInitializer
-      //watch.Start();
-      ci.Apply(scope);
-      //watch.Stop();
-      //timesExecuteCreateChildren[0] += watch.ElapsedTicks;
-      //watch.Reset();
-      // UniformSequentialSubScopesProcessor
-      foreach (IScope s in scope.SubScopes) {
-        //watch.Start();
-        if (crossover.Execute(s) != null)
-          throw new InvalidOperationException("ERROR: no support for combined operators!");
-        //watch.Stop();
-        //timesExecuteCreateChildren[1] += watch.ElapsedTicks;
-        //watch.Reset();
-
-
-        // Stochastic Branch
-        if (random.NextDouble() < probability.Data) {
-          //watch.Start();
-          if (mutator.Execute(s) != null)
-            throw new InvalidOperationException("ERROR: no support for combined operators!");
-          //watch.Stop();
-          //timesExecuteCreateChildren[2] += watch.ElapsedTicks;
-          //watch.Reset();
-
-        }
-
-        //watch.Start();
-        if (evaluator.Execute(s) != null)
-          throw new InvalidOperationException("ERROR: no support for combined operators!");
-        //watch.Stop();
-        //timesExecuteCreateChildren[3] += watch.ElapsedTicks;
-        //watch.Reset();
-
-        // subscopes remover
-        //watch.Start();
-        while (s.SubScopes.Count > 0)
-          s.RemoveSubScope(s.SubScopes[0]);
-        //watch.Stop();
-        //timesExecuteCreateChildren[4] += watch.ElapsedTicks;
-        //watch.Reset();
-
-        evaluatedSolutions.Data++;
-      } // foreach
-
-      // sort scopes
-      bool descending = GetVariableValue<BoolData>("Maximization", scope, true).Data;
-
-      double[] keys = new double[scope.SubScopes.Count];
-      int[] sequence = new int[keys.Length];
-
-      for (int i = 0; i < keys.Length; i++) {
-        keys[i] = scope.SubScopes[i].GetVariableValue<DoubleData>("Quality", false).Data;
-        sequence[i] = i;
-      }
-
-      Array.Sort<double, int>(keys, sequence);
-
-      if (descending) {
-        int temp;
-        for (int i = 0; i < sequence.Length / 2; i++) {
-          temp = sequence[i];
-          sequence[i] = sequence[sequence.Length - 1 - i];
-          sequence[sequence.Length - 1 - i] = temp;
-        }
-      }
-      scope.ReorderSubScopes(sequence);
-      //watch.Stop();
-      //timesExecuteCreateChildren[5] += watch.ElapsedTicks;
-      //watch.Reset();
-
-      return;
-    } // ExecuteCreateChildrenHW
-
+    private void ExecuteCreateReplacementWithFixedConstrolStructures(IScope scope) {
+      // SequentialSubScopesProcessor
+      ls.Execute(scope.SubScopes[0]);
+      rr.Execute(scope.SubScopes[0]);
+
+      rs.Execute(scope.SubScopes[1]);
+      lr.Execute(scope.SubScopes[1]);
+
+      mr.Execute(scope);
+      sorter.Execute(scope);
+    } // ExecuteCreateReplacementWithFixedConstrolStructures
   } // class FixedSGAMain
 } // namespace HeuristicLab.FixedOperators
Index: trunk/sources/HeuristicLab.FixedOperators/3.2/HeuristicLab.FixedOperators-3.2.csproj
===================================================================
--- trunk/sources/HeuristicLab.FixedOperators/3.2/HeuristicLab.FixedOperators-3.2.csproj	(revision 1646)
+++ trunk/sources/HeuristicLab.FixedOperators/3.2/HeuristicLab.FixedOperators-3.2.csproj	(revision 1661)
@@ -68,4 +68,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="FixedAllSGAMain.cs" />
     <Compile Include="CreateReplacement.cs" />
     <Compile Include="CreateChildrenHardWired.cs" />
