Changeset 3635
- Timestamp:
- 05/05/10 14:48:55 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/BestTSPSolutionAnalyzer.cs
r3634 r3635 36 36 [Item("BestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")] 37 37 [StorableClass] 38 public sealed class BestTSPSolutionAnalyzer : SingleSuccessorOperator, I SolutionAnalyzer {39 public LookupParameter<DoubleMatrix> CoordinatesParameter {40 get { return ( LookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }38 public sealed class BestTSPSolutionAnalyzer : SingleSuccessorOperator, IBestTSPSolutionAnalyzer, ISolutionAnalyzer { 39 public ILookupParameter<DoubleMatrix> CoordinatesParameter { 40 get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; } 41 41 } 42 public LookupParameter<Permutation> PermutationParameter {43 get { return ( LookupParameter<Permutation>)Parameters["Permutation"]; }42 public ILookupParameter<Permutation> PermutationParameter { 43 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 44 44 } 45 public LookupParameter<DoubleValue> QualityParameter {46 get { return (LookupParameter<DoubleValue>)Parameters["Quality"]; }45 ILookupParameter IBestTSPSolutionAnalyzer.PermutationParameter { 46 get { return PermutationParameter; } 47 47 } 48 public LookupParameter<PathTSPTour> BestSolutionParameter {49 get { return ( LookupParameter<PathTSPTour>)Parameters["BestSolution"]; }48 public ILookupParameter<DoubleValue> QualityParameter { 49 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } 50 50 } 51 public ValueLookupParameter<ResultCollection> ResultsParameter { 52 get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; } 51 ILookupParameter IBestTSPSolutionAnalyzer.QualityParameter { 52 get { return QualityParameter; } 53 } 54 public ILookupParameter<PathTSPTour> BestSolutionParameter { 55 get { return (ILookupParameter<PathTSPTour>)Parameters["BestSolution"]; } 56 } 57 public IValueLookupParameter<ResultCollection> ResultsParameter { 58 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 53 59 } 54 60 -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/MultiPopulationBestTSPSolutionAnalyzer.cs
r3634 r3635 38 38 [Item("MultiPopulationBestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")] 39 39 [StorableClass] 40 public sealed class MultiPopulationBestTSPSolutionAnalyzer : SingleSuccessorOperator, I MultiPopulationAnalyzer {41 public LookupParameter<DoubleMatrix> CoordinatesParameter {42 get { return ( LookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }40 public sealed class MultiPopulationBestTSPSolutionAnalyzer : SingleSuccessorOperator, IBestTSPSolutionAnalyzer, IMultiPopulationAnalyzer { 41 public ILookupParameter<DoubleMatrix> CoordinatesParameter { 42 get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; } 43 43 } 44 public SubScopesSubScopesLookupParameter<Permutation> PermutationParameter {45 get { return ( SubScopesSubScopesLookupParameter<Permutation>)Parameters["Permutation"]; }44 public ILookupParameter<ItemArray<ItemArray<Permutation>>> PermutationParameter { 45 get { return (ILookupParameter<ItemArray<ItemArray<Permutation>>>)Parameters["Permutation"]; } 46 46 } 47 public SubScopesSubScopesLookupParameter<DoubleValue> QualityParameter {48 get { return (SubScopesSubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }47 ILookupParameter IBestTSPSolutionAnalyzer.PermutationParameter { 48 get { return PermutationParameter; } 49 49 } 50 public LookupParameter<PathTSPTour> BestSolutionParameter {51 get { return ( LookupParameter<PathTSPTour>)Parameters["BestSolution"]; }50 public ILookupParameter<ItemArray<ItemArray<DoubleValue>>> QualityParameter { 51 get { return (ILookupParameter<ItemArray<ItemArray<DoubleValue>>>)Parameters["Quality"]; } 52 52 } 53 public ValueLookupParameter<ResultCollection> ResultsParameter { 54 get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; } 53 ILookupParameter IBestTSPSolutionAnalyzer.QualityParameter { 54 get { return QualityParameter; } 55 } 56 public ILookupParameter<PathTSPTour> BestSolutionParameter { 57 get { return (ILookupParameter<PathTSPTour>)Parameters["BestSolution"]; } 58 } 59 public IValueLookupParameter<ResultCollection> ResultsParameter { 60 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 55 61 } 56 62 -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/PopulationBestTSPSolutionAnalyzer.cs
r3634 r3635 36 36 [Item("PopulationBestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")] 37 37 [StorableClass] 38 public sealed class PopulationBestTSPSolutionAnalyzer : SingleSuccessorOperator, I PopulationAnalyzer {39 public LookupParameter<DoubleMatrix> CoordinatesParameter {40 get { return ( LookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }38 public sealed class PopulationBestTSPSolutionAnalyzer : SingleSuccessorOperator, IBestTSPSolutionAnalyzer, IPopulationAnalyzer { 39 public ILookupParameter<DoubleMatrix> CoordinatesParameter { 40 get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; } 41 41 } 42 public SubScopesLookupParameter<Permutation> PermutationParameter {43 get { return ( SubScopesLookupParameter<Permutation>)Parameters["Permutation"]; }42 public ILookupParameter<ItemArray<Permutation>> PermutationParameter { 43 get { return (ILookupParameter<ItemArray<Permutation>>)Parameters["Permutation"]; } 44 44 } 45 public SubScopesLookupParameter<DoubleValue> QualityParameter {46 get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }45 ILookupParameter IBestTSPSolutionAnalyzer.PermutationParameter { 46 get { return PermutationParameter; } 47 47 } 48 public LookupParameter<PathTSPTour> BestSolutionParameter {49 get { return ( LookupParameter<PathTSPTour>)Parameters["BestSolution"]; }48 public ILookupParameter<ItemArray<DoubleValue>> QualityParameter { 49 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Quality"]; } 50 50 } 51 public ValueLookupParameter<ResultCollection> ResultsParameter { 52 get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; } 51 ILookupParameter IBestTSPSolutionAnalyzer.QualityParameter { 52 get { return QualityParameter; } 53 } 54 public ILookupParameter<PathTSPTour> BestSolutionParameter { 55 get { return (ILookupParameter<PathTSPTour>)Parameters["BestSolution"]; } 56 } 57 public IValueLookupParameter<ResultCollection> ResultsParameter { 58 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 53 59 } 54 60 -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj
r3634 r3635 90 90 <Compile Include="Evaluators\TSPGeoPathEvaluator.cs" /> 91 91 <Compile Include="HeuristicLabProblemsTravelingSalesmanPlugin.cs" /> 92 <Compile Include="Interfaces\IBestTSPSolutionAnalyzer.cs" /> 92 93 <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveEuclideanPathEvaluator.cs" /> 93 94 <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveGeoPathEvaluator.cs" /> -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r3616 r3635 124 124 get { return operators; } 125 125 } 126 private BestTSPSolutionAnalyzer Analyzer{127 get { return operators.OfType< BestTSPSolutionAnalyzer>().FirstOrDefault(); }126 private IEnumerable<IBestTSPSolutionAnalyzer> BestTSPSolutionAnalyzers { 127 get { return operators.OfType<IBestTSPSolutionAnalyzer>(); } 128 128 } 129 129 #endregion … … 231 231 ParameterizeSolutionCreator(); 232 232 ParameterizeEvaluator(); 233 ParameterizeAnalyzer ();233 ParameterizeAnalyzers(); 234 234 ParameterizeOperators(); 235 235 OnSolutionCreatorChanged(); … … 237 237 private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) { 238 238 ParameterizeEvaluator(); 239 ParameterizeAnalyzer ();239 ParameterizeAnalyzers(); 240 240 ParameterizeOperators(); 241 241 } … … 244 244 ParameterizeEvaluator(); 245 245 UpdateMoveEvaluators(); 246 ParameterizeAnalyzer ();246 ParameterizeAnalyzers(); 247 247 ClearDistanceMatrix(); 248 248 OnEvaluatorChanged(); 249 249 } 250 250 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 251 ParameterizeAnalyzer ();251 ParameterizeAnalyzers(); 252 252 } 253 253 private void MoveGenerator_InversionMoveParameter_ActualNameChanged(object sender, EventArgs e) { … … 281 281 operators = new List<IOperator>(); 282 282 operators.Add(new BestTSPSolutionAnalyzer()); 283 ParameterizeAnalyzer(); 283 operators.Add(new PopulationBestTSPSolutionAnalyzer()); 284 operators.Add(new MultiPopulationBestTSPSolutionAnalyzer()); 285 ParameterizeAnalyzers(); 284 286 operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Cast<IOperator>()); 285 287 ParameterizeOperators(); … … 323 325 } 324 326 } 325 private void ParameterizeAnalyzer () {326 if (Analyzer != null) {327 Analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;328 Analyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name;329 Analyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;330 Analyzer.ResultsParameter.ActualName = "Results";327 private void ParameterizeAnalyzers() { 328 foreach (IBestTSPSolutionAnalyzer analyzer in BestTSPSolutionAnalyzers) { 329 analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 330 analyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name; 331 analyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 332 analyzer.ResultsParameter.ActualName = "Results"; 331 333 } 332 334 }
Note: See TracChangeset
for help on using the changeset viewer.