Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/GQAPPopulationDiversityAnalyzer.cs @ 13770

Last change on this file since 13770 was 7438, checked in by abeham, 13 years ago

#1614

  • Add BestKnownSolutions parameter
  • Assignment view
    • Clicking on an equipment highlights all related equipments
    • Clicking on a location highlights other locations that contain equipment to which relations exist
    • Showing installation costs when nothing is selected
  • Analyzers were present double times
  • Fixed GRASP to check EnabledByDefault
File size: 3.7 KB
Line 
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
22using HeuristicLab.Analysis;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.IntegerVectorEncoding;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;
30
31namespace 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 {
40      get { return base.MaximizationParameter; }
41    }
42    public new IScopeTreeLookupParameter<DoubleValue> QualityParameter {
43      get { return base.QualityParameter; }
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}
Note: See TracBrowser for help on using the repository browser.