Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8866


Ignore:
Timestamp:
11/02/12 16:21:51 (12 years ago)
Author:
ascheibe
Message:

#1886 further improvements for the crossover performance analyzer

File:
1 edited

Legend:

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

    r8865 r8866  
    8080
    8181    [Storable]
    82     private ScatterPlotHelper plotHelper, childDiversityToWorseParentHelper, childDiversityToBetterParentHelper, parentDiversityHelper, parentQualityHelper;
    83     [Storable]
    84     private DataTableHelper performanceHelper, successHelper, equalParentsHelper;
     82    private ScatterPlotHelper worseParentCrossoverPerformancePlot, betterParentCrossoverPerformancePlot, childDiversityToWorseParentHelper, childDiversityToBetterParentHelper, parentDiversityHelper, parentQualityHelper;
     83    [Storable]
     84    private DataTableHelper successHelper, equalParentsHelper;
    8585    [Storable]
    8686    private int cnt = 0;
     
    9191    [Storable]
    9292    private int equalParents = 0;
    93     [Storable]
    94     private List<double> qualityPoints = new List<double>();
    9593
    9694    [StorableConstructor]
     
    102100      lastGeneration = original.lastGeneration;
    103101      equalParents = original.equalParents;
    104       qualityPoints = new List<double>(original.qualityPoints);
    105       plotHelper = (ScatterPlotHelper)original.plotHelper.Clone(cloner);
     102      worseParentCrossoverPerformancePlot = (ScatterPlotHelper)original.worseParentCrossoverPerformancePlot.Clone(cloner);
     103      betterParentCrossoverPerformancePlot = (ScatterPlotHelper)original.betterParentCrossoverPerformancePlot.Clone(cloner);
    106104      childDiversityToWorseParentHelper = (ScatterPlotHelper)original.childDiversityToWorseParentHelper.Clone(cloner);
    107105      childDiversityToBetterParentHelper = (ScatterPlotHelper)original.childDiversityToBetterParentHelper.Clone(cloner);
    108106      parentDiversityHelper = (ScatterPlotHelper)original.parentDiversityHelper.Clone(cloner);
    109107      parentQualityHelper = (ScatterPlotHelper)original.parentQualityHelper.Clone(cloner);
    110       performanceHelper = (DataTableHelper)original.performanceHelper.Clone(cloner);
    111108      successHelper = (DataTableHelper)original.successHelper.Clone(cloner);
    112109      equalParentsHelper = (DataTableHelper)original.equalParentsHelper.Clone(cloner);
     
    136133
    137134
    138       plotHelper = new ScatterPlotHelper(false, true);
     135      worseParentCrossoverPerformancePlot = new ScatterPlotHelper(false, true);
     136      betterParentCrossoverPerformancePlot = new ScatterPlotHelper(false, true);
    139137      childDiversityToWorseParentHelper = new ScatterPlotHelper(false, true);
    140138      childDiversityToBetterParentHelper = new ScatterPlotHelper(false, true);
    141139      parentDiversityHelper = new ScatterPlotHelper(false, true);
    142140      parentQualityHelper = new ScatterPlotHelper(false, true);
    143       performanceHelper = new DataTableHelper();
    144141      successHelper = new DataTableHelper();
    145142      equalParentsHelper = new DataTableHelper();
     
    167164      }
    168165
    169       plotHelper.InitializePlot(Results, "Crossover Performance", "Solution Index", "Absolut Quality Difference");
     166      worseParentCrossoverPerformancePlot.InitializePlot(Results, "Crossover Performance compared to worse parent", "Solution Index", "Absolut Quality Difference");
     167      betterParentCrossoverPerformancePlot.InitializePlot(Results, "Crossover Performance compared to better parent", "Solution Index", "Absolut Quality Difference");
    170168      childDiversityToWorseParentHelper.InitializePlot(Results, "Child Diversity to Worse Parent", "Solution Index", "Diversity");
    171169      childDiversityToBetterParentHelper.InitializePlot(Results, "Child Diversity to Better Parent", "Solution Index", "Diversity");
    172170      parentDiversityHelper.InitializePlot(Results, "Parent Diversity", "Solution Index", "Diversity");
    173171      parentQualityHelper.InitializePlot(Results, "Parent Quality Difference", "Solution Index", "Absolut Quality Difference");
    174       performanceHelper.InitializeChart(Results, "Average Crossover Performance", new string[] { "Average Crossover Performance per Generation" });
    175172      equalParentsHelper.InitializeChart(Results, "Number of equal parents", new string[] { "Absolut number of equal parents" });
    176173
     
    186183      Initialize();
    187184
    188       Point2D<double> qualityPoint, childDiversityToWorseParent, childDiversityToBetterParent, diversityPointParent, qualityPointParent;
     185      Point2D<double> worseQualityPoint, betterQualityPoint, childDiversityToWorseParent, childDiversityToBetterParent, diversityPointParent, qualityPointParent;
    189186      var parent1 = ParentsParameter.ActualValue.First();
    190187      var parent2 = ParentsParameter.ActualValue.Last();
     
    200197      qualityPointParent = new Point2D<double>(cnt, Math.Abs(qualityParent1 - qualityParent2));
    201198
     199
     200      double worseQuality, betterQuality;
     201
    202202      if (qualityParent1 > qualityParent2) {
    203203        if (MaximizationParameter.ActualValue.Value) {
    204204          childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last()));
    205205          childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First()));
     206          worseQuality = qualityParent2;
     207          betterQuality = qualityParent1;
    206208        } else {
    207209          childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First()));
    208210          childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last()));
     211          worseQuality = qualityParent1;
     212          betterQuality = qualityParent2;
    209213        }
    210214      } else {
     
    212216          childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First()));
    213217          childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last()));
     218          worseQuality = qualityParent1;
     219          betterQuality = qualityParent2;
    214220        } else {
    215221          childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last()));
    216222          childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First()));
    217         }
    218       }
    219 
    220       double worseQuality = qualityParent1 > qualityParent2 ? qualityParent1 : qualityParent2;
    221       qualityPoint = new Point2D<double>(cnt++, worseQuality - qualityChild);
    222       qualityPoints.Add(qualityPoint.Y);
    223 
     223          worseQuality = qualityParent2;
     224          betterQuality = qualityParent1;
     225        }
     226      }
     227
     228      worseQualityPoint = new Point2D<double>(cnt, worseQuality - qualityChild);
     229      betterQualityPoint = new Point2D<double>(cnt++, betterQuality - qualityChild);
     230
     231      if (GenerationsParameter.ActualValue.Value == lastGeneration) {
     232        CountSuccess(qualityChild, qualityParent1, qualityParent2);
     233
     234        if (parentDiversity == 1.0) {
     235          equalParents++;
     236        }
     237      }
     238
     239      if (GenerationsParameter.ActualValue.Value != 0) {
     240        if (GenerationsParameter.ActualValue.Value > lastGeneration) {
     241          equalParentsHelper.AddPoint(equalParents);
     242
     243          for (int i = 0; i < ComparisonFactorParameter.Value.Count; i++) {
     244            successHelper.AddPoint(SuccessfullCrossoversRowName + ComparisonFactorParameter.Value.ElementAt(i).Value.ToString(), success[i]);
     245          }
     246
     247          Reset();
     248
     249          CountSuccess(qualityChild, qualityParent1, qualityParent2);
     250          if (parentDiversity == 1.0) {
     251            equalParents++;
     252          }
     253        }
     254
     255        betterParentCrossoverPerformancePlot.AddPoint(curGenStr, betterQualityPoint);
     256        worseParentCrossoverPerformancePlot.AddPoint(curGenStr, worseQualityPoint);
     257        childDiversityToWorseParentHelper.AddPoint(curGenStr, childDiversityToWorseParent);
     258        childDiversityToBetterParentHelper.AddPoint(curGenStr, childDiversityToBetterParent);
     259        parentDiversityHelper.AddPoint(curGenStr, diversityPointParent);
     260        parentQualityHelper.AddPoint(curGenStr, qualityPointParent);
     261      }
     262
     263      return base.Apply();
     264    }
     265
     266    private void CountSuccess(double qualityChild, double qualityParent1, double qualityParent2) {
    224267      //track successfull cx
    225268      var compFactsArray = ComparisonFactorParameter.Value.ToArray();
     
    229272        }
    230273      }
    231 
    232       if (parentDiversity == 1.0) {
    233         equalParents++;
    234       }
    235 
    236       if (GenerationsParameter.ActualValue.Value != 0) {
    237         if (GenerationsParameter.ActualValue.Value > lastGeneration) {
    238           double avg = qualityPoints.Average();
    239 
    240           performanceHelper.AddPoint(avg);
    241           equalParentsHelper.AddPoint(equalParents);
    242 
    243           for (int i = 0; i < compFactsArray.Length; i++) {
    244             successHelper.AddPoint(SuccessfullCrossoversRowName + compFactsArray[i].Value.ToString(), success[i]);
    245           }
    246 
    247           Reset();
    248         }
    249 
    250         plotHelper.AddPoint(curGenStr, qualityPoint);
    251         childDiversityToWorseParentHelper.AddPoint(curGenStr, childDiversityToWorseParent);
    252         childDiversityToBetterParentHelper.AddPoint(curGenStr, childDiversityToBetterParent);
    253         parentDiversityHelper.AddPoint(curGenStr, diversityPointParent);
    254         parentQualityHelper.AddPoint(curGenStr, qualityPointParent);
    255       }
    256 
    257       return base.Apply();
    258274    }
    259275
     
    262278      success = new int[ComparisonFactorParameter.Value.Count];
    263279      lastGeneration = GenerationsParameter.ActualValue.Value;
    264       qualityPoints.Clear();
    265280      equalParents = 0;
    266281    }
Note: See TracChangeset for help on using the changeset viewer.