using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Analysis; using HEAL.Attic; namespace HeuristicLab.Problems.MetaOptimization { /// /// An operator for analyzing the diversity of solutions of Traveling Salesman Problems given in path representation. /// [Item("PMOPopulationDiversityAnalyzer", "An operator for analyzing the diversity of solutions of Parameter Meta-Optimization.")] [StorableType("6B841AFF-BEE0-484D-AC84-26368854852A")] public sealed class PMOPopulationDiversityAnalyzer : PopulationDiversityAnalyzer { [StorableConstructor] private PMOPopulationDiversityAnalyzer(StorableConstructorFlag _) : base(_) { } private PMOPopulationDiversityAnalyzer(PMOPopulationDiversityAnalyzer original, Cloner cloner) : base(original, cloner) { } public PMOPopulationDiversityAnalyzer() : base() { } public override IDeepCloneable Clone(Cloner cloner) { return new PMOPopulationDiversityAnalyzer(this, cloner); } protected override double[,] CalculateSimilarities(ParameterConfigurationTree[] solutions) { int count = solutions.Length; double[,] similarities = new double[count, count]; for (int i = 0; i < count; i++) { similarities[i, i] = 1; for (int j = i + 1; j < count; j++) { similarities[i, j] = CalculateSimilarity(solutions[i], solutions[j]); similarities[j, i] = similarities[i, j]; } } return similarities; } private double CalculateSimilarity(ParameterConfigurationTree pca, ParameterConfigurationTree pcb) { return pca.CalculateSimilarity(pcb); } } }