Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3057_DynamicALPS/TestProblems/oesr-alps-master/HeuristicLab.Algorithms.OESRALPS/Analyzers/LayerQualityAnalyzer.cs

Last change on this file was 17479, checked in by kyang, 5 years ago

#3057

  1. upload the latest version of ALPS with SMS-EMOA
  2. upload the related dynamic test problems (dynamic, single-objective symbolic regression), written by David Daninel.
File size: 3.1 KB
RevLine 
[17479]1using HEAL.Attic;
2using HeuristicLab.Analysis;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
7using HeuristicLab.Optimization;
8using HeuristicLab.Parameters;
9using HeuristicLab.Problems.DataAnalysis;
10using HeuristicLab.Problems.DataAnalysis.Symbolic;
11using System;
12using System.Collections.Generic;
13using System.Linq;
14using System.Text;
15using System.Threading.Tasks;
16
17namespace HeuristicLab.Algorithms.OESRALPS.Analyzers
18{
19    [Item("LayerQualityAnalyzer", "An operator that analyzes the validation and training best solution for single objective problems on a layer.")]
20    [StorableType("31E292AA-95B2-4FA4-8544-CF2025B65822")]
21    public abstract class LayerQualityAnalyzer : SymbolicDataAnalysisSingleObjectiveAnalyzer
22    {
23        protected const string TrainingBestSolutionsParameterName = "Best training solution";
24        protected const string TrainingBestSolutionQualitiesParameterName = "Best training solution quality";
25
26        private const string ValidationBestSolutionParameterName = "Best validation solution";
27        private const string ValidationBestSolutionQualityParameterName = "Best validation solution quality";
28
29        private const string LayerBestSolutionChartName = "Layer best solution chart";
30
31        [StorableConstructor]
32        protected LayerQualityAnalyzer(StorableConstructorFlag _) : base(_) { }
33        protected LayerQualityAnalyzer(LayerQualityAnalyzer original, Cloner cloner)
34          : base(original, cloner)
35        {
36        }
37
38        protected LayerQualityAnalyzer() : base()
39        {
40        }
41
42        public override IOperation Apply()
43        {
44            var results = ResultCollection;
45            if (!results.ContainsKey(TrainingBestSolutionsParameterName)
46                || !results.ContainsKey(ValidationBestSolutionParameterName))
47                return base.Apply();
48
49            #region Add Parameter
50            if (!results.ContainsKey(LayerBestSolutionChartName))
51                results.Add(new Result(LayerBestSolutionChartName, new DataTable(LayerBestSolutionChartName)));
52
53            var layerQualityTable = (DataTable)results[LayerBestSolutionChartName].Value;
54
55            if (!layerQualityTable.Rows.ContainsKey(TrainingBestSolutionQualitiesParameterName))
56                layerQualityTable.Rows.Add(new DataRow(TrainingBestSolutionQualitiesParameterName));
57            if (!layerQualityTable.Rows.ContainsKey(ValidationBestSolutionQualityParameterName))
58                layerQualityTable.Rows.Add(new DataRow(ValidationBestSolutionQualityParameterName));
59            #endregion
60
61            layerQualityTable.Rows[TrainingBestSolutionQualitiesParameterName].Values.Add(((DoubleValue)results[TrainingBestSolutionQualitiesParameterName].Value).Value);
62            layerQualityTable.Rows[ValidationBestSolutionQualityParameterName].Values.Add(((DoubleValue)results[ValidationBestSolutionQualityParameterName].Value).Value);
63           
64            return base.Apply();
65        }
66    }
67}
Note: See TracBrowser for help on using the repository browser.