Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8722 for branches


Ignore:
Timestamp:
10/02/12 22:20:08 (12 years ago)
Author:
ascheibe
Message:

#1886 improved the DuplicateSolutionsAnalyzer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/DuplicateSolutionsAnalyzer.cs

    r8505 r8722  
    2121
    2222
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Operators;
    2627using HeuristicLab.Optimization;
    27 using HeuristicLab.Optimization.Operators;
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    30 using HeuristicLab.Problems.TravelingSalesman;
    3130
    3231namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
     
    4645      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
    4746    }
    48     public IValueParameter<SingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
    49       get { return (IValueParameter<SingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
     47    public IValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
     48      get { return (IValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
     49    }
     50    public ILookupParameter<ItemCollection<IItem>> OperatorsParameter {
     51      get { return (ILookupParameter<ItemCollection<IItem>>)Parameters["Operators"]; }
    5052    }
    5153    #endregion
     
    6264    [StorableConstructor]
    6365    private DuplicateSolutionsAnalyzer(bool deserializing) : base(deserializing) { }
    64    
    65     private DuplicateSolutionsAnalyzer(DuplicateSolutionsAnalyzer original, Cloner cloner) : base(original, cloner) {
     66
     67    private DuplicateSolutionsAnalyzer(DuplicateSolutionsAnalyzer original, Cloner cloner)
     68      : base(original, cloner) {
    6669      chartingHelper = (DataTableHelper)original.chartingHelper.Clone(cloner);
    6770    }
    68    
     71
    6972    public DuplicateSolutionsAnalyzer()
    7073      : base() {
    7174      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    72       Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", new TSPSimilarityCalculator()));
    73       SimilarityCalculatorParameter.Value.SolutionVariableName = "TSPTour";
    74       SimilarityCalculatorParameter.Value.QualityVariableName = "TSPTourLength";
     75      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
     76      Parameters.Add(new LookupParameter<ItemCollection<IItem>>("Operators", "The operators and items that the problem provides to the algorithms."));
    7577
    7678      chartingHelper = new DataTableHelper();
     
    8284
    8385    public override IOperation Apply() {
     86      if (SimilarityCalculatorParameter.Value == null) {
     87        SimilarityCalculatorParameter.Value = OperatorsParameter.ActualValue.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault();
     88      }
    8489      chartingHelper.InitializeChart(Results, "Duplicate Solutions", "Duplicate Solutions per Generation");
    8590
     
    95100      }
    96101
    97       chartingHelper.AddPoint(counter);
     102      chartingHelper.AddPoint(counter / (double)similarities.Length);
    98103      return base.Apply();
    99104    }
Note: See TracChangeset for help on using the changeset viewer.