Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/16 18:20:50 (8 years ago)
Author:
mkommend
Message:

#1087: Refactored and improved analyzers for multi-objective test functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/CrowdingAnalyzer.cs

    r13725 r14044  
    1919 */
    2020#endregion
     21
     22using System.Linq;
    2123using HeuristicLab.Common;
    2224using HeuristicLab.Core;
     
    2931  [Item("CrowdingAnalyzer", "The mean crowding distance for each point of the Front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    3032  public class CrowdingAnalyzer : MOTFAnalyzer {
    31     [StorableHook(HookType.AfterDeserialization)]
    32     private void AfterDeserialization() {
    33     }
     33
    3434    [StorableConstructor]
    3535    protected CrowdingAnalyzer(bool deserializing) : base(deserializing) { }
    36     public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner) : base(original, cloner) {
     36    public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner)
     37      : base(original, cloner) {
    3738    }
    3839    public override IDeepCloneable Clone(Cloner cloner) {
     
    4041    }
    4142
    42 
    43 
    4443    public CrowdingAnalyzer() { }
    4544
    46     public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     45    public override IOperation Apply() {
     46      var results = ResultsParameter.ActualValue;
     47      var qualities = QualitiesParameter.ActualValue;
     48      var testFunction = TestFunctionParameter.ActualValue;
    4749      int objectives = qualities[0].Length;
    48       if (!results.ContainsKey("Crowding")) results.Add(new Result("Crowding", typeof(DoubleValue)));
    49       results["Crowding"].Value = new DoubleValue(Crowding.Calculate(qualities, TestFunctionParameter.ActualValue.Bounds(objectives)));
     50
     51      if (!results.ContainsKey("Crowding")) results.Add(new Result("Crowding", new DoubleValue()));
     52      var resultValue = (DoubleValue)results["Crowding"].Value;
     53
     54      var crowdingDistance = Crowding.Calculate(qualities.Select(x => x.ToArray()), testFunction.Bounds(objectives));
     55      resultValue.Value = crowdingDistance;
     56
     57      return base.Apply();
    5058    }
     59
    5160  }
    5261}
Note: See TracChangeset for help on using the changeset viewer.