Index: trunk/sources/HeuristicLab.SGA/3.3/SGA.cs
===================================================================
--- trunk/sources/HeuristicLab.SGA/3.3/SGA.cs	(revision 2851)
+++ trunk/sources/HeuristicLab.SGA/3.3/SGA.cs	(revision 2852)
@@ -20,13 +20,12 @@
 #endregion
 
-using System;
 using HeuristicLab.Core;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.Collections;
-using HeuristicLab.Parameters;
 using HeuristicLab.Data;
+using HeuristicLab.Evolutionary;
 using HeuristicLab.Operators;
 using HeuristicLab.Optimization;
-using HeuristicLab.Evolutionary;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
 
 namespace HeuristicLab.SGA {
@@ -36,6 +35,18 @@
   [Item("SGA", "A standard genetic algorithm.")]
   [Creatable("Algorithms")]
-  [EmptyStorableClass]
   public sealed class SGA : EngineAlgorithm {
+    [Storable]
+    private PopulationCreator populationCreator;
+    [Storable]
+    private SGAOperator sgaOperator;
+
+    public override Type ProblemType {
+      get { return typeof(ISingleObjectiveProblem); }
+    }
+    public new ISingleObjectiveProblem Problem {
+      get { return (ISingleObjectiveProblem)base.Problem; }
+      set { base.Problem = value; }
+    }
+
     public new IScope GlobalScope {
       get { return base.GlobalScope; }
@@ -44,6 +55,4 @@
     public SGA()
       : base() {
-//      Parameters.Add(new ValueLookupParameter<BoolData>("Maximization", "True if the problem is a maximization problem, otherwise false."));
-//      Parameters.Add(new SubScopesLookupParameter<DoubleData>("Quality", "The value which represents the quality of a solution."));
       Parameters.Add(new ValueParameter<IntData>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntData(0)));
       Parameters.Add(new ValueParameter<BoolData>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolData(true)));
@@ -52,11 +61,10 @@
       Parameters.Add(new ValueParameter<DoubleData>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new DoubleData(0.05)));
       Parameters.Add(new OperatorParameter("MutationOperator", "The operator used to mutate solutions."));
-//      Parameters.Add(new ValueLookupParameter<IOperator>("SolutionEvaluator", "The operator used to evaluate solutions."));
       Parameters.Add(new ValueParameter<IntData>("Elites", "The numer of elite solutions which are kept in each generation.", new IntData(1)));
       Parameters.Add(new ValueParameter<IntData>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntData(1000)));
 
       RandomCreator randomCreator = new RandomCreator();
-      PopulationCreator populationCreator = new PopulationCreator();
-      SGAOperator sgaOperator = new SGAOperator();
+      populationCreator = new PopulationCreator();
+      sgaOperator = new SGAOperator();
 
       randomCreator.RandomParameter.ActualName = "Random";
@@ -69,20 +77,55 @@
       populationCreator.PopulationSizeParameter.ActualName = "PopulationSize";
       populationCreator.PopulationSizeParameter.Value = null;
-      populationCreator.SolutionCreatorParameter.ActualName = "SolutionCreator";
-      populationCreator.SolutionEvaluatorParameter.ActualName = "SolutionEvaluator";
       populationCreator.Successor = sgaOperator;
 
       sgaOperator.CrossoverOperatorParameter.ActualName = "CrossoverOperator";
       sgaOperator.ElitesParameter.ActualName = "Elites";
-      sgaOperator.MaximizationParameter.ActualName = "Maximization";
       sgaOperator.MaximumGenerationsParameter.ActualName = "MaximumGenerations";
       sgaOperator.MutationOperatorParameter.ActualName = "MutationOperator";
       sgaOperator.MutationProbabilityParameter.ActualName = "MutationProbability";
-      sgaOperator.QualityParameter.ActualName = "Quality";
       sgaOperator.RandomParameter.ActualName = "Random";
-      sgaOperator.SolutionEvaluatorParameter.ActualName = "SolutionEvaluator";
 
       OperatorGraph.InitialOperator = randomCreator;
     }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      SGA clone = (SGA)base.Clone(cloner);
+      clone.populationCreator = (PopulationCreator)cloner.Clone(populationCreator);
+      clone.sgaOperator = (SGAOperator)cloner.Clone(sgaOperator);
+      return clone;
+    }
+
+    protected override void DeregisterProblemEvents() {
+      Problem.MaximizationChanged -= new EventHandler(Problem_MaximizationChanged);
+      base.DeregisterProblemEvents();
+    }
+    protected override void RegisterProblemEvents() {
+      base.RegisterProblemEvents();
+      Problem.MaximizationChanged += new EventHandler(Problem_MaximizationChanged);
+    }
+
+    protected override void OnProblemChanged() {
+      Problem.SolutionCreator.RandomParameter.ActualName = "Random";
+      populationCreator.SolutionCreatorParameter.Value = Problem.SolutionCreator;
+      populationCreator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
+      sgaOperator.MaximizationParameter.Value = Problem.Maximization;
+      sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
+      sgaOperator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
+      base.OnProblemChanged();
+    }
+    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
+      Problem.SolutionCreator.RandomParameter.ActualName = "Random";
+      populationCreator.SolutionCreatorParameter.Value = Problem.SolutionCreator;
+      base.Problem_SolutionCreatorChanged(sender, e);
+    }
+    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
+      populationCreator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
+      sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
+      sgaOperator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
+      base.Problem_EvaluatorChanged(sender, e);
+    }
+    private void Problem_MaximizationChanged(object sender, EventArgs e) {
+      sgaOperator.MaximizationParameter.Value = Problem.Maximization;
+    }
   }
 }
