Changeset 4502 for branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPPopulationDiversityAnalyzer.cs
- Timestamp:
- 09/26/10 18:31:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPPopulationDiversityAnalyzer.cs
r4501 r4502 44 44 // - iterations sampling 45 45 // - view 46 // - implement data structure for population diversity details46 // - extract population diversity basic behavior into separate project 47 47 48 48 public const string PermutationKey = "Permutation"; … … 58 58 public ValueParameter<BoolValue> StoreCompleteHistoryParameter { 59 59 get { return (ValueParameter<BoolValue>)Parameters[StoreCompleteHistoryKey]; } 60 }61 62 public const string SimilaritiesKey = "Similarities";63 public ValueParameter<ItemList<DoubleMatrix>> SimilaritiesParameter {64 get { return (ValueParameter<ItemList<DoubleMatrix>>)Parameters[SimilaritiesKey]; }65 }66 public const string MaximumSimilaritiesKey = "MaximumSimilarities";67 public ValueParameter<ItemList<DoubleArray>> MaximumSimilaritiesParameter {68 get { return (ValueParameter<ItemList<DoubleArray>>)Parameters[MaximumSimilaritiesKey]; }69 60 } 70 61 … … 73 64 public const string CurrentAverageMaximumSimilarityKey = "Current Average Maximum Population Similarity"; 74 65 public const string AverageMaximumSimilarityProgressKey = "Average Maximum Population Similarity Progress"; 66 public const string PopulationDiversityAnalysisResultsDetailsKey = "Population Diversity Analysis Results Details"; 75 67 76 68 public const string ResultsKey = "Results"; … … 85 77 Parameters.Add(new ValueParameter<BoolValue>(StoreCompleteHistoryKey, "Flag that denotes whether the complete history of similarity values shall be stored.", new BoolValue(true))); 86 78 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection in which the population diversity analysis results should be stored.")); 87 88 Parameters.Add(new ValueParameter<ItemList<DoubleMatrix>>(SimilaritiesKey, "The similarities of the TSP solutions which should be analyzed."));89 Parameters.Add(new ValueParameter<ItemList<DoubleArray>>(MaximumSimilaritiesKey, "The maximum similarities of the TSP solutions which should be analyzed."));90 79 } 91 80 … … 121 110 edges[i] = CalculateEdgesVector(permutationsArray[i]); 122 111 123 DoubleMatrix similarities = new DoubleMatrix(cities, cities);124 DoubleArray maxSimilarities = new DoubleArray(cities);112 double[,] similarities = new double[cities, cities]; 113 double[] maxSimilarities = new double[cities]; 125 114 double avgSimilarity = 0; 126 115 int n = 0; … … 142 131 DoubleValue averageSimilarity = new DoubleValue(avgSimilarity / n); 143 132 144 if (SimilaritiesParameter.Value == null) {145 SimilaritiesParameter.Value = new ItemList<DoubleMatrix>();146 MaximumSimilaritiesParameter.Value = new ItemList<DoubleArray>();147 }148 if (!StoreCompleteHistoryParameter.Value.Value && SimilaritiesParameter.Value.Count > 0) {149 SimilaritiesParameter.Value[SimilaritiesParameter.Value.Count - 1] = null;150 MaximumSimilaritiesParameter.Value[MaximumSimilaritiesParameter.Value.Count - 1] = null;151 }152 SimilaritiesParameter.Value.Add(similarities);153 MaximumSimilaritiesParameter.Value.Add(maxSimilarities);154 155 133 #region Store average similarity values 156 134 if (results.ContainsKey(CurrentAverageSimilarityKey)) … … 178 156 averageMaximumSimilarityProgressDataTable.Rows.Add(new Analysis.DataRow(AverageMaximumSimilarityProgressKey)); 179 157 averageMaximumSimilarityProgressDataTable.Rows[AverageMaximumSimilarityProgressKey].Values.Add(averageMaximumSimilarity.Value); 158 #endregion 159 #region Store details 160 TSPPopulationDiversityAnalysisDetails details; 161 if (!results.ContainsKey(PopulationDiversityAnalysisResultsDetailsKey)) { 162 details = new TSPPopulationDiversityAnalysisDetails(); 163 results.Add(new Result(PopulationDiversityAnalysisResultsDetailsKey, details)); 164 } else { 165 details = (TSPPopulationDiversityAnalysisDetails)(results[PopulationDiversityAnalysisResultsDetailsKey].Value); 166 } 167 details.AverageSimilarities.Add(averageSimilarity.Value); 168 details.AverageMaximumSimilarities.Add(averageMaximumSimilarity.Value); 169 details.Similarities.Add(similarities); 170 details.MaximumSimilarities.Add(maxSimilarities); 171 if (!StoreCompleteHistoryParameter.Value.Value && details.Similarities.Count > 1) { 172 details.Similarities[details.Similarities.Count - 1] = null; 173 details.MaximumSimilarities[details.MaximumSimilarities.Count - 1] = null; 174 } 180 175 #endregion 181 176
Note: See TracChangeset
for help on using the changeset viewer.