Changeset 14584
- Timestamp:
- 01/18/17 15:40:34 (8 years ago)
- Location:
- branches/HeuristicLab.OSGAEvaluator
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator.sln
r14428 r14584 7 7 EndProject 8 8 Global 9 GlobalSection(Performance) = preSolution10 HasPerformanceSessions = true11 EndGlobalSection12 9 GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 10 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 22 using System.Linq; 2 23 using HeuristicLab.Analysis; 3 24 using HeuristicLab.Common; … … 44 65 45 66 ResultCollection predictionResults; 46 DataTable rejectedStatsTable, totalStatsTable, rejectedStatsPerGenerationTable , nonRejectedStatsPerGenerationTable;67 DataTable rejectedStatsTable, totalStatsTable, rejectedStatsPerGenerationTable; 47 68 if (!ResultCollection.ContainsKey("OS Prediction")) { 48 69 predictionResults = new ResultCollection(); … … 58 79 predictionResults.Add(new Result("Total Stats", totalStatsTable)); 59 80 rejectedStatsPerGenerationTable = new DataTable("Rejected Per Generation"); 60 nonRejectedStatsPerGenerationTable = new DataTable("Non Rejected Stats per Generation");61 81 foreach (var rowName in rejectedStats.RowNames) { 62 82 rejectedStatsPerGenerationTable.Rows.Add(new DataRow(rowName) { VisualProperties = { StartIndexZero = true, ChartType = DataRowVisualProperties.DataRowChartType.Line, LineWidth = 1 } }); 63 83 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);66 84 } 67 85 predictionResults.Add(new Result("Rejected Stats Per Generation", rejectedStatsPerGenerationTable)); 68 predictionResults.Add(new Result("Non Rejected Stats Per Generation", nonRejectedStatsPerGenerationTable));69 86 ResultCollection.Add(new Result("OS Prediction", predictionResults)); 70 87 } else { … … 73 90 totalStatsTable = (DataTable)predictionResults["Total Stats"].Value; 74 91 rejectedStatsPerGenerationTable = (DataTable)predictionResults["Rejected Stats Per Generation"].Value; 75 nonRejectedStatsPerGenerationTable = (DataTable)predictionResults["Non Rejected Stats Per Generation"].Value;76 92 } 77 93 … … 88 104 var sum = row.Values.Sum(); 89 105 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);93 106 ++i; 94 107 } -
branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs
r14428 r14584 63 63 get { return (IValueParameter<BoolValue>)Parameters[AggregateStatisticsParameterName]; } 64 64 } 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 }71 65 public IValueLookupParameter<DoubleValue> ComparisonFactorParameter { 72 66 get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; } … … 106 100 set { RelativeFitnessEvaluationIntervalSizeParameter.Value.Value = value; } 107 101 } 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 116 103 #endregion 117 104 … … 120 107 } 121 108 109 // keep track of statistics 122 110 public double AdjustedEvaluatedSolutions { get; set; } 111 public IntMatrix RejectedStats { get; set; } 112 public IntMatrix TotalStats { get; set; } 123 113 124 114 public SymbolicRegressionSingleObjectiveOsgaEvaluator() { … … 128 118 Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName)); 129 119 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()));132 120 Parameters.Add(new ValueParameter<BoolValue>(AggregateStatisticsParameterName, new BoolValue(false))); 133 121 Parameters.Add(new LookupParameter<DoubleValue>(ActualSelectionPressureParameterName)); … … 135 123 Parameters.Add(new FixedValueParameter<BoolValue>(UseFixedEvaluationIntervalsParameterName, new BoolValue(false))); 136 124 Parameters.Add(new FixedValueParameter<BoolValue>(PreserveResultCompatibilityParameterName, new BoolValue(false))); 125 126 RejectedStats = new IntMatrix(); 127 TotalStats = new IntMatrix(); 137 128 } 138 129 … … 153 144 154 145 [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 } 158 159 159 160 public override IDeepCloneable Clone(Cloner cloner) { … … 262 263 bool predictedRejected = false; 263 264 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]; 266 269 if (double.IsNaN(q) || !(q > threshold)) { 267 270 predictedRejected = true; … … 269 272 break; 270 273 } 271 ++calculatedRows;272 274 } 273 275 … … 275 277 276 278 if (RejectedStats.Rows == 0 || TotalStats.Rows == 0) { 277 RejectedStats = new IntMatrix(2, qualityPerInterval.Count );279 RejectedStats = new IntMatrix(2, qualityPerInterval.Count + 1); 278 280 RejectedStats.RowNames = new[] { "Predicted", "Actual" }; 279 281 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); 281 283 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]++; 288 292 } 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 } 298 297 } 299 298 }
Note: See TracChangeset
for help on using the changeset viewer.