Changeset 10133
 Timestamp:
 11/13/13 10:56:46 (9 years ago)
 Location:
 branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionModifiers
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionModifiers/PermutationConvexHullModifier.cs
r10116 r10133 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 using System.Text;26 24 using HeuristicLab.Analysis.SolutionCaching.PermutationEncoding; 27 using HeuristicLab.Analysis.SolutionCaching.RealVectorEncoding;28 25 using HeuristicLab.Common; 29 26 using HeuristicLab.Core; 30 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HeuristicLab.Data; 28 using HeuristicLab.Encodings.PermutationEncoding; 31 29 using HeuristicLab.Optimization; 32 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 54 52 if (solutionCache == null) continue; 55 53 56 DataTable dt = new DataTable("Convex Hull Volume over Generations"); 54 DataTable volDataTable = new DataTable("Convex hull volume over generations"); 55 DataTable nrOfPointsTable = new DataTable("Nr. of points of convex hull"); 56 DoubleValue overallVolumn = new DoubleValue(); 57 57 58 DataRow dtVolumeRow = new DataRow("Volume"); 58 DataRow dtNrPointsRow = new DataRow("Nr. of Points");59 dt.Rows.Add(dtVolumeRow);60 dt.Rows.Add(dtNrPointsRow);59 DataRow dtNrPointsRow = new DataRow("Nr. of points"); 60 volDataTable.Rows.Add(dtVolumeRow); 61 nrOfPointsTable.Rows.Add(dtNrPointsRow); 61 62 63 List<double[]> curHull = null; 62 64 var sols = solutionCache.GetSolutionsFromGeneration(i); 63 65 int dim = sols.First().Length; 64 66 while (sols.Count != 0) { 65 double[][] dm = new double[sols.Count][]; 66 for (int j = 0; j < sols.Count; j++) { 67 dm[j] = new double[sols.Count]; 68 } 69 70 for (int j = 0; j < sols.Count; j++) { 71 for (int k = 0; k < sols.Count; k++) { 72 dm[j][k] = TSPSimilarityCalculator.CalculateSimilarity(sols[j], sols[k]); 73 } 74 } 75 double[][] popPoints = DistanceMatrixToPoints.ConvertDistanceMatrixToPoints(DistanceMatrixToPoints.MetricMDS(dm, dim, true)); 67 double[][] dm = CalculateDistanceMatrixFromPermutations(sols); 68 double[][] popPoints = DistanceMatrixToPoints.MetricMDS(dm, dim); 76 69 77 70 var convexHull = LPHull.Calculate(popPoints); … … 80 73 dtNrPointsRow.Values.Add(convexHull.Count); 81 74 75 if (curHull == null) { 76 curHull = convexHull; 77 } else { 78 var newPHull = curHull.Union(convexHull).ToArray(); 79 curHull = LPHull.Calculate(newPHull); 80 } 81 82 82 sols = solutionCache.GetSolutionsFromGeneration(++i); 83 83 } 84 overallVolumn.Value = ConvexHullMeasures.CalculateVolume(curHull); 84 85 85 run.Results.Add("Convex Hull Measures", dt); 86 run.Results.Add("Overall volumn: ", overallVolumn); 87 run.Results.Add("Convex hull volumn", volDataTable); 88 run.Results.Add("Convex nr. of points", nrOfPointsTable); 89 } 90 } 91 92 private double[][] CalculateDistanceMatrixFromPermutations(List<Permutation> points) { 93 double[][] tmpDm = new double[points.Count][]; 94 AllocArray(tmpDm, points.Count); 95 96 for (int i = 0; i < points.Count; i++) { 97 for (int j = 0; j < points.Count; j++) { 98 double diversity = TSPSimilarityCalculator.CalculateSimilarity(points[i], points[j]); 99 tmpDm[i][j] = diversity; 100 } 101 } 102 103 return DistanceMatrixToPoints.TransformToDistances(tmpDm); 104 } 105 106 private void AllocArray(double[][] arr, int size) { 107 for (int i = 0; i < arr.Length; i++) { 108 arr[i] = new double[size]; 86 109 } 87 110 } 
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionModifiers/RealVectorConvexHullModifier.cs
r10119 r10133 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 using System.Text;26 24 using HeuristicLab.Analysis.SolutionCaching.RealVectorEncoding; 27 25 using HeuristicLab.Common; … … 53 51 if (solutionCache == null) continue; 54 52 55 var sols = solutionCache.GetSolutionsFromGeneration(i);56 53 DataTable volDataTable = new DataTable("Convex hull volume over generations"); 57 54 DataTable nrOfPointsTable = new DataTable("Nr. of points of convex hull"); … … 64 61 65 62 List<double[]> curHull = null; 66 63 var sols = solutionCache.GetSolutionsFromGeneration(i); 67 64 while (sols.Count != 0) { 68 65 var input = sols.Select(x => ConvertRealVectorToVertexArray(x)).ToArray();
Note: See TracChangeset
for help on using the changeset viewer.