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/SpacingAnalyzer.cs

    r13725 r14044  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    3031  [Item("SpacingAnalyzer", "The spacing of the current front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    3132  public class SpacingAnalyzer : MOTFAnalyzer {
    32 
    33     [StorableHook(HookType.AfterDeserialization)]
    34     private void AfterDeserialization() {
    35     }
    36 
    3733    [StorableConstructor]
    3834    protected SpacingAnalyzer(bool deserializing) : base(deserializing) { }
    3935
    40     public SpacingAnalyzer() {
    41     }
    42 
    43     public SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) {
    44     }
    45 
     36    protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) { }
    4637    public override IDeepCloneable Clone(Cloner cloner) {
    4738      return new SpacingAnalyzer(this, cloner);
    4839    }
    4940
    50     public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    51       if (!results.ContainsKey("Spacing")) results.Add(new Result("Spacing", typeof(DoubleValue)));
    52       results["Spacing"].Value = new DoubleValue(Spacing.Calculate(qualities));
     41    public SpacingAnalyzer() { }
     42
     43    public override IOperation Apply() {
     44      var results = ResultsParameter.ActualValue;
     45      var qualities = QualitiesParameter.ActualValue;
     46
     47      if (!results.ContainsKey("Spacing")) results.Add(new Result("Spacing", new DoubleValue(0)));
     48      var resultValue = (DoubleValue)results["Spacing"].Value;
     49
     50      var spacing = Spacing.Calculate(qualities.Select(q => q.ToArray()));
     51      resultValue.Value = spacing;
     52
     53      return base.Apply();
    5354    }
    5455  }
Note: See TracChangeset for help on using the changeset viewer.