Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultCollectionPostProcessors/SymRegPythonPostProcessor.cs @ 18046

Last change on this file since 18046 was 18046, checked in by dpiringe, 3 years ago

#3026

  • added a first version of a new feature called ResultCollectionPostProcessors, which should transform/process the results of an optimizer run
    • created a new interface IResultCollectionPostProcessor
    • created a new class SymRegPythonPostProcessor, which formats all ISymbolicRegressionSolution with the usage of the SymbolicDataAnalysisExpressionPythonFormatter
    • changed the generation and instantiation of templates to handle this new feature
    • the template files contains a new area PostProcessors
    • added functionality in Runner to use these new type of result processing
    • added a new tab in ExportJsonDialog to configure PostProcessors
File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Collections;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Optimization;
10using HeuristicLab.Problems.DataAnalysis.Symbolic;
11using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
12using HEAL.Attic;
13
14namespace HeuristicLab.JsonInterface {
15  [StorableType("844F2887-B7A0-4BD4-89B8-F9155C65D214")]
16  public class SymRegPythonPostProcessor : Item, IResultCollectionPostProcessor {
17
18    [StorableConstructor]
19    protected SymRegPythonPostProcessor(StorableConstructorFlag _) : base(_) {
20    }
21
22    public SymRegPythonPostProcessor() { }
23    public SymRegPythonPostProcessor(SymRegPythonPostProcessor old, Cloner cloner) { }
24
25    public void Apply(IObservableDictionary<string, IItem> results, IDictionary<string, string> output) {
26      var formatter = new SymbolicDataAnalysisExpressionPythonFormatter();
27      foreach (var kvp in results) {
28        if (kvp.Value is ISymbolicRegressionSolution sol) {
29          output.Add(kvp.Key, formatter.Format(sol.Model.SymbolicExpressionTree));
30        }
31      }
32    }
33
34
35    public override IDeepCloneable Clone(Cloner cloner) {
36      return new SymRegPythonPostProcessor(this, cloner);
37    }
38  }
39}
Note: See TracBrowser for help on using the repository browser.