Changeset 8739


Ignore:
Timestamp:
10/04/12 16:19:15 (10 years ago)
Author:
ascheibe
Message:

#1886 removed static method calls to similarity calculators

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
Files:
2 edited

Legend:

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

    r8511 r8739  
    2929using HeuristicLab.Operators;
    3030using HeuristicLab.Optimization;
    31 using HeuristicLab.Optimization.Operators;
    3231using HeuristicLab.Parameters;
    3332using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    34 using HeuristicLab.Problems.TravelingSalesman;
    3533
    3634namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
     
    6664      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    6765    }
    68     public IValueParameter<SingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
    69       get { return (IValueParameter<SingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
     66    public IValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
     67      get { return (IValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
     68    }
     69    public ILookupParameter<ItemCollection<IItem>> OperatorsParameter {
     70      get { return (ILookupParameter<ItemCollection<IItem>>)Parameters["Operators"]; }
    7071    }
    7172    #endregion
     
    126127      QualityParameter.ActualName = "TSPTourLength";
    127128
    128       Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
     129      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
     130      Parameters.Add(new LookupParameter<ItemCollection<IItem>>("Operators", "The operators and items that the problem provides to the algorithms."));
    129131
    130132      plotHelper = new ScatterPlotHelper(false, true);
     
    141143
    142144    public override IOperation Apply() {
    143       SimilarityCalculatorParameter.Value.QualityVariableName = "TSPTourLength";
    144       SimilarityCalculatorParameter.Value.SolutionVariableName = "TSPTour";
     145      if (SimilarityCalculatorParameter.Value == null) {
     146        SimilarityCalculatorParameter.Value = OperatorsParameter.ActualValue.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault();
     147      }
    145148
    146149      plotHelper.InitializePlot(Results, "Crossover Performance", "Solution Index", "Absolut Quality Difference");
     
    176179      qualityPoints.Add(qualityPoint.Y);
    177180
    178       if (TSPSimilarityCalculator.CalculateSimilarity(parent1, parent2) == 1.0) {
     181      if (parentDiversity == 1.0) {
    179182        equalParents++;
    180183      }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/MutationPerformanceAnalyzer.cs

    r8661 r8739  
    6666      get { return (ILookupParameter<Permutation>)Parameters["PermutationAfterMutation"]; }
    6767    }
     68    public ILookupParameter<ItemCollection<IItem>> OperatorsParameter {
     69      get { return (ILookupParameter<ItemCollection<IItem>>)Parameters["Operators"]; }
     70    }
     71    public IValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
     72      get { return (IValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
     73    }
    6874    #endregion
    6975
     
    112118      PermutationAfterMutationParameter.ActualName = "TSPTour";
    113119
     120      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
     121      Parameters.Add(new LookupParameter<ItemCollection<IItem>>("Operators", "The operators and items that the problem provides to the algorithms."));
     122
    114123      diversityPlotHelper = new ScatterPlotHelper(false, true);
    115124      qualityPlotHelper = new ScatterPlotHelper(false, true);
     
    124133      Point2D<double> curPoint, divPoint;
    125134
     135      if (SimilarityCalculatorParameter.Value == null) {
     136        SimilarityCalculatorParameter.Value = OperatorsParameter.ActualValue.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault();
     137      }
     138
    126139      var qualityCX = QualityAfterCrossoverParameter.ActualValue.Value;
    127140      var qualityM = QualityAfterMutationParameter.ActualValue.Value;
     
    134147        avgDataTableHelper.InitializeChart(Results, "Average Mutation Performance", "Average Mutation Performance per Generation");
    135148
    136         divPoint = new Point2D<double>(cnt, TSPSimilarityCalculator.CalculateSimilarity(permutationBefore, permutationAfter));
     149        Scope permutationBeforeScope = new Scope();
     150        Scope permutationAfterScope = new Scope();
     151        permutationBeforeScope.Variables.Add(new Variable(PermutationAfterMutationParameter.ActualName, permutationBefore));
     152        permutationAfterScope.Variables.Add(new Variable(PermutationAfterMutationParameter.ActualName, permutationAfter));
     153
     154        divPoint = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(permutationBeforeScope, permutationAfterScope));
    137155        curPoint = new Point2D<double>(cnt++, qualityCX - qualityM);
    138156        qualityPoints.Add(curPoint.Y);
Note: See TracChangeset for help on using the changeset viewer.