Changeset 9431


Ignore:
Timestamp:
05/03/13 10:08:38 (7 years ago)
Author:
ascheibe
Message:

#1886 added configuration of frequency with which the ab measures are calculated

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

Legend:

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

    r9331 r9431  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2425using HeuristicLab.Optimization;
    2526using HeuristicLab.Optimization.Operators;
     
    5253      get { return (IValueParameter<SingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
    5354    }
     55    public ValueParameter<IntValue> UpdateIntervalParameter {
     56      get { return (ValueParameter<IntValue>)Parameters["UpdateInterval"]; }
     57    }
     58    public ILookupParameter<IntValue> GenerationsParameter {
     59      get { return (ILookupParameter<IntValue>)Parameters["Generations"]; }
     60    }
    5461
    5562    [StorableConstructor]
     
    6774      Parameters.Add(new LookupParameter<IEvaluator>("Evaluator", "The operator which is used to evaluate new solutions."));
    6875      Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
     76      Parameters.Add(new ValueParameter<IntValue>("UpdateInterval", "The interval in which the operator should be applied.", new IntValue(2)));
     77      Parameters.Add(new LookupParameter<IntValue>("Generations", "Nr of generations."));
    6978
    7079      SimilarityCalculatorParameter.ValueChanged += new System.EventHandler(SimilarityCalculatorParameter_ValueChanged);
     
    96105      Operators.Add(selPressureAnalyzer);
    97106    }
     107
     108    public override IOperation Apply() {
     109      if (GenerationsParameter.ActualValue.Value % UpdateIntervalParameter.Value.Value == 0) {
     110        return base.Apply();
     111      } else {
     112        return base.BaseApply();
     113      }
     114    }
    98115  }
    99116}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/AfterMutationCombinedOperator.cs

    r9054 r9431  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2425using HeuristicLab.Optimization;
    2526using HeuristicLab.Optimization.Operators;
     
    3637    public IValueParameter<SingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {
    3738      get { return (IValueParameter<SingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
     39    }
     40    public ValueParameter<IntValue> UpdateIntervalParameter {
     41      get { return (ValueParameter<IntValue>)Parameters["UpdateInterval"]; }
     42    }
     43    public ILookupParameter<IntValue> GenerationsParameter {
     44      get { return (ILookupParameter<IntValue>)Parameters["Generations"]; }
    3845    }
    3946
     
    6067      Parameters.Add(new LookupParameter<IEvaluator>("Evaluator", "The operator which is used to evaluate new solutions."));
    6168      Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
     69      Parameters.Add(new ValueParameter<IntValue>("UpdateInterval", "The interval in which the operator should be applied.", new IntValue(2)));
     70      Parameters.Add(new LookupParameter<IntValue>("Generations", "Nr of generations."));
    6271
    6372      SimilarityCalculatorParameter.ValueChanged += new System.EventHandler(SimilarityCalculatorParameter_ValueChanged);
     
    8796      Operators.Add(solToPopAnalyzer);
    8897    }
     98
     99    public override IOperation Apply() {
     100      if (GenerationsParameter.ActualValue.Value % UpdateIntervalParameter.Value.Value == 0) {
     101        return base.Apply();
     102      } else {
     103        return base.BaseApply();
     104      }
     105    }
    89106  }
    90107}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/CombinedOperator.cs

    r8711 r9431  
    5454    public virtual void InitializeOperators() { }
    5555
     56    protected IOperation BaseApply() {
     57      return base.Apply();
     58    }
     59
    5660    public override IOperation Apply() {
    5761      if (Operators.Count == 0)
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/CrossoverPerformanceAnalyzer.cs

    r9252 r9431  
    9292    [Storable]
    9393    private int equalParents = 0;
     94    [Storable]
     95    private bool scalingFinished = false;
    9496    #endregion
    9597
     
    112114      successHelper = (DataTableHelper)original.successHelper.Clone(cloner);
    113115      equalParentsHelper = (DataTableHelper)original.equalParentsHelper.Clone(cloner);
     116      scalingFinished = original.scalingFinished;
    114117    }
    115118
     
    242245      }
    243246
    244       if (GenerationsParameter.ActualValue.Value == 1) {
     247      if (WorstKnownQualityParameter.ActualValue != null && !scalingFinished) {
     248        scalingFinished = true;
    245249        double bkQuality = BestKnownQualityParameter.ActualValue.Value;
    246250        double wkQuality = WorstKnownQualityParameter.ActualValue.Value;
     
    322326      successHelper.CleanUpAndCompressData();
    323327      equalParentsHelper.CleanUpAndCompressData();
     328      scalingFinished = false;
    324329    }
    325330  }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/DuplicateSolutionsAnalyzer.cs

    r9418 r9431  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Operators;
    2829using HeuristicLab.Optimization;
     
    5253      get { return (ILookupParameter<ItemCollection<IItem>>)Parameters["Operators"]; }
    5354    }
     55    public ValueParameter<IntValue> UpdateIntervalParameter {
     56      get { return (ValueParameter<IntValue>)Parameters["UpdateInterval"]; }
     57    }
     58    public ILookupParameter<IntValue> GenerationsParameter {
     59      get { return (ILookupParameter<IntValue>)Parameters["Generations"]; }
     60    }
    5461    #endregion
    5562
     
    7784      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
    7885      Parameters.Add(new LookupParameter<ItemCollection<IItem>>("Operators", "The operators and items that the problem provides to the algorithms."));
     86      Parameters.Add(new ValueParameter<IntValue>("UpdateInterval", "The interval in which the operator should be applied.", new IntValue(2)));
     87      Parameters.Add(new LookupParameter<IntValue>("Generations", "Nr of generations."));
    7988
    8089      chartingHelper = new DataTableHelper();
     
    93102      similarityChartHelper.InitializeChart(Results, "Average Similarity", new string[] { "Avg. Similarity per Generation" });
    94103
    95       var similarities = SimilarityCalculatorParameter.Value.CalculateSolutionCrowdSimilarity(ExecutionContext.Scope);
    96       List<double> similaritiesArr = new List<double>();
    97       int counter = 0;
    98       for (int i = 0; i < similarities.Length; i++) {
    99         for (int j = 0; j < similarities[i].Length; j++) {
    100           if (similarities[i][j] == 1.0 && i != j) {
    101             counter++;
    102             break;
     104      if (GenerationsParameter.ActualValue.Value % UpdateIntervalParameter.Value.Value == 0) {
     105        var similarities = SimilarityCalculatorParameter.Value.CalculateSolutionCrowdSimilarity(ExecutionContext.Scope);
     106        List<double> similaritiesArr = new List<double>();
     107        int counter = 0;
     108        for (int i = 0; i < similarities.Length; i++) {
     109          for (int j = 0; j < similarities[i].Length; j++) {
     110            if (similarities[i][j] == 1.0 && i != j) {
     111              counter++;
     112              break;
     113            }
     114          }
     115          for (int j = 0; j < similarities[i].Length; j++) {
     116            if (i != j) {
     117              similaritiesArr.Add(similarities[i][j]);
     118            }
    103119          }
    104120        }
    105         for (int j = 0; j < similarities[i].Length; j++) {
    106           if (i != j) {
    107             similaritiesArr.Add(similarities[i][j]);
    108           }
    109         }
     121
     122        similarityChartHelper.AddPoint(similaritiesArr.Average());
     123        chartingHelper.AddPoint(counter / (double)similarities.Length);
    110124      }
    111 
    112       similarityChartHelper.AddPoint(similaritiesArr.Average());
    113       chartingHelper.AddPoint(counter / (double)similarities.Length);
    114125      return base.Apply();
    115126    }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/MutationPerformanceAnalyzer.cs

    r9341 r9431  
    8484    [Storable]
    8585    private int cnt = 0, lastGeneration = 0, success = 0;
     86    [Storable]
     87    private bool scalingFinished = false;
    8688
    8789    [StorableConstructor]
     
    9597      lastGeneration = original.lastGeneration;
    9698      success = original.success;
     99      scalingFinished = original.scalingFinished;
    97100    }
    98101
     
    165168      }
    166169
    167       if (GenerationsParameter.ActualValue.Value == 1) {
     170      if (WorstKnownQualityParameter.ActualValue != null && !scalingFinished) {
     171        scalingFinished = true;
    168172        double bkQuality = BestKnownQualityParameter.ActualValue.Value;
    169173        double wkQuality = WorstKnownQualityParameter.ActualValue.Value;
     
    182186      }
    183187
     188
    184189      if (GenerationsParameter.ActualValue.Value != 0) {
    185190        if (GenerationsParameter.ActualValue.Value > lastGeneration) {
     
    208213      diversityPlotHelper.CleanUp();
    209214      successHelper.CleanUpAndCompressData();
     215      scalingFinished = false;
    210216    }
    211217
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/SelectionPressureAnalyzer.cs

    r9384 r9431  
    7171    [Storable]
    7272    private int lastGeneration = 0;
     73    [Storable]
     74    private bool scalingFinished = false;
    7375    #endregion
    7476
     
    8284      selIntensityPlot = (ScatterPlotHelper)original.selIntensityPlot.Clone(cloner);
    8385      SolutionQualityName = original.SolutionQualityName;
     86      scalingFinished = original.scalingFinished;
    8487    }
    8588
     
    136139        double quality = ParentsQualityParameter.ActualValue.Average(x => x.Value);
    137140
    138         if (GenerationsParameter.ActualValue.Value == 1) {
     141        if (WorstKnownQualityParameter.ActualValue != null && !scalingFinished) {
     142          scalingFinished = true;
    139143          double bkQuality = BestKnownQualityParameter.ActualValue.Value;
    140144          double wkQuality = WorstKnownQualityParameter.ActualValue.Value;
     
    181185      selPressurePlot.CleanUp();
    182186      selIntensityPlot.CleanUp();
     187      scalingFinished = false;
    183188    }
    184189
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/SolutionToPopulationAnalyzer.cs

    r9252 r9431  
    8080    [Storable]
    8181    private int lastGeneration = 0;
     82    [Storable]
     83    private bool scalingFinished = false;
    8284    #endregion
    8385
     
    9193      populationQualityPlot = (ScatterPlotHelper)original.populationQualityPlot.Clone(cloner);
    9294      qualityPlot = (ScatterPlotHelper)original.qualityPlot.Clone(cloner);
     95      scalingFinished = original.scalingFinished;
    9396    }
    9497
     
    162165        }
    163166
    164         if (GenerationsParameter.ActualValue.Value == 1) {
     167        if (WorstKnownQualityParameter.ActualValue != null && !scalingFinished) {
     168          scalingFinished = true;
    165169          double bkQuality = BestKnownQualityParameter.ActualValue.Value;
    166170          double wkQuality = WorstKnownQualityParameter.ActualValue.Value;
     
    210214      populationDiversityPlot.CleanUp();
    211215      qualityPlot.CleanUp();
     216      scalingFinished = false;
    212217    }
    213218
Note: See TracChangeset for help on using the changeset viewer.