- Timestamp:
- 11/20/18 14:53:51 (6 years ago)
- Location:
- branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Optimization (added) merged: 16179
- Property svn:mergeinfo changed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs
r16171 r16310 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using System.Linq; 25 23 using HeuristicLab.Common; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs
r15583 r16310 188 188 TimeSpan.FromSeconds(15) }); 189 189 snapshotTimesIndex = 0; 190 snapshots = new RunCollection(); 190 191 Runs = new RunCollection { OptimizerName = Name }; 191 192 Initialize(); … … 199 200 TimeSpan.FromSeconds(15) }); 200 201 snapshotTimesIndex = 0; 202 snapshots = new RunCollection(); 201 203 Runs = new RunCollection { OptimizerName = Name }; 202 204 Initialize(); -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/CrowdingCalculator.cs
r16171 r16310 35 35 /// Beware that CrowdingCalculator is not normalized for the number of dimensions. A higher number of dimensions normally causes higher CrowdingCalculator values 36 36 /// </summary> 37 public static class CrowdingCalculator 38 { 37 public static class CrowdingCalculator { 39 38 40 39 public static double CalculateCrowding<TP>(IEnumerable<TP> qualities) where TP : IReadOnlyList<double> { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/GenerationalDistanceCalculator.cs
r16171 r16310 23 23 24 24 #region 25 26 25 using System; 27 26 using System.Collections.Generic; 28 27 using System.Linq; 29 28 using HeuristicLab.Common; 30 31 29 #endregion 32 30 … … 40 38 public static class GenerationalDistanceCalculator { 41 39 public static double CalculateGenerationalDistance<TP1, TP2>(IEnumerable<TP1> qualities, IEnumerable<TP2> bestKnownFront, double p) where TP1 : IReadOnlyList<double> where TP2 : IReadOnlyList<double> { 42 if (qualities == null || bestKnownFront == null) throw new ArgumentNullException( "Fronts must not be null");40 if (qualities == null || bestKnownFront == null) throw new ArgumentNullException(nameof(qualities)); 43 41 if (p.IsAlmost(0.0)) throw new ArgumentException("p must not be zero."); 44 42 var mat = bestKnownFront.ToMatrix(); 45 43 if (mat.GetLength(0) == 0) throw new ArgumentException("Fronts must not be empty."); 46 44 47 alglib.kdtree tree; 48 alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out tree); 45 alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out var tree); 49 46 var sum = 0.0; 50 47 var summand = new double[1]; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/HypervolumeCalculator.cs
r16171 r16310 23 23 using System.Linq; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Optimization;26 25 27 26 namespace HeuristicLab.Optimization { … … 64 63 public static double CalculateHypervolume(double[][] qualities, double[] referencePoint, bool[] maximization){ 65 64 qualities = qualities.Where(vec => DominationCalculator.Dominates(vec, referencePoint, maximization, false) == DominationResult.Dominates).ToArray(); 66 if ( !qualities.Any()) return 0;//TODO replace with negative computation65 if (qualities.Length == 0 ) return 0;//TODO computation for negative hypervolume? 67 66 if (maximization.Length == 2) 68 67 return Calculate2D(qualities, referencePoint, maximization); … … 73 72 } 74 73 74 75 /// <summary> 76 /// Caluclates the Hypervolume for a 2 dimensional problem 77 /// </summary> 78 /// <param name="front">All points within the front need to be Non-Dominated and need to dominate the reference point</param> 79 /// <param name="referencePoint"></param> 80 /// <param name="maximization"></param> 81 /// <returns></returns> 75 82 public static double Calculate2D(double[][] front, double[] referencePoint, bool[] maximization) { 76 if (front == null) throw new ArgumentNullException("Front must not be null."); 83 if (front == null) throw new ArgumentNullException(nameof(front)); 84 if (referencePoint == null) throw new ArgumentNullException(nameof(referencePoint)); 85 if (maximization == null) throw new ArgumentNullException(nameof(maximization)); 77 86 if (!front.Any()) throw new ArgumentException("Front must not be empty."); 78 79 if (referencePoint == null) throw new ArgumentNullException("ReferencePoint must not be null.");80 87 if (referencePoint.Length != 2) throw new ArgumentException("ReferencePoint must have exactly two dimensions."); 81 88 … … 87 94 double sum = 0; 88 95 for (var i = 0; i < set.Length - 1; i++) 89 sum += Math.Abs((set[i][0] - set[i + 1][0])) * Math.Abs((set[i][1] - referencePoint[1])); 90 96 sum += Math.Abs(set[i][0] - set[i + 1][0]) * Math.Abs(set[i][1] - referencePoint[1]); 91 97 var lastPoint = set[set.Length - 1]; 92 98 sum += Math.Abs(lastPoint[0] - referencePoint[0]) * Math.Abs(lastPoint[1] - referencePoint[1]); … … 112 118 } 113 119 120 121 //within Stream a number of equality comparisons on double values are performed 122 //this is intentional and required 114 123 private static double Stream(double[] regionLow, double[] regionUp, List<double[]> front, int split, double cover, int sqrtNoPoints, int objectives) { 115 124 var coverOld = cover; … … 135 144 var piles = new int[coverIndex]; 136 145 for (var i = 0; i < coverIndex; i++) { 137 piles[i] = IsPile(front[i], regionLow, regionUp,objectives);146 piles[i] = IsPile(front[i], regionLow, objectives); 138 147 if (piles[i] == -1) { 139 148 allPiles = false; … … 145 154 var trellis = new double[regionUp.Length]; 146 155 for (var j = 0; j < trellis.Length; j++) trellis[j] = regionUp[j]; 147 double current = 0; 148 double next = 0; 156 double next; 149 157 var i = 0; 150 158 do { 151 current = front[i][objectives - 1];159 var current = front[i][objectives - 1]; 152 160 do { 153 161 if (front[i][piles[i]] < trellis[piles[i]]) trellis[piles[i]] = front[i][piles[i]]; … … 176 184 } while (bound == -1.0); 177 185 178 List<double[]> pointsChildLow, pointsChildUp; 179 pointsChildLow = new List<double[]>(); 180 pointsChildUp = new List<double[]>(); 186 var pointsChildLow = new List<double[]>(); 187 var pointsChildUp = new List<double[]>(); 181 188 var regionUpC = new double[regionUp.Length]; 182 189 for (var j = 0; j < regionUpC.Length; j++) regionUpC[j] = regionUp[j]; … … 205 212 double result = 0; 206 213 var noSummands = BinarayToInt(bs); 207 int oneCounter; double summand;208 214 for (uint i = 1; i <= noSummands; i++) { 209 summand = 1;215 double summand = 1; 210 216 IntToBinary(i, bs); 211 oneCounter = 0;217 var oneCounter = 0; 212 218 for (var j = 0; j < objectives - 1; j++) { 213 219 if (bs[j]) { … … 244 250 } 245 251 246 private static int IsPile(double[] cuboid, double[] regionLow, double[] regionUp,int objectives) {252 private static int IsPile(double[] cuboid, double[] regionLow, int objectives) { 247 253 var pile = cuboid.Length; 248 254 for (var i = 0; i < objectives - 1; i++) { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/SpacingCalculator.cs
r16171 r16310 34 34 35 35 public static double CalculateSpacing<TP>(IEnumerable<TP> qualities) where TP: IReadOnlyList<double> { 36 if (qualities == null) throw new Argument Exception("Front must not be null.");36 if (qualities == null) throw new ArgumentNullException(nameof(qualities)); 37 37 var l = qualities.ToList(); 38 38 if (l.Count == 0) throw new ArgumentException("Front must not be empty."); … … 40 40 41 41 var mat = l.ToMatrix(); 42 alglib.kdtree tree; 43 alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out tree); 42 alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out var tree); 44 43 var summand = new double[2]; 45 44 var dists = new List<double>(); … … 51 50 return dists.StandardDeviationPop(); 52 51 } 53 54 55 52 } 56 53 }
Note: See TracChangeset
for help on using the changeset viewer.