Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4502


Ignore:
Timestamp:
09/26/10 18:31:37 (14 years ago)
Author:
swinkler
Message:

Worked on population diversity analyzer for TSP: Implemented storing of population diversity result details in a specialized data structure and the algorithm's results collection. (#1188)

Location:
branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPPopulationDiversityAnalyzer.cs

    r4501 r4502  
    4444    // - iterations sampling
    4545    // - view
    46     // - implement data structure for population diversity details
     46    // - extract population diversity basic behavior into separate project
    4747
    4848    public const string PermutationKey = "Permutation";
     
    5858    public ValueParameter<BoolValue> StoreCompleteHistoryParameter {
    5959      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]; }
    6960    }
    7061
     
    7364    public const string CurrentAverageMaximumSimilarityKey = "Current Average Maximum Population Similarity";
    7465    public const string AverageMaximumSimilarityProgressKey = "Average Maximum Population Similarity Progress";
     66    public const string PopulationDiversityAnalysisResultsDetailsKey = "Population Diversity Analysis Results Details";
    7567
    7668    public const string ResultsKey = "Results";
     
    8577      Parameters.Add(new ValueParameter<BoolValue>(StoreCompleteHistoryKey, "Flag that denotes whether the complete history of similarity values shall be stored.", new BoolValue(true)));
    8678      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."));
    9079    }
    9180
     
    121110        edges[i] = CalculateEdgesVector(permutationsArray[i]);
    122111
    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];
    125114      double avgSimilarity = 0;
    126115      int n = 0;
     
    142131      DoubleValue averageSimilarity = new DoubleValue(avgSimilarity / n);
    143132
    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 
    155133      #region Store average similarity values
    156134      if (results.ContainsKey(CurrentAverageSimilarityKey))
     
    178156        averageMaximumSimilarityProgressDataTable.Rows.Add(new Analysis.DataRow(AverageMaximumSimilarityProgressKey));
    179157      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      }
    180175      #endregion
    181176
  • branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj

    r4501 r4502  
    154154  <ItemGroup>
    155155    <Compile Include="Analyzers\BestTSPSolutionAnalyzer.cs" />
     156    <Compile Include="Analyzers\TSPPopulationDiversityAnalysisDetails.cs" />
    156157    <Compile Include="Analyzers\TSPPopulationDiversityAnalyzer.cs" />
    157158    <Compile Include="Evaluators\TSPEuclideanPathEvaluator.cs" />
Note: See TracChangeset for help on using the changeset viewer.