Changeset 14030 for branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/NormalizedHypervolumeAnalyzer.cs
- Timestamp:
- 07/08/16 15:30:46 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/NormalizedHypervolumeAnalyzer.cs
r13771 r14030 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 45 46 46 47 #region Names 47 private const string bestKnownFront = "BestKnownFront _2";48 private const string bestKnownFront = "BestKnownFront Zitzler"; 48 49 private const string resultsHV = "NormalizedHypervolume"; 49 50 private const string resultsDist = "Absolute Distance to Normalized BestKnownHypervolume"; … … 90 91 } 91 92 92 double diff;93 IEnumerable<double[]> front = NonDominatedSelect.selectNonDominatedVectors(qualities, TestFunctionParameter.ActualValue.Maximization(objectives), true); 93 94 94 95 if (!results.ContainsKey(resultsHV)) results.Add(new Result(resultsHV, typeof(DoubleValue))); 95 IEnumerable<double[]> front = NonDominatedSelect.selectNonDominatedVectors(qualities, TestFunctionParameter.ActualValue.Maximization(objectives), true);96 if (!results.ContainsKey(resultsDist)) results.Add(new Result(resultsDist, typeof(DoubleValue))); 96 97 if (!results.ContainsKey(bestknownHV)) results.Add(new Result(bestknownHV, typeof(DoubleValue))); 97 98 else { … … 99 100 best = dv.Value; 100 101 } 101 if (!results.ContainsKey(resultsDist)) results.Add(new Result(resultsDist, typeof(DoubleValue)));102 103 double hv = Double.NaN;104 102 105 103 bool[] maximization = TestFunctionParameter.ActualValue.Maximization(objectives); 106 104 double[] invPoint = GetBestPoint(OptimalFrontParameter.Value, maximization); 107 105 double[] refPoint = GetWorstPoint(OptimalFrontParameter.Value, maximization); 108 double normalization = GetHypervolume(refPoint, invPoint); 106 double normalization = Hypervolume.Calculate(new double[][] { invPoint }, refPoint, maximization); 107 double hv = front.Any() ? Hypervolume.Calculate(front, refPoint, maximization) / normalization : 0; 109 108 110 111 try { 112 if (objectives == 2) { //Hypervolume analysis only with 2 objectives for now 113 hv = Hypervolume.Calculate(front, refPoint, maximization); 114 } else if (Array.TrueForAll(maximization, x => !x)) { 115 hv = MultiDimensionalHypervolume.Calculate(front, refPoint); 116 } 117 } 118 catch (ArgumentException) { 119 120 } 121 122 hv /= normalization; 123 124 if (best < 0) { 125 best = hv; 126 } 109 if (Double.IsNaN(best)) best = hv; else best = Math.Max(best, hv); 110 double diff; 127 111 diff = best - hv; 128 if (!Double.IsNaN(hv) && (diff < 0 || best < 0)) { 129 best = hv; 130 diff = 0; 112 if (diff == 0) { 131 113 BestKnownFrontParameter.ActualValue = new DoubleMatrix(MultiObjectiveTestFunctionProblem.To2D(qualities)); 132 114 } … … 136 118 results[bestknownHV].Value = new DoubleValue(best); 137 119 138 }139 140 private double GetHypervolume(double[] refPoint, double[] invPoint) {141 if (refPoint.Length == 0) return 0;142 double hv = 1;143 for (int i = 0; i < refPoint.Length; i++) {144 hv *= Math.Abs(refPoint[i] - invPoint[i]);145 }146 return hv;147 120 } 148 121
Note: See TracChangeset
for help on using the changeset viewer.