Changeset 8287
- Timestamp:
- 07/12/12 06:37:58 (12 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/AlleleOccurencesInGenerationsAnalyzer.cs
r8268 r8287 99 99 var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultParameterName].Value; 100 100 var subtours = AlgorithmBehaviorHelpers.ExtractSubtours(BestSolution.Permutation, 2); 101 List<Point2D<double>> points = new List<Point2D<double>>(); 102 101 103 102 104 Dictionary<IntArray, Dictionary<int, List<int>>> occurences = new Dictionary<IntArray, Dictionary<int, List<int>>>(); … … 106 108 107 109 for (int i = 0; i < GenerationsParameter.ActualValue.Value; i++) { 108 var individuals = graph.Values.Where(x => x.Rank.Contains(i) || x.Rank.Contains(i + 0.5)); 110 var individuals = graph.Values.Where(x => x.Rank.Contains(i)); 111 int k = 0; 109 112 foreach (var subtour in subtours) { 110 113 int cnt = 0; 111 114 double quality = 0.0; 115 double min = double.MaxValue; 116 double max = double.MinValue; 112 117 foreach (var individual in individuals) { 113 118 var ind = (IntArray)individual.Data; 114 119 if (AlgorithmBehaviorHelpers.IsSubtour(subtour, (Permutation)ind)) { 115 120 cnt++; 116 quality += TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, (Permutation)individual.Data); 121 double tmp = TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, (Permutation)individual.Data); 122 if (tmp < min) min = tmp; 123 if (tmp > max) max = tmp; 124 quality += tmp; 117 125 } 118 126 } … … 122 130 if (cnt != 0) { 123 131 double avgQuality = quality / cnt; 124 double qualityRatio = avgQuality / Qualities.Rows["CurrentAverageQuality"].Values[i] * 100;132 double qualityRatio = avgQuality / Qualities.Rows["CurrentAverageQuality"].Values[i]; 125 133 vals.Add((int)qualityRatio); 134 135 points.Add(new Point2D<double>(k++, qualityRatio)); 126 136 } 127 137 occurences[subtour][i] = vals; 128 138 } 139 140 var plot = new ScatterPlot("Contained Edges of Best Found Solution and Relative Solution Qualtiy", null); 141 plot.VisualProperties.XAxisTitle = "Contained Alleles of Best Found Solution"; 142 plot.VisualProperties.YAxisTitle = "Relative Solution Quality"; 143 plot.VisualProperties.XAxisMinimumAuto = false; 144 plot.VisualProperties.XAxisMinimumFixedValue = 0.0; 145 plot.VisualProperties.XAxisMaximumAuto = false; 146 plot.VisualProperties.XAxisMaximumFixedValue = subtours.Count; 147 /*plot.VisualProperties.YAxisMinimumAuto = false; 148 plot.VisualProperties.YAxisMinimumFixedValue = 0.0; 149 plot.VisualProperties.YAxisMaximumAuto = false; 150 plot.VisualProperties.YAxisMaximumFixedValue = 1.0;*/ 151 var row = new ScatterPlotDataRow("Solutions of Current Generation", null, points); 152 row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle; 153 row.VisualProperties.PointSize = 5; 154 plot.Rows.Add(row); 155 156 if (!Results.ContainsKey("Scatter Plot")) 157 Results.Add(new Result("Scatter Plot", plot)); 158 else 159 Results["Scatter Plot"].Value = plot; 160 161 if (!Results.ContainsKey("Scatter Plot History")) { 162 Results.Add(new Result("Scatter Plot History", new ScatterPlotHistory())); 163 } 164 ((ScatterPlotHistory)Results["Scatter Plot History"].Value).Add(plot); 165 points.Clear(); 129 166 } 130 167 -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/DistinctSolutionsAnalyzer.cs
r8281 r8287 44 44 private const string SchemataParameterName = "Schemata"; 45 45 private const string DistinctSolutionsInGenerationsMatrixParameterName = "DistinctSolutionsInGenerationsMatrix"; 46 private const string OverallDistinctSolutionsParameterName = "OverallDistinctSolutions"; 46 47 private const string QualitiesParameterName = "Qualities"; 47 48 private const string DistanceMatrixParameterName = "DistanceMatrix"; … … 49 50 private const string PopulationSizeParameterName = "PopulationSize"; 50 51 private const string BestSolutionParameterName = "Best TSP Solution"; 52 private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions"; 51 53 52 54 #region IAnalyzer Members … … 81 83 get { return ((HeuristicLab.Analysis.DataTable)ResultsParameter.ActualValue[QualitiesParameterName].Value); } 82 84 } 85 public IntValue EvaluatedSolutions { 86 get { return ((IntValue)ResultsParameter.ActualValue[EvaluatedSolutionsParameterName].Value); } 87 } 83 88 public PathTSPTour BestSolution { 84 89 get { return ((PathTSPTour)ResultsParameter.ActualValue[BestSolutionParameterName].Value); } … … 105 110 int generations = GenerationsParameter.ActualValue.Value; 106 111 int popSize = PopulationSizeParameter.ActualValue.Value; 112 int evaluatedSolutions = EvaluatedSolutions.Value; 113 int overallDistinctSolutions = 0; 107 114 108 115 Dictionary<int, int> distinctSolsInGen = new Dictionary<int, int>(); … … 111 118 var individuals = graph.Values.Where(x => x.Rank.Contains(i)); 112 119 distinctSolsInGen.Add(i, individuals.Count()); 120 overallDistinctSolutions += individuals.Count(); 113 121 } 114 122 … … 122 130 123 131 Results.Add(new Result(DistinctSolutionsInGenerationsMatrixParameterName, dt)); 132 Results.Add(new Result(OverallDistinctSolutionsParameterName, new DoubleValue(evaluatedSolutions / (double)overallDistinctSolutions))); 124 133 return base.Apply(); 125 134 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/HeuristicLab.Analysis.AlgorithmBehavior-3.3.csproj
r8277 r8287 102 102 <Compile Include="Analyzers\AlleleOccurencesInGenerationsAnalyzer.cs" /> 103 103 <Compile Include="Analyzers\ConvergenceSpeedAnalyzer.cs" /> 104 <Compile Include="Analyzers\AlleleOccurencesInGenerationsPerIndAnalyzer.cs" /> 104 105 <Compile Include="Analyzers\DistinctSolutionsAnalyzer.cs" /> 105 106 <Compile Include="Creators\BestIndividualSchemataCreator.cs" />
Note: See TracChangeset
for help on using the changeset viewer.