[16996] | 1 | using HeuristicLab.Common;
|
---|
[5522] | 2 | using HeuristicLab.Core;
|
---|
| 3 | using HeuristicLab.Analysis;
|
---|
[16574] | 4 | using HEAL.Attic;
|
---|
[5522] | 5 |
|
---|
| 6 | namespace 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.")]
|
---|
[16574] | 11 | [StorableType("6B841AFF-BEE0-484D-AC84-26368854852A")]
|
---|
[5522] | 12 | public sealed class PMOPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<ParameterConfigurationTree> {
|
---|
| 13 | [StorableConstructor]
|
---|
[16574] | 14 | private PMOPopulationDiversityAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
[5522] | 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 | }
|
---|