Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3635 for trunk


Ignore:
Timestamp:
05/05/10 14:48:55 (14 years ago)
Author:
swagner
Message:

Worked on best solution analysis for the TSP (#999)

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  
    3636  [Item("BestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")]
    3737  [StorableClass]
    38   public sealed class BestTSPSolutionAnalyzer : SingleSuccessorOperator, ISolutionAnalyzer {
    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"]; }
    4141    }
    42     public LookupParameter<Permutation> PermutationParameter {
    43       get { return (LookupParameter<Permutation>)Parameters["Permutation"]; }
     42    public ILookupParameter<Permutation> PermutationParameter {
     43      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    4444    }
    45     public LookupParameter<DoubleValue> QualityParameter {
    46       get { return (LookupParameter<DoubleValue>)Parameters["Quality"]; }
     45    ILookupParameter IBestTSPSolutionAnalyzer.PermutationParameter {
     46      get { return PermutationParameter; }
    4747    }
    48     public LookupParameter<PathTSPTour> BestSolutionParameter {
    49       get { return (LookupParameter<PathTSPTour>)Parameters["BestSolution"]; }
     48    public ILookupParameter<DoubleValue> QualityParameter {
     49      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    5050    }
    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"]; }
    5359    }
    5460
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/MultiPopulationBestTSPSolutionAnalyzer.cs

    r3634 r3635  
    3838  [Item("MultiPopulationBestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")]
    3939  [StorableClass]
    40   public sealed class MultiPopulationBestTSPSolutionAnalyzer : SingleSuccessorOperator, IMultiPopulationAnalyzer {
    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"]; }
    4343    }
    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"]; }
    4646    }
    47     public SubScopesSubScopesLookupParameter<DoubleValue> QualityParameter {
    48       get { return (SubScopesSubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }
     47    ILookupParameter IBestTSPSolutionAnalyzer.PermutationParameter {
     48      get { return PermutationParameter; }
    4949    }
    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"]; }
    5252    }
    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"]; }
    5561    }
    5662
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/PopulationBestTSPSolutionAnalyzer.cs

    r3634 r3635  
    3636  [Item("PopulationBestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")]
    3737  [StorableClass]
    38   public sealed class PopulationBestTSPSolutionAnalyzer : SingleSuccessorOperator, IPopulationAnalyzer {
    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"]; }
    4141    }
    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"]; }
    4444    }
    45     public SubScopesLookupParameter<DoubleValue> QualityParameter {
    46       get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }
     45    ILookupParameter IBestTSPSolutionAnalyzer.PermutationParameter {
     46      get { return PermutationParameter; }
    4747    }
    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"]; }
    5050    }
    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"]; }
    5359    }
    5460
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj

    r3634 r3635  
    9090    <Compile Include="Evaluators\TSPGeoPathEvaluator.cs" />
    9191    <Compile Include="HeuristicLabProblemsTravelingSalesmanPlugin.cs" />
     92    <Compile Include="Interfaces\IBestTSPSolutionAnalyzer.cs" />
    9293    <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveEuclideanPathEvaluator.cs" />
    9394    <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveGeoPathEvaluator.cs" />
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r3616 r3635  
    124124      get { return operators; }
    125125    }
    126     private BestTSPSolutionAnalyzer Analyzer {
    127       get { return operators.OfType<BestTSPSolutionAnalyzer>().FirstOrDefault(); }
     126    private IEnumerable<IBestTSPSolutionAnalyzer> BestTSPSolutionAnalyzers {
     127      get { return operators.OfType<IBestTSPSolutionAnalyzer>(); }
    128128    }
    129129    #endregion
     
    231231      ParameterizeSolutionCreator();
    232232      ParameterizeEvaluator();
    233       ParameterizeAnalyzer();
     233      ParameterizeAnalyzers();
    234234      ParameterizeOperators();
    235235      OnSolutionCreatorChanged();
     
    237237    private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
    238238      ParameterizeEvaluator();
    239       ParameterizeAnalyzer();
     239      ParameterizeAnalyzers();
    240240      ParameterizeOperators();
    241241    }
     
    244244      ParameterizeEvaluator();
    245245      UpdateMoveEvaluators();
    246       ParameterizeAnalyzer();
     246      ParameterizeAnalyzers();
    247247      ClearDistanceMatrix();
    248248      OnEvaluatorChanged();
    249249    }
    250250    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    251       ParameterizeAnalyzer();
     251      ParameterizeAnalyzers();
    252252    }
    253253    private void MoveGenerator_InversionMoveParameter_ActualNameChanged(object sender, EventArgs e) {
     
    281281      operators = new List<IOperator>();
    282282      operators.Add(new BestTSPSolutionAnalyzer());
    283       ParameterizeAnalyzer();
     283      operators.Add(new PopulationBestTSPSolutionAnalyzer());
     284      operators.Add(new MultiPopulationBestTSPSolutionAnalyzer());
     285      ParameterizeAnalyzers();
    284286      operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Cast<IOperator>());
    285287      ParameterizeOperators();
     
    323325      }
    324326    }
    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";
    331333      }
    332334    }
Note: See TracChangeset for help on using the changeset viewer.