Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8287


Ignore:
Timestamp:
07/12/12 06:37:58 (12 years ago)
Author:
ascheibe
Message:

#1886 worked on analyzers

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

Legend:

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

    r8268 r8287  
    9999      var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultParameterName].Value;
    100100      var subtours = AlgorithmBehaviorHelpers.ExtractSubtours(BestSolution.Permutation, 2);
     101      List<Point2D<double>> points = new List<Point2D<double>>();
     102
    101103
    102104      Dictionary<IntArray, Dictionary<int, List<int>>> occurences = new Dictionary<IntArray, Dictionary<int, List<int>>>();
     
    106108
    107109      for (int i = 0; i < GenerationsParameter.ActualValue.Value; i++) {
    108         var individuals = graph.Values.Where(x => x.Rank.Contains(i) || x.Rank.Contains(i + 0.5));
     110        var individuals = graph.Values.Where(x => x.Rank.Contains(i));
     111        int k = 0;
    109112        foreach (var subtour in subtours) {
    110113          int cnt = 0;
    111114          double quality = 0.0;
     115          double min = double.MaxValue;
     116          double max = double.MinValue;
    112117          foreach (var individual in individuals) {
    113118            var ind = (IntArray)individual.Data;
    114119            if (AlgorithmBehaviorHelpers.IsSubtour(subtour, (Permutation)ind)) {
    115120              cnt++;
    116               quality += TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, (Permutation)individual.Data);
     121              double tmp = TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, (Permutation)individual.Data);
     122              if (tmp < min) min = tmp;
     123              if (tmp > max) max = tmp;
     124              quality += tmp;
    117125            }
    118126          }
     
    122130          if (cnt != 0) {
    123131            double avgQuality = quality / cnt;
    124             double qualityRatio = avgQuality / Qualities.Rows["CurrentAverageQuality"].Values[i] * 100;
     132            double qualityRatio = avgQuality / Qualities.Rows["CurrentAverageQuality"].Values[i];
    125133            vals.Add((int)qualityRatio);
     134
     135            points.Add(new Point2D<double>(k++, qualityRatio));
    126136          }
    127137          occurences[subtour][i] = vals;
    128138        }
     139
     140        var plot = new ScatterPlot("Contained Edges of Best Found Solution and Relative Solution Qualtiy", null);
     141        plot.VisualProperties.XAxisTitle = "Contained Alleles of Best Found Solution";
     142        plot.VisualProperties.YAxisTitle = "Relative Solution Quality";
     143        plot.VisualProperties.XAxisMinimumAuto = false;
     144        plot.VisualProperties.XAxisMinimumFixedValue = 0.0;
     145        plot.VisualProperties.XAxisMaximumAuto = false;
     146        plot.VisualProperties.XAxisMaximumFixedValue = subtours.Count;
     147        /*plot.VisualProperties.YAxisMinimumAuto = false;
     148        plot.VisualProperties.YAxisMinimumFixedValue = 0.0;
     149        plot.VisualProperties.YAxisMaximumAuto = false;
     150        plot.VisualProperties.YAxisMaximumFixedValue = 1.0;*/
     151        var row = new ScatterPlotDataRow("Solutions of Current Generation", null, points);
     152        row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle;
     153        row.VisualProperties.PointSize = 5;
     154        plot.Rows.Add(row);
     155
     156        if (!Results.ContainsKey("Scatter Plot"))
     157          Results.Add(new Result("Scatter Plot", plot));
     158        else
     159          Results["Scatter Plot"].Value = plot;
     160
     161        if (!Results.ContainsKey("Scatter Plot History")) {
     162          Results.Add(new Result("Scatter Plot History", new ScatterPlotHistory()));
     163        }
     164        ((ScatterPlotHistory)Results["Scatter Plot History"].Value).Add(plot);
     165        points.Clear();
    129166      }
    130167
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/DistinctSolutionsAnalyzer.cs

    r8281 r8287  
    4444    private const string SchemataParameterName = "Schemata";
    4545    private const string DistinctSolutionsInGenerationsMatrixParameterName = "DistinctSolutionsInGenerationsMatrix";
     46    private const string OverallDistinctSolutionsParameterName = "OverallDistinctSolutions";
    4647    private const string QualitiesParameterName = "Qualities";
    4748    private const string DistanceMatrixParameterName = "DistanceMatrix";
     
    4950    private const string PopulationSizeParameterName = "PopulationSize";
    5051    private const string BestSolutionParameterName = "Best TSP Solution";
     52    private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions";
    5153
    5254    #region IAnalyzer Members
     
    8183      get { return ((HeuristicLab.Analysis.DataTable)ResultsParameter.ActualValue[QualitiesParameterName].Value); }
    8284    }
     85    public IntValue EvaluatedSolutions {
     86      get { return ((IntValue)ResultsParameter.ActualValue[EvaluatedSolutionsParameterName].Value); }
     87    }
    8388    public PathTSPTour BestSolution {
    8489      get { return ((PathTSPTour)ResultsParameter.ActualValue[BestSolutionParameterName].Value); }
     
    105110      int generations = GenerationsParameter.ActualValue.Value;
    106111      int popSize = PopulationSizeParameter.ActualValue.Value;
     112      int evaluatedSolutions = EvaluatedSolutions.Value;
     113      int overallDistinctSolutions = 0;
    107114
    108115      Dictionary<int, int> distinctSolsInGen = new Dictionary<int, int>();
     
    111118        var individuals = graph.Values.Where(x => x.Rank.Contains(i));
    112119        distinctSolsInGen.Add(i, individuals.Count());
     120        overallDistinctSolutions += individuals.Count();
    113121      }
    114122
     
    122130
    123131      Results.Add(new Result(DistinctSolutionsInGenerationsMatrixParameterName, dt));
     132      Results.Add(new Result(OverallDistinctSolutionsParameterName, new DoubleValue(evaluatedSolutions / (double)overallDistinctSolutions)));
    124133      return base.Apply();
    125134    }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/HeuristicLab.Analysis.AlgorithmBehavior-3.3.csproj

    r8277 r8287  
    102102    <Compile Include="Analyzers\AlleleOccurencesInGenerationsAnalyzer.cs" />
    103103    <Compile Include="Analyzers\ConvergenceSpeedAnalyzer.cs" />
     104    <Compile Include="Analyzers\AlleleOccurencesInGenerationsPerIndAnalyzer.cs" />
    104105    <Compile Include="Analyzers\DistinctSolutionsAnalyzer.cs" />
    105106    <Compile Include="Creators\BestIndividualSchemataCreator.cs" />
Note: See TracChangeset for help on using the changeset viewer.