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

    r14073 r14085  
    6565    public override bool[] Maximization {
    6666      get {
    67         //necessary because of virtual member call in base ctor to this property
    68         if (!Parameters.ContainsKey("TestFunction")) return new bool[2];
    69         return TestFunction.Maximization(Objectives);
     67        if (!Parameters.ContainsKey("Maximization")) return new bool[2];
     68        return MaximizationParameter.Value.ToArray();
    7069      }
    7170    }
     
    8786      set { TestFunctionParameter.Value = value; }
    8887    }
    89     public IEnumerable<double[]> BestKnownFront {
    90       get { return Parameters.ContainsKey("BestKnownFront") ? TestFunction.OptimalParetoFront(Objectives) : null; }
     88    public DoubleArray ReferencePoint {
     89      get { return ReferencePointParameter.Value; }
     90      set { ReferencePointParameter.Value = value; }
     91    }
     92    public DoubleMatrix BestKnownFront {
     93      get { return BestKnownFrontParameter.Value; }
     94      set { BestKnownFrontParameter.Value = value; }
    9195    }
    9296    #endregion
     
    112116      Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2)));
    113117      Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound.", new DoubleMatrix(new double[,] { { -4, 4 } })));
     118      Parameters.Add(new ValueParameter<DoubleArray>("ReferencePoint", "The reference point used for hypervolume calculation."));
    114119      Parameters.Add(new ValueParameter<IMultiObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Fonseca()));
    115120      Parameters.Add(new ValueParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
     
    165170    #region Events
    166171    private void UpdateParameterValues() {
    167       MaximizationParameter.ActualValue = (BoolArray)new BoolArray(Maximization).AsReadOnly();
    168       var front = BestKnownFront;
    169       if (front != null) { BestKnownFrontParameter.Value = (DoubleMatrix)new DoubleMatrix(To2D(front.ToArray())).AsReadOnly(); }
    170 
     172      MaximizationParameter.Value = (BoolArray)new BoolArray(TestFunction.Maximization(Objectives)).AsReadOnly();
     173
     174      var front = TestFunction.OptimalParetoFront(Objectives);
     175      if (front != null) {
     176        BestKnownFrontParameter.Value = (DoubleMatrix)new DoubleMatrix(To2D(front.ToArray())).AsReadOnly();
     177      } else BestKnownFrontParameter.Value = null;
     178
     179
     180      BoundsParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives));
     181      ReferencePointParameter.Value = new DoubleArray(TestFunction.ReferencePoint(Objectives));
    171182    }
    172183
     
    186197      Objectives = Math.Max(TestFunction.MinimumObjectives, Math.Min(Objectives, TestFunction.MaximumObjectives));
    187198
    188       Bounds = (DoubleMatrix)new DoubleMatrix(TestFunction.Bounds(Objectives)).Clone();
    189199      ParameterizeAnalyzers();
    190200      UpdateParameterValues();
     
    228238        analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name;
    229239
     240        var crowdingAnalyzer = analyzer as CrowdingAnalyzer;
     241        if (crowdingAnalyzer != null) {
     242          crowdingAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
     243        }
     244
    230245        var hyperVolumeAnalyzer = analyzer as HypervolumeAnalyzer;
    231246        if (hyperVolumeAnalyzer != null) {
    232           hyperVolumeAnalyzer.ReferencePointParameter.Value = new DoubleArray(TestFunction.ReferencePoint(Objectives));
    233           hyperVolumeAnalyzer.BestKnownHyperVolume = TestFunction.BestKnownHypervolume(Objectives);
     247          hyperVolumeAnalyzer.ReferencePointParameter.ActualName = ReferencePointParameter.Name;
     248          hyperVolumeAnalyzer.BestKnownHyperVolume = TestFunction.OptimalHypervolume(Objectives);
    234249        }
    235250
Note: See TracChangeset for help on using the changeset viewer.