Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/15/16 14:14:50 (8 years ago)
Author:
mkommend
Message:

#1087: Further refactoring of testfunction problem and analyzers.

File:
1 edited

Legend:

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

    r14081 r14085  
    3434  public class HypervolumeAnalyzer : MOTFAnalyzer {
    3535
    36     public IValueParameter<DoubleArray> ReferencePointParameter {
    37       get { return (IValueParameter<DoubleArray>)Parameters["ReferencePoint"]; }
     36    public ILookupParameter<DoubleArray> ReferencePointParameter {
     37      get { return (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    3838    }
    3939
     
    4949    [StorableConstructor]
    5050    protected HypervolumeAnalyzer(bool deserializing) : base(deserializing) { }
    51     [StorableHook(HookType.AfterDeserialization)]
    52     private void AfterDeserialization() {
    53       RegisterEventHandlers();
    54     }
    5551
    5652    protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner)
    5753      : base(original, cloner) {
    58       RegisterEventHandlers();
    5954    }
    6055    public override IDeepCloneable Clone(Cloner cloner) {
     
    6358
    6459    public HypervolumeAnalyzer() {
    65       Parameters.Add(new ValueParameter<DoubleArray>("ReferencePoint", "The reference point for hypervolume calculation"));
     60      Parameters.Add(new LookupParameter<DoubleArray>("ReferencePoint", "The reference point for hypervolume calculation"));
    6661      Parameters.Add(new FixedValueParameter<DoubleValue>("BestKnownHyperVolume", "The currently best known hypervolume", new DoubleValue(0)));
    67 
    68       RegisterEventHandlers();
    69     }
    70 
    71     private void RegisterEventHandlers() {
    72       ReferencePointParameter.ValueChanged += (o, e) => BestKnownHyperVolume = 0;
    7362    }
    7463
     
    7766      var qualities = QualitiesParameter.ActualValue;
    7867      var testFunction = TestFunctionParameter.ActualValue;
     68      var referencePoint = ReferencePointParameter.ActualValue;
    7969      int objectives = qualities[0].Length;
     70
     71
    8072
    8173      if (!results.ContainsKey("Hypervolume")) results.Add(new Result("Hypervolume", typeof(DoubleValue)));
     
    9385      IEnumerable<double[]> front = NonDominatedSelect.SelectNonDominatedVectors(qualities.Select(q => q.ToArray()), testFunction.Maximization(objectives), true);
    9486
    95       double hv = front.Any() ? Hypervolume.Calculate(front, testFunction.ReferencePoint(objectives), testFunction.Maximization(objectives)) : 0;
     87      double hv = front.Any() ? Hypervolume.Calculate(front, referencePoint.CloneAsArray(), testFunction.Maximization(objectives)) : 0;
    9688
    9789
Note: See TracChangeset for help on using the changeset viewer.