Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/PMOPopulationDiversityAnalyzer.cs @ 17074

Last change on this file since 17074 was 16996, checked in by gkronber, 5 years ago

#2520 Update plugin dependencies and references for HL.MetaOptimization for new persistence

File size: 1.7 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Analysis;
4using HEAL.Attic;
5
6namespace HeuristicLab.Problems.MetaOptimization {
7  /// <summary>
8  /// An operator for analyzing the diversity of solutions of Traveling Salesman Problems given in path representation.
9  /// </summary>
10  [Item("PMOPopulationDiversityAnalyzer", "An operator for analyzing the diversity of solutions of Parameter Meta-Optimization.")]
11  [StorableType("6B841AFF-BEE0-484D-AC84-26368854852A")]
12  public sealed class PMOPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<ParameterConfigurationTree> {
13    [StorableConstructor]
14    private PMOPopulationDiversityAnalyzer(StorableConstructorFlag _) : base(_) { }
15    private PMOPopulationDiversityAnalyzer(PMOPopulationDiversityAnalyzer original, Cloner cloner) : base(original, cloner) { }
16    public PMOPopulationDiversityAnalyzer() : base() { }
17
18    public override IDeepCloneable Clone(Cloner cloner) {
19      return new PMOPopulationDiversityAnalyzer(this, cloner);
20    }
21
22    protected override double[,] CalculateSimilarities(ParameterConfigurationTree[] solutions) {
23      int count = solutions.Length;
24      double[,] similarities = new double[count, count];
25
26      for (int i = 0; i < count; i++) {
27        similarities[i, i] = 1;
28        for (int j = i + 1; j < count; j++) {
29          similarities[i, j] = CalculateSimilarity(solutions[i], solutions[j]);
30          similarities[j, i] = similarities[i, j];
31        }
32      }
33      return similarities;
34    }
35
36    private double CalculateSimilarity(ParameterConfigurationTree pca, ParameterConfigurationTree pcb) {
37      return pca.CalculateSimilarity(pcb);
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.