Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8867


Ignore:
Timestamp:
11/04/12 23:11:01 (10 years ago)
Author:
ascheibe
Message:

#1886 improved mutation analyzer

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

Legend:

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

    r8866 r8867  
    3535  [Item("CrossoverPerformanceAnalyzer", "An operator that analyzes the performance of crossovers.")]
    3636  [StorableClass]
    37   public class CrossoverPerformanceAnalyzer : InitializableOperator {
     37  public class CrossoverPerformanceAnalyzer : InitializableOperator, IStatefulItem {
    3838    private const string ResultsParameterName = "Results";
    3939    private const string GenerationsParameterName = "Generations";
     
    226226      }
    227227
    228       worseQualityPoint = new Point2D<double>(cnt, worseQuality - qualityChild);
    229       betterQualityPoint = new Point2D<double>(cnt++, betterQuality - qualityChild);
     228      worseQualityPoint = new Point2D<double>(cnt, Math.Abs(worseQuality - qualityChild));
     229      betterQualityPoint = new Point2D<double>(cnt++, Math.Abs(betterQuality - qualityChild));
    230230
    231231      if (GenerationsParameter.ActualValue.Value == lastGeneration) {
     
    280280      equalParents = 0;
    281281    }
     282
     283    public override void ClearState() {
     284      betterParentCrossoverPerformancePlot.CleanUp();
     285      worseParentCrossoverPerformancePlot.CleanUp();
     286      childDiversityToWorseParentHelper.CleanUp();
     287      childDiversityToBetterParentHelper.CleanUp();
     288      parentDiversityHelper.CleanUp();
     289      parentQualityHelper.CleanUp();
     290    }
    282291  }
    283292}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/MutationPerformanceAnalyzer.cs

    r8797 r8867  
    2121
    2222
    23 using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Common;
     
    2726using HeuristicLab.Data;
    2827using HeuristicLab.Encodings.PermutationEncoding;
    29 using HeuristicLab.Operators;
    3028using HeuristicLab.Optimization;
    3129using HeuristicLab.Parameters;
     
    3533  [Item("MutationPerformanceAnalyzer", "An operator that analyzes the performance of mutation.")]
    3634  [StorableClass]
    37   public class MutationPerformanceAnalyzer : SingleSuccessorOperator, IAnalyzer {
     35  public class MutationPerformanceAnalyzer : InitializableOperator, IStatefulItem {
    3836    private const string ResultsParameterName = "Results";
    3937    private const string GenerationsParameterName = "Generations";
    40 
    41     #region IAnalyzer Members
    42     public bool EnabledByDefault {
    43       get { return true; }
    44     }
    45     #endregion
    46 
    4738
    4839    #region Parameter properties
     
    8273    private ScatterPlotHelper diversityPlotHelper, qualityPlotHelper;
    8374    [Storable]
    84     private DataTableHelper avgDataTableHelper;
    85     [Storable]
    8675    private int cnt = 0, lastGeneration = 0;
    87     [Storable]
    88     private List<double> qualityPoints = new List<double>();
    8976
    9077    [StorableConstructor]
     
    9481      diversityPlotHelper = (ScatterPlotHelper)original.diversityPlotHelper.Clone(cloner);
    9582      qualityPlotHelper = (ScatterPlotHelper)original.qualityPlotHelper.Clone(cloner);
    96       avgDataTableHelper = (DataTableHelper)original.avgDataTableHelper.Clone(cloner);
    9783      cnt = original.cnt;
    9884      lastGeneration = original.lastGeneration;
    99       qualityPoints = new List<double>(original.qualityPoints);
    10085    }
    10186
     
    122107      diversityPlotHelper = new ScatterPlotHelper(false, true);
    123108      qualityPlotHelper = new ScatterPlotHelper(false, true);
    124       avgDataTableHelper = new DataTableHelper();
    125109    }
    126110
     
    129113    }
    130114
    131     public override IOperation Apply() {
    132       Point2D<double> curPoint, divPoint;
    133 
     115    protected override void InitializeAction() {
    134116      if (SimilarityCalculatorParameter.Value == null) {
    135117        SimilarityCalculatorParameter.Value = OperatorsParameter.ActualValue.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault();
    136118      }
     119      Reset();
     120    }
     121
     122    public override IOperation Apply() {
     123      Initialize();
     124      Point2D<double> curPoint, divPoint;
    137125
    138126      var qualityCX = QualityAfterCrossoverParameter.ActualValue.Value;
     
    144132        qualityPlotHelper.InitializePlot(Results, "Mutation Quality", "Solution Index", "Absolut Quality Difference");
    145133        diversityPlotHelper.InitializePlot(Results, "Mutation Diversity", "Solution Index", "Diversity");
    146         avgDataTableHelper.InitializeChart(Results, "Average Mutation Performance", new string[] { "Average Mutation Performance per Generation" });
    147134
    148135        Scope permutationBeforeScope = new Scope();
     
    153140        divPoint = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(permutationBeforeScope, permutationAfterScope));
    154141        curPoint = new Point2D<double>(cnt++, qualityCX - qualityM);
    155         qualityPoints.Add(curPoint.Y);
     142
    156143
    157144        string curGenStr = GenerationsParameter.ActualValue.Value.ToString();
     
    162149        if (GenerationsParameter.ActualValue.Value != 0) {
    163150          if (GenerationsParameter.ActualValue.Value > lastGeneration) {
    164             double avg = qualityPoints.Average();
    165             avgDataTableHelper.AddPoint(avg);
    166151            Reset();
    167152          }
    168         } else {
    169           Reset();
    170153        }
    171154      }
     
    177160      cnt = 0;
    178161      lastGeneration = GenerationsParameter.ActualValue.Value;
    179       qualityPoints.Clear();
     162    }
     163
     164    public override void ClearState() {
     165      qualityPlotHelper.CleanUp();
     166      diversityPlotHelper.CleanUp();
    180167    }
    181168  }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ScatterPlotHelper.cs

    r8797 r8867  
    133133      Plot.VisualProperties.YAxisTitle = yAxisTitle;
    134134    }
     135
     136    public void CleanUp() {
     137      if (!StoreHistory && CreateDataTable) {
     138        resultsCol[chartName].Value = null;
     139        resultsCol.Remove(chartName);
     140        plot = null;
     141      }
     142    }
    135143  }
    136144}
Note: See TracChangeset for help on using the changeset viewer.