[7437] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using HeuristicLab.Analysis;
|
---|
| 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
| 27 | using HeuristicLab.Parameters;
|
---|
| 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 29 | using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;
|
---|
| 30 |
|
---|
| 31 | namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Analyzers {
|
---|
| 32 | [Item("GQAPPopulationDiversityAnalyzer", "Analyzes the population diversity.")]
|
---|
| 33 | [StorableClass]
|
---|
| 34 | public class GQAPPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<IntegerVector>, IAssignmentsAwareGQAPOperator, IQualitiesAwareGQAPOperator {
|
---|
| 35 |
|
---|
| 36 | public IScopeTreeLookupParameter<IntegerVector> AssignmentParameter {
|
---|
| 37 | get { return SolutionParameter; }
|
---|
| 38 | }
|
---|
| 39 | public new ILookupParameter<BoolValue> MaximizationParameter {
|
---|
[7438] | 40 | get { return base.MaximizationParameter; }
|
---|
[7437] | 41 | }
|
---|
| 42 | public new IScopeTreeLookupParameter<DoubleValue> QualityParameter {
|
---|
[7438] | 43 | get { return base.QualityParameter; }
|
---|
[7437] | 44 | }
|
---|
| 45 | public IScopeTreeLookupParameter<DoubleValue> FlowDistanceQualityParameter {
|
---|
| 46 | get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["FlowDistanceQuality"]; }
|
---|
| 47 | }
|
---|
| 48 | public IScopeTreeLookupParameter<DoubleValue> InstallationQualityParameter {
|
---|
| 49 | get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["InstallationQuality"]; }
|
---|
| 50 | }
|
---|
| 51 | public IScopeTreeLookupParameter<DoubleValue> OverbookedCapacityParameter {
|
---|
| 52 | get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["OverbookedCapacity"]; }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | [StorableConstructor]
|
---|
| 56 | protected GQAPPopulationDiversityAnalyzer(bool deserializing) : base(deserializing) { }
|
---|
| 57 | protected GQAPPopulationDiversityAnalyzer(GQAPPopulationDiversityAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
| 58 | public GQAPPopulationDiversityAnalyzer()
|
---|
| 59 | : base() {
|
---|
| 60 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("FlowDistanceQuality", GQAPEvaluator.FlowDistanceQualityDescription));
|
---|
| 61 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("InstallationQuality", GQAPEvaluator.InstallationQualityDescription));
|
---|
| 62 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("OverbookedCapacity", GQAPEvaluator.OverbookedCapacityDescription));
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 66 | return new GQAPPopulationDiversityAnalyzer(this, cloner);
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | protected override double[,] CalculateSimilarities(IntegerVector[] solutions) {
|
---|
| 70 | double[,] result = new double[solutions.Length, solutions.Length];
|
---|
| 71 | for (int i = 0; i < solutions.Length - 1; i++)
|
---|
| 72 | for (int j = i + 1; j < solutions.Length; j++) {
|
---|
| 73 | result[i, j] = IntegerVectorEqualityComparer.GetSimilarity(solutions[i], solutions[j]);
|
---|
| 74 | result[j, i] = result[i, j];
|
---|
| 75 | }
|
---|
| 76 | return result;
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 | }
|
---|