Index: trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs	(revision 3378)
+++ trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs	(revision 3379)
@@ -38,5 +38,5 @@
   /// An offspring selection genetic algorithm.
   /// </summary>
-  [Item("Offspring Selection Genetic Algorithm", "An offspring selection genetic algorithm (Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms. Adaptive and Natural Computing Algorithms, pp. 218-221, Springer).")]
+  [Item("Offspring Selection Genetic Algorithm", "An offspring selection genetic algorithm (Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications. CRC Press).")]
   [Creatable("Algorithms")]
   [StorableClass]
@@ -80,4 +80,22 @@
       get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
     }
+    private ValueLookupParameter<DoubleValue> SuccessRatioParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
+    }
+    private ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
+    }
+    private ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
+    }
+    private ConstrainedValueParameter<IDiscreteDoubleValueModifier> ComparisonFactorModifierParameter {
+      get { return (ConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; }
+    }
+    private ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
+    }
+    private ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
+      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
+    }
     #endregion
 
@@ -119,4 +137,28 @@
       set { MaximumGenerationsParameter.Value = value; }
     }
+    private DoubleValue SuccessRatio {
+      get { return SuccessRatioParameter.Value; }
+      set { SuccessRatioParameter.Value = value; }
+    }
+    private DoubleValue ComparisonFactorLowerBound {
+      get { return ComparisonFactorLowerBoundParameter.Value; }
+      set { ComparisonFactorLowerBoundParameter.Value = value; }
+    }
+    private DoubleValue ComparisonFactorUpperBound {
+      get { return ComparisonFactorUpperBoundParameter.Value; }
+      set { ComparisonFactorUpperBoundParameter.Value = value; }
+    }
+    private IDiscreteDoubleValueModifier ComparisonFactorModifier {
+      get { return ComparisonFactorModifierParameter.Value; }
+      set { ComparisonFactorModifierParameter.Value = value; }
+    }
+    private DoubleValue MaximumSelectionPressure {
+      get { return MaximumSelectionPressureParameter.Value; }
+      set { MaximumSelectionPressureParameter.Value = value; }
+    }
+    private BoolValue OffspringSelectionBeforeMutation {
+      get { return OffspringSelectionBeforeMutationParameter.Value; }
+      set { OffspringSelectionBeforeMutationParameter.Value = value; }
+    }
     private RandomCreator RandomCreator {
       get { return (RandomCreator)OperatorGraph.InitialOperator; }
@@ -132,6 +174,9 @@
       get { return selectors; }
     }
+    private List<IDiscreteDoubleValueModifier> comparisonFactorModifiers;
     #endregion
 
+    [StorableConstructor]
+    private OffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { }
     public OffspringSelectionGeneticAlgorithm()
       : base() {
@@ -145,4 +190,10 @@
       Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
       Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0)));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1)));
+      Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
+      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
 
       RandomCreator randomCreator = new RandomCreator();
@@ -161,4 +212,5 @@
       solutionsCreator.Successor = mainLoop;
 
+      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
       mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
       mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
@@ -172,6 +224,4 @@
       Initialize();
     }
-    [StorableConstructor]
-    private OffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { }
 
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -192,5 +242,5 @@
       foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
       ParameterizeSolutionsCreator();
-      ParameterizeGeneticAlgorithmMainLoop();
+      ParameterizMainLoop();
       ParameterizeSelectors();
       UpdateCrossovers();
@@ -209,5 +259,5 @@
       ParameterizeStochasticOperator(Problem.Evaluator);
       ParameterizeSolutionsCreator();
-      ParameterizeGeneticAlgorithmMainLoop();
+      ParameterizMainLoop();
       ParameterizeSelectors();
       Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
@@ -216,5 +266,5 @@
     protected override void Problem_VisualizerChanged(object sender, EventArgs e) {
       ParameterizeStochasticOperator(Problem.Visualizer);
-      ParameterizeGeneticAlgorithmMainLoop();
+      ParameterizMainLoop();
       if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged);
       base.Problem_VisualizerChanged(sender, e);
@@ -235,15 +285,17 @@
     private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
       PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
+      MainLoop.PopulationSizeParameter.Value = new IntValue(PopulationSize.Value - Elites.Value);
       ParameterizeSelectors();
     }
     private void PopulationSize_ValueChanged(object sender, EventArgs e) {
+      MainLoop.PopulationSizeParameter.Value = new IntValue(PopulationSize.Value - Elites.Value);
       ParameterizeSelectors();
     }
     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
-      ParameterizeGeneticAlgorithmMainLoop();
+      ParameterizMainLoop();
       ParameterizeSelectors();
     }
     private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) {
-      ParameterizeGeneticAlgorithmMainLoop();
+      ParameterizMainLoop();
     }
     #endregion
@@ -254,4 +306,6 @@
       InitializeSelectors();
       UpdateSelectors();
+      InitializeComparisonFactorModifiers();
+      UpdateComparisonFactorModifiers();
       PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
       PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
@@ -270,5 +324,5 @@
       SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     }
-    private void ParameterizeGeneticAlgorithmMainLoop() {
+    private void ParameterizMainLoop() {
       MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
       MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
@@ -288,4 +342,9 @@
       ParameterizeSelectors();
     }
+    private void InitializeComparisonFactorModifiers() {
+      comparisonFactorModifiers = new List<IDiscreteDoubleValueModifier>();
+      comparisonFactorModifiers.AddRange(ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name));
+      ParameterizeComparisonFactorModifiers();
+    }
     private void ParameterizeSelectors() {
       foreach (ISelector selector in Selectors) {
@@ -301,4 +360,14 @@
       }
     }
+    private void ParameterizeComparisonFactorModifiers() {
+      foreach (IDiscreteDoubleValueModifier modifier in comparisonFactorModifiers) {
+        modifier.IndexParameter.ActualName = "Generations"; // FIXME: hmmm, not so good, this variable is defined within the main loop
+        modifier.EndIndexParameter.ActualName = MaximumGenerationsParameter.Name;
+        modifier.EndValueParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
+        modifier.StartIndexParameter.Value = new IntValue(0);
+        modifier.StartValueParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
+        modifier.ValueParameter.ActualName = "ComparisonFactor"; // FIXME: hmmm, not so good, this variable is defined within the main loop
+      }
+    }
     private void UpdateSelectors() {
       ISelector oldSelector = SelectorParameter.Value;
@@ -314,4 +383,14 @@
         if (selector != null) SelectorParameter.Value = selector;
       }
+    }
+    private void UpdateComparisonFactorModifiers() {
+      IDiscreteDoubleValueModifier oldModifier = ComparisonFactorModifier;
+      ComparisonFactorModifierParameter.ValidValues.Clear();
+      foreach (IDiscreteDoubleValueModifier modifier in comparisonFactorModifiers)
+        ComparisonFactorModifierParameter.ValidValues.Add(modifier);
+      if (oldModifier != null) {
+        IDiscreteDoubleValueModifier modifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldModifier.GetType());
+        if (modifier != null) ComparisonFactorModifierParameter.Value = modifier;
+      } else if (ComparisonFactorModifierParameter.ValidValues.Count > 0) ComparisonFactorModifierParameter.Value = ComparisonFactorModifierParameter.ValidValues.First();
     }
     private void UpdateCrossovers() {
