Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14584


Ignore:
Timestamp:
01/18/17 15:40:34 (7 years ago)
Author:
bburlacu
Message:

#2635: Improve reporting of statistics about rejected individuals.

Location:
branches/HeuristicLab.OSGAEvaluator
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator.sln

    r14428 r14584  
    77EndProject
    88Global
    9   GlobalSection(Performance) = preSolution
    10     HasPerformanceSessions = true
    11   EndGlobalSection
    129  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    1310    Debug|Any CPU = Debug|Any CPU
  • branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/OSGAPredictionCountsAnalyzer.cs

    r14428 r14584  
    1 using System.Linq;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Linq;
    223using HeuristicLab.Analysis;
    324using HeuristicLab.Common;
     
    4465
    4566      ResultCollection predictionResults;
    46       DataTable rejectedStatsTable, totalStatsTable, rejectedStatsPerGenerationTable, nonRejectedStatsPerGenerationTable;
     67      DataTable rejectedStatsTable, totalStatsTable, rejectedStatsPerGenerationTable;
    4768      if (!ResultCollection.ContainsKey("OS Prediction")) {
    4869        predictionResults = new ResultCollection();
     
    5879        predictionResults.Add(new Result("Total Stats", totalStatsTable));
    5980        rejectedStatsPerGenerationTable = new DataTable("Rejected Per Generation");
    60         nonRejectedStatsPerGenerationTable = new DataTable("Non Rejected Stats per Generation");
    6181        foreach (var rowName in rejectedStats.RowNames) {
    6282          rejectedStatsPerGenerationTable.Rows.Add(new DataRow(rowName) { VisualProperties = { StartIndexZero = true, ChartType = DataRowVisualProperties.DataRowChartType.Line, LineWidth = 1 } });
    6383          rejectedStatsPerGenerationTable.Rows[rowName].Values.Add(0d);
    64           nonRejectedStatsPerGenerationTable.Rows.Add(new DataRow(rowName) { VisualProperties = { StartIndexZero = true, ChartType = DataRowVisualProperties.DataRowChartType.Line, LineWidth = 1 } });
    65           nonRejectedStatsPerGenerationTable.Rows[rowName].Values.Add(0d);
    6684        }
    6785        predictionResults.Add(new Result("Rejected Stats Per Generation", rejectedStatsPerGenerationTable));
    68         predictionResults.Add(new Result("Non Rejected Stats Per Generation", nonRejectedStatsPerGenerationTable));
    6986        ResultCollection.Add(new Result("OS Prediction", predictionResults));
    7087      } else {
     
    7390        totalStatsTable = (DataTable)predictionResults["Total Stats"].Value;
    7491        rejectedStatsPerGenerationTable = (DataTable)predictionResults["Rejected Stats Per Generation"].Value;
    75         nonRejectedStatsPerGenerationTable = (DataTable)predictionResults["Non Rejected Stats Per Generation"].Value;
    7692      }
    7793
     
    88104        var sum = row.Values.Sum();
    89105        row.Values.Add(totalStats[i, 0] - sum);
    90         row = nonRejectedStatsPerGenerationTable.Rows[rowName];
    91         sum = row.Values.Sum();
    92         row.Values.Add(totalStats[i, 1] - sum);
    93106        ++i;
    94107      }
  • branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs

    r14428 r14584  
    6363      get { return (IValueParameter<BoolValue>)Parameters[AggregateStatisticsParameterName]; }
    6464    }
    65     public IValueParameter<IntMatrix> RejectedStatsParameter {
    66       get { return (IValueParameter<IntMatrix>)Parameters["RejectedStats"]; }
    67     }
    68     public IValueParameter<IntMatrix> NotRejectedStatsParameter {
    69       get { return (IValueParameter<IntMatrix>)Parameters["TotalStats"]; }
    70     }
    7165    public IValueLookupParameter<DoubleValue> ComparisonFactorParameter {
    7266      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
     
    106100      set { RelativeFitnessEvaluationIntervalSizeParameter.Value.Value = value; }
    107101    }
    108     public IntMatrix RejectedStats {
    109       get { return RejectedStatsParameter.Value; }
    110       set { RejectedStatsParameter.Value = value; }
    111     }
    112     public IntMatrix TotalStats {
    113       get { return NotRejectedStatsParameter.Value; }
    114       set { NotRejectedStatsParameter.Value = value; }
    115     }
     102
    116103    #endregion
    117104
     
    120107    }
    121108
     109    // keep track of statistics
    122110    public double AdjustedEvaluatedSolutions { get; set; }
     111    public IntMatrix RejectedStats { get; set; }
     112    public IntMatrix TotalStats { get; set; }
    123113
    124114    public SymbolicRegressionSingleObjectiveOsgaEvaluator() {
     
    128118      Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName));
    129119      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ParentQualities") { ActualName = "Quality" });
    130       Parameters.Add(new ValueParameter<IntMatrix>("RejectedStats", new IntMatrix()));
    131       Parameters.Add(new ValueParameter<IntMatrix>("TotalStats", new IntMatrix()));
    132120      Parameters.Add(new ValueParameter<BoolValue>(AggregateStatisticsParameterName, new BoolValue(false)));
    133121      Parameters.Add(new LookupParameter<DoubleValue>(ActualSelectionPressureParameterName));
     
    135123      Parameters.Add(new FixedValueParameter<BoolValue>(UseFixedEvaluationIntervalsParameterName, new BoolValue(false)));
    136124      Parameters.Add(new FixedValueParameter<BoolValue>(PreserveResultCompatibilityParameterName, new BoolValue(false)));
     125
     126      RejectedStats = new IntMatrix();
     127      TotalStats = new IntMatrix();
    137128    }
    138129
     
    153144
    154145    [StorableConstructor]
    155     protected SymbolicRegressionSingleObjectiveOsgaEvaluator(bool deserializing) : base(deserializing) { }
    156 
    157     protected SymbolicRegressionSingleObjectiveOsgaEvaluator(SymbolicRegressionSingleObjectiveOsgaEvaluator original, Cloner cloner) : base(original, cloner) { }
     146    protected SymbolicRegressionSingleObjectiveOsgaEvaluator(bool deserializing) : base(deserializing) {
     147      TotalStats = new IntMatrix();
     148      RejectedStats = new IntMatrix();
     149    }
     150
     151    protected SymbolicRegressionSingleObjectiveOsgaEvaluator(SymbolicRegressionSingleObjectiveOsgaEvaluator original,
     152      Cloner cloner) : base(original, cloner) {
     153      if (original.TotalStats != null)
     154        TotalStats = cloner.Clone(original.TotalStats);
     155
     156      if (original.RejectedStats != null)
     157        RejectedStats = cloner.Clone(original.RejectedStats);
     158    }
    158159
    159160    public override IDeepCloneable Clone(Cloner cloner) {
     
    262263            bool predictedRejected = false;
    263264
    264             calculatedRows = 0;
    265             foreach (var q in qualityPerInterval) {
     265            int i;
     266
     267            for (i = 0; i < qualityPerInterval.Count; ++i) {
     268              var q = qualityPerInterval[i];
    266269              if (double.IsNaN(q) || !(q > threshold)) {
    267270                predictedRejected = true;
     
    269272                break;
    270273              }
    271               ++calculatedRows;
    272274            }
    273275
     
    275277
    276278            if (RejectedStats.Rows == 0 || TotalStats.Rows == 0) {
    277               RejectedStats = new IntMatrix(2, qualityPerInterval.Count);
     279              RejectedStats = new IntMatrix(2, qualityPerInterval.Count + 1);
    278280              RejectedStats.RowNames = new[] { "Predicted", "Actual" };
    279281              RejectedStats.ColumnNames = Enumerable.Range(1, RejectedStats.Columns).Select(x => string.Format("0-{0}", Math.Min(trainingEnd, x * interval)));
    280               TotalStats = new IntMatrix(2, 2);
     282              TotalStats = new IntMatrix(2, 1);
    281283              TotalStats.RowNames = new[] { "Predicted", "Actual" };
    282               TotalStats.ColumnNames = new[] { "Rejected", "Not Rejected" };
    283             }
    284             // gather some statistics
    285             if (predictedRejected) {
    286               RejectedStats[0, calculatedRows]++;
    287               TotalStats[0, 0]++;
     284              TotalStats.ColumnNames = new[] { "Rejected" };
     285            }
     286
     287            if (actuallyRejected) {
     288              TotalStats[0, 0]++; // prediction true
     289              TotalStats[1, 0]++;
     290              RejectedStats[0, i]++;
     291              RejectedStats[1, i]++;
    288292            } else {
    289               TotalStats[0, 1]++;
    290             }
    291             if (actuallyRejected) {
    292               TotalStats[1, 0]++;
    293             } else {
    294               TotalStats[1, 1]++;
    295             }
    296             if (predictedRejected && actuallyRejected) {
    297               RejectedStats[1, calculatedRows]++;
     293              if (predictedRejected) {
     294                RejectedStats[0, i]++;
     295                TotalStats[0, 0]++;
     296              }
    298297            }
    299298          }
Note: See TracChangeset for help on using the changeset viewer.