Index: branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm-3.3.csproj
===================================================================
--- branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm-3.3.csproj	(revision 11513)
+++ branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm-3.3.csproj	(revision 11516)
@@ -172,4 +172,5 @@
     <Compile Include="VOffspringSelectionGeneticAlgorithmMainLoop.cs" />
     <Compile Include="VOffspringSelectionGeneticAlgorithmMainOperator.cs" />
+    <Compile Include="WeightedParentsDiversityComparator.cs" />
     <Compile Include="WeightedParentsQualityComparator.cs" />
   </ItemGroup>
Index: branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/ISubScopesQualityComparatorOperator.cs
===================================================================
--- branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/ISubScopesQualityComparatorOperator.cs	(revision 11516)
+++ branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/ISubScopesQualityComparatorOperator.cs	(revision 11516)
@@ -0,0 +1,17 @@
+﻿using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+
+namespace HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm {
+  public interface ISubScopesQualityComparatorOperator : ISubScopesQualityComparator, IOperator {
+    //TODO: the ISubScopesQualityComparator interface should be fixed:
+    // * add IOperator as base interface
+    // * don't call it QualityComparator because it could also compare solutions by diversity
+
+
+    ValueLookupParameter<DoubleValue> ComparisonFactorParameter { get; }
+  }
+
+}
+
Index: branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithm.cs
===================================================================
--- branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithm.cs	(revision 11513)
+++ branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithm.cs	(revision 11516)
@@ -121,4 +121,7 @@
       get { return (ConstrainedValueParameter<ISubScopesQualityComparatorOperator>)Parameters["SubScopesQualityComparator"]; }
     }
+    public IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
+      get { return (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
+    }
     #endregion
 
@@ -218,4 +221,8 @@
     private SolutionsCreator SolutionsCreator {
       get { return (SolutionsCreator)RandomCreator.Successor; }
+    }
+    public ISingleObjectiveSolutionSimilarityCalculator SimilarityCalculator {
+      get { return SimilarityCalculatorParameter.Value; }
+      set { SimilarityCalculatorParameter.Value = value; }
     }
     private VOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
@@ -281,4 +288,5 @@
       Parameters.Add(new ConstrainedValueParameter<IOffspringSelector>("OffspringSelector", "The operator used as selection criterea for deciding which individuals are successful and which should be disgarded."));
       Parameters.Add(new ConstrainedValueParameter<ISubScopesQualityComparatorOperator>("SubScopesQualityComparator", "The operator used to compare solution candidates with."));
+      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
 
       RandomCreator randomCreator = new RandomCreator();
@@ -378,4 +386,5 @@
       ParameterizeSubScopesQualityComparators();
       ParameterizeOffspringSelectors();
+      UpdateSimilarityCalculators();
       Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
       base.OnProblemChanged();
@@ -422,4 +431,5 @@
       ParameterizeSelectors();
       ParameterizeAnalyzers();
+      ParameterizeSimilarityCalculators();
     }
     #endregion
@@ -434,4 +444,9 @@
         Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
       }
+      SimilarityCalculatorParameter.ValueChanged += SimilarityCalculatorParameter_ValueChanged;
+    }
+    void SimilarityCalculatorParameter_ValueChanged(object sender, EventArgs e) {
+      foreach (ISimilarityBasedOperator op in SubScopesQualityComparatorParameter.ValidValues.OfType<ISimilarityBasedOperator>())
+        op.SimilarityCalculator = SimilarityCalculator;
     }
     private void ParameterizeSolutionsCreator() {
@@ -560,4 +575,28 @@
       Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault);
     }
+    private void UpdateSimilarityCalculators() {
+      ISingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;
+      SimilarityCalculatorParameter.ValidValues.Clear();
+      ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault();
+
+      SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName });
+      SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator());
+
+      foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>())
+        SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator);
+
+      if (oldSimilarityCalculator != null) {
+        ISingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());
+        if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator;
+        else oldSimilarityCalculator = null;
+      }
+      if (oldSimilarityCalculator == null && defaultSimilarityCalculator != null)
+        SimilarityCalculatorParameter.Value = defaultSimilarityCalculator;
+    }
+    private void ParameterizeSimilarityCalculators() {
+      foreach (ISingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) {
+        calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName;
+      }
+    }
     private VOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
       IOperator mainLoop = start;
