- Timestamp:
- 09/26/10 17:05:23 (14 years ago)
- Location:
- branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPPopulationDiversityAnalyzer.cs
r4432 r4501 22 22 using System; 23 23 using System.Linq; 24 using HeuristicLab.Analysis; 24 25 using HeuristicLab.Core; 26 using HeuristicLab.Common; 25 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Encodings.PermutationEncoding; … … 29 31 using HeuristicLab.Parameters; 30 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using System.Data; 31 34 32 35 namespace HeuristicLab.Problems.TravelingSalesman { … … 41 44 // - iterations sampling 42 45 // - view 43 46 // - implement data structure for population diversity details 47 48 public const string PermutationKey = "Permutation"; 44 49 public ScopeTreeLookupParameter<Permutation> PermutationParameter { 45 get { return (ScopeTreeLookupParameter<Permutation>)Parameters["Permutation"]; } 46 } 50 get { return (ScopeTreeLookupParameter<Permutation>)Parameters[PermutationKey]; } 51 } 52 public const string QualityKey = "Quality"; 47 53 public ScopeTreeLookupParameter<DoubleValue> QualityParameter { 48 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 49 } 54 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[QualityKey]; } 55 } 56 57 public const string StoreCompleteHistoryKey = "StoreCompleteHistory"; 50 58 public ValueParameter<BoolValue> StoreCompleteHistoryParameter { 51 get { return (ValueParameter<BoolValue>)Parameters["StoreCompleteHistory"]; } 52 } 59 get { return (ValueParameter<BoolValue>)Parameters[StoreCompleteHistoryKey]; } 60 } 61 62 public const string SimilaritiesKey = "Similarities"; 53 63 public ValueParameter<ItemList<DoubleMatrix>> SimilaritiesParameter { 54 get { return (ValueParameter<ItemList<DoubleMatrix>>)Parameters["Similarities"]; } 55 } 64 get { return (ValueParameter<ItemList<DoubleMatrix>>)Parameters[SimilaritiesKey]; } 65 } 66 public const string MaximumSimilaritiesKey = "MaximumSimilarities"; 56 67 public ValueParameter<ItemList<DoubleArray>> MaximumSimilaritiesParameter { 57 get { return (ValueParameter<ItemList<DoubleArray>>)Parameters["MaximumSimilarities"]; } 58 } 59 public ValueParameter<ItemList<DoubleValue>> AverageMaximumSimilaritiesParameter { 60 get { return (ValueParameter<ItemList<DoubleValue>>)Parameters["AverageMaximumSimilarities"]; } 61 } 62 public ValueParameter<ItemList<DoubleValue>> AverageSimilaritiesParameter { 63 get { return (ValueParameter<ItemList<DoubleValue>>)Parameters["AverageSimilarities"]; } 68 get { return (ValueParameter<ItemList<DoubleArray>>)Parameters[MaximumSimilaritiesKey]; } 69 } 70 71 public const string CurrentAverageSimilarityKey = "Current Average Population Similarity"; 72 public const string AverageSimilarityProgressKey = "Average Population Similarity Progress"; 73 public const string CurrentAverageMaximumSimilarityKey = "Current Average Maximum Population Similarity"; 74 public const string AverageMaximumSimilarityProgressKey = "Average Maximum Population Similarity Progress"; 75 76 public const string ResultsKey = "Results"; 77 public ValueLookupParameter<ResultCollection> ResultsParameter { 78 get { return (ValueLookupParameter<ResultCollection>)Parameters[ResultsKey]; } 64 79 } 65 80 66 81 public TSPPopulationDiversityAnalyzer() 67 82 : base() { 68 Parameters.Add(new ScopeTreeLookupParameter<Permutation>( "Permutation", "The TSP solutions given in path representation from which the best solution should be analyzed."));69 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>( "Quality", "The qualities of the TSP solutions which should be analyzed."));70 Parameters.Add(new ValueParameter<BoolValue>( "StoreCompleteHistory", "Flag that denotes whether the complete history of similarity values shall be stored.", new BoolValue(true)));71 Parameters.Add(new Value Parameter<ItemList<DoubleMatrix>>("Similarities", "The similarities of the TSP solutions which should be analyzed."));72 Parameters.Add(new ValueParameter<ItemList<DoubleArray>>("MaximumSimilarities", "The maximum similarities of the TSP solutions which should be analyzed.")); 73 Parameters.Add(new ValueParameter<ItemList<Double Value>>("AverageMaximumSimilarities", "The average maximumsimilarities of the TSP solutions which should be analyzed."));74 Parameters.Add(new ValueParameter<ItemList<Double Value>>("AverageSimilarities", "The averagesimilarities of the TSP solutions which should be analyzed."));83 Parameters.Add(new ScopeTreeLookupParameter<Permutation>(PermutationKey, "The TSP solutions given in path representation from which the best solution should be analyzed.")); 84 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityKey, "The qualities of the TSP solutions which should be analyzed.")); 85 Parameters.Add(new ValueParameter<BoolValue>(StoreCompleteHistoryKey, "Flag that denotes whether the complete history of similarity values shall be stored.", new BoolValue(true))); 86 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.")); 75 90 } 76 91 77 92 public override IOperation Apply() { 78 79 #region testing80 /*81 Permutation permutationA = new Permutation(PermutationTypes.Absolute, new int[] { 0, 5, 4, 3, 2, 1 });82 Permutation permutationB = new Permutation(PermutationTypes.Absolute, new int[] { 0, 3, 2, 4, 5, 1 });83 Permutation permutationC = new Permutation(PermutationTypes.Absolute, new int[] { 3, 2, 4, 5, 1, 0 });84 Permutation permutationD = new Permutation(PermutationTypes.Absolute, new int[] { 3, 2, 4, 5, 0, 1 });85 int[] edgesA = CalculateEdgesVector(permutationA);86 int[] edgesB = CalculateEdgesVector(permutationB);87 int[] edgesC = CalculateEdgesVector(permutationC);88 int[] edgesD = CalculateEdgesVector(permutationD);89 double s = CalculateSimilarity(edgesA, edgesB);90 s = CalculateSimilarity(edgesA, edgesA);91 s = CalculateSimilarity(edgesB, edgesB);92 s = CalculateSimilarity(edgesC, edgesC);93 s = CalculateSimilarity(edgesD, edgesD);94 s = CalculateSimilarity(edgesB, edgesC);95 s = CalculateSimilarity(edgesC, edgesD);96 */97 #endregion98 93 99 94 ItemArray<Permutation> permutations = PermutationParameter.ActualValue; … … 102 97 DoubleValue[] qualitiesArray = qualities.ToArray(); 103 98 int cities = permutationsArray.Length; 99 ResultCollection results = ResultsParameter.ActualValue; 100 104 101 #region sort permutations array 105 102 for (int i = 0; i < cities; i++) { … … 148 145 SimilaritiesParameter.Value = new ItemList<DoubleMatrix>(); 149 146 MaximumSimilaritiesParameter.Value = new ItemList<DoubleArray>(); 150 AverageMaximumSimilaritiesParameter.Value = new ItemList<DoubleValue>();151 AverageSimilaritiesParameter.Value = new ItemList<DoubleValue>();152 147 } 153 148 if (!StoreCompleteHistoryParameter.Value.Value && SimilaritiesParameter.Value.Count > 0) { … … 157 152 SimilaritiesParameter.Value.Add(similarities); 158 153 MaximumSimilaritiesParameter.Value.Add(maxSimilarities); 159 AverageMaximumSimilaritiesParameter.Value.Add(averageMaximumSimilarity); 160 AverageSimilaritiesParameter.Value.Add(averageSimilarity); 154 155 #region Store average similarity values 156 if (results.ContainsKey(CurrentAverageSimilarityKey)) 157 results[CurrentAverageSimilarityKey].Value = averageSimilarity; 158 else 159 results.Add(new Result(CurrentAverageSimilarityKey, averageSimilarity)); 160 161 if (!results.ContainsKey(AverageSimilarityProgressKey)) 162 results.Add(new Result(AverageSimilarityProgressKey, new Analysis.DataTable(AverageSimilarityProgressKey))); 163 Analysis.DataTable averageSimilarityProgressDataTable = (Analysis.DataTable)(results[AverageSimilarityProgressKey].Value); 164 if (averageSimilarityProgressDataTable.Rows.Count == 0) 165 averageSimilarityProgressDataTable.Rows.Add(new Analysis.DataRow(AverageSimilarityProgressKey)); 166 averageSimilarityProgressDataTable.Rows[AverageSimilarityProgressKey].Values.Add(averageSimilarity.Value); 167 #endregion 168 #region Store average maximum similarity values 169 if (results.ContainsKey(CurrentAverageMaximumSimilarityKey)) 170 results[CurrentAverageMaximumSimilarityKey].Value = averageMaximumSimilarity; 171 else 172 results.Add(new Result(CurrentAverageMaximumSimilarityKey, averageMaximumSimilarity)); 173 174 if (!results.ContainsKey(AverageMaximumSimilarityProgressKey)) 175 results.Add(new Result(AverageMaximumSimilarityProgressKey, new Analysis.DataTable(AverageMaximumSimilarityProgressKey))); 176 Analysis.DataTable averageMaximumSimilarityProgressDataTable = (Analysis.DataTable)(results[AverageMaximumSimilarityProgressKey].Value); 177 if (averageMaximumSimilarityProgressDataTable.Rows.Count == 0) 178 averageMaximumSimilarityProgressDataTable.Rows.Add(new Analysis.DataRow(AverageMaximumSimilarityProgressKey)); 179 averageMaximumSimilarityProgressDataTable.Rows[AverageMaximumSimilarityProgressKey].Values.Add(averageMaximumSimilarity.Value); 180 #endregion 161 181 162 182 return base.Apply(); -
branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj
r4420 r4501 97 97 </PropertyGroup> 98 98 <ItemGroup> 99 <Reference Include="HeuristicLab.Analysis-3.3"> 100 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Analysis-3.3.dll</HintPath> 101 </Reference> 99 102 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 100 103 <SpecificVersion>False</SpecificVersion> -
branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLabProblemsTravelingSalesmanPlugin.cs.frame
r3702 r4501 28 28 [Plugin("HeuristicLab.Problems.TravelingSalesman", "3.3.0.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.TravelingSalesman-3.3.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] 30 31 [PluginDependency("HeuristicLab.Collections", "3.3")] 31 32 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.DiversityAnalysis/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r4420 r4501 322 322 TSPPopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 323 323 TSPPopulationDiversityAnalyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 324 TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results"; 324 325 } 325 326 private void ParameterizeOperators() {
Note: See TracChangeset
for help on using the changeset viewer.