Index: branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/WeightedParentsDiversityComparator.cs
===================================================================
--- branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/WeightedParentsDiversityComparator.cs	(revision 11516)
+++ branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/WeightedParentsDiversityComparator.cs	(revision 11516)
@@ -0,0 +1,155 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.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;
+
+namespace HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm {
+  [Item("WeightedParentsDiversityComparator", "Compares the similarity against that of its parents (assumes the parents are subscopes to the child scope). This operator works with any number of subscopes > 0.")]
+  [StorableClass]
+  public class WeightedParentsDiversityComparator : SingleSuccessorOperator, ISubScopesQualityComparatorOperator, ISimilarityBasedOperator {
+    [Storable]
+    public ISolutionSimilarityCalculator SimilarityCalculator { get; set; }
+    public IValueLookupParameter<BoolValue> MaximizationParameter {
+      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
+    }
+    public ILookupParameter<DoubleValue> LeftSideParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["LeftSide"]; }
+    }
+    public ILookupParameter<ItemArray<DoubleValue>> RightSideParameter {
+      get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["RightSide"]; }
+    }
+    public ILookupParameter<BoolValue> ResultParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters["Result"]; }
+    }
+    public ValueLookupParameter<DoubleValue> ComparisonFactorParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
+    }
+    public ValueLookupParameter<DoubleValue> DiversityComparisonFactorParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["DiversityComparisonFactor"]; }
+    }
+    private ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["DiversityComparisonFactorLowerBound"]; }
+    }
+    private ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
+      get { return (ValueLookupParameter<DoubleValue>)Parameters["DiversityComparisonFactorUpperBound"]; }
+    }
+    public IConstrainedValueParameter<IDiscreteDoubleValueModifier> ComparisonFactorModifierParameter {
+      get { return (IConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; }
+    }
+
+    [StorableConstructor]
+    protected WeightedParentsDiversityComparator(bool deserializing) : base(deserializing) { }
+    protected WeightedParentsDiversityComparator(WeightedParentsDiversityComparator original, Cloner cloner) : base(original, cloner) { }
+    public WeightedParentsDiversityComparator()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, false otherwise"));
+      Parameters.Add(new LookupParameter<DoubleValue>("LeftSide", "The quality of the child."));
+      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("RightSide", "The qualities of the parents."));
+      Parameters.Add(new LookupParameter<BoolValue>("Result", "The result of the comparison: True means Quality is better, False means it is worse than parents."));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactor", "Determines if the quality should be compared to the better parent (1.0), to the worse (0.0) or to any linearly interpolated value between them."));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("DiversityComparisonFactor", "Determines if the quality should be compared to the better parent (1.0), to the worse (0.0) or to any linearly interpolated value between them.", new DoubleValue(0.0)));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("DiversityComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0.5)));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("DiversityComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1.0)));
+      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
+
+      foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
+        ComparisonFactorModifierParameter.ValidValues.Add(modifier);
+      IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier"));
+      if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier;
+      ParameterizeComparisonFactorModifiers();
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new WeightedParentsDiversityComparator(this, cloner);
+    }
+
+    private void ParameterizeComparisonFactorModifiers() {
+      //TODO: does not work if Generations parameter names are changed
+      foreach (IDiscreteDoubleValueModifier modifier in ComparisonFactorModifierParameter.ValidValues) {
+        modifier.IndexParameter.ActualName = "Generations";
+        modifier.EndIndexParameter.ActualName = "MaximumGenerations";
+        modifier.EndValueParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
+        modifier.StartIndexParameter.Value = new IntValue(0);
+        modifier.StartValueParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
+        modifier.ValueParameter.ActualName = "DiversityComparisonFactor";
+      }
+    }
+
+    public override IOperation Apply() {
+      ItemArray<DoubleValue> rightQualities = RightSideParameter.ActualValue;
+      if (rightQualities.Length < 1) throw new InvalidOperationException(Name + ": No subscopes found.");
+      double compFact = ComparisonFactorParameter.ActualValue.Value;
+      double diversityComFact = DiversityComparisonFactorParameter.ActualValue.Value;
+      bool maximization = MaximizationParameter.ActualValue.Value;
+      double leftQuality = LeftSideParameter.ActualValue.Value;
+      bool resultDiversity;
+
+      double threshold = 0;
+
+      #region Calculate threshold
+      if (rightQualities.Length == 2) {
+        var sim1 = SimilarityCalculator.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes[0]);
+        var sim2 = SimilarityCalculator.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes[1]);
+        var simAvg = (sim1 + sim2) / 2.0;
+
+        //TODO: try out different things
+        //resultDiversity = simAvg < diversityComFact;
+        resultDiversity = sim1 < diversityComFact || sim2 < diversityComFact;
+
+        double minQuality = Math.Min(rightQualities[0].Value, rightQualities[1].Value);
+        double maxQuality = Math.Max(rightQualities[0].Value, rightQualities[1].Value);
+        if (maximization)
+          threshold = minQuality + (maxQuality - minQuality) * compFact;
+        else
+          threshold = maxQuality - (maxQuality - minQuality) * compFact;
+      } else {
+        throw new NotImplementedException("Only 2 parents are supported.");
+      }
+      #endregion
+
+      bool result = maximization && leftQuality > threshold || !maximization && leftQuality < threshold;
+      result = result && resultDiversity;
+      BoolValue resultValue = ResultParameter.ActualValue;
+      if (resultValue == null) {
+        ResultParameter.ActualValue = new BoolValue(result);
+      } else {
+        resultValue.Value = result;
+      }
+
+      //like the placeholder, though we create child operations
+      OperationCollection next = new OperationCollection(base.Apply());
+      IOperator op = ComparisonFactorModifierParameter.Value;
+      if (op != null)
+        next.Insert(0, ExecutionContext.CreateChildOperation(op));
+      return next;
+    }
+  }
+}
