Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/12/21 15:24:18 (3 years ago)
Author:
dpiringe
Message:

#3026

  • added ResultFormatter to add an extra layer of result transformation logic (converting a result value to a string with a defined logic, e.g. MatlabResultFormatter for ISymbolicRegressionSolution)
  • extended the IResultJsonItem with two properties for result formatting
  • added a new control to selected a result formatter for a result value
  • refactored the Runner for the new result formatting process
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs

    r17828 r17834  
    3030      IAlgorithm algorithm = value as IAlgorithm;
    3131      foreach (var res in algorithm.Results) {
     32        item.AddChildren(root.Extract(res, root));
     33        /*
    3234        item.AddChildren(new ResultJsonItem() {
    3335          Name = res.Name,
    3436          Description = res.Description
    35         });
     37        });*/
    3638      }
    3739      item.AddChildren(root.Extract(algorithm.Problem, root));
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs

    r17828 r17834  
    2020    public abstract IJsonItem Extract(IItem value, IJsonItemConverter root);
    2121
     22
    2223    #region Helper
    23 
    2424    protected IItem Instantiate(Type type, params object[] args) =>
    2525      (IItem)Activator.CreateInstance(type,args);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs

    r17828 r17834  
    6666
    6767      // check data
    68       if(!dataset.RowNames.Any(x => x == targetVariable.Value)) {
     68      if(!dataset.ColumnNames.Any(x => x == targetVariable.Value)) {
    6969        throw new Exception($"The value of the target variable ('{targetVariable.Value}') has no matching row name value of the dataset.");
    7070      }
    7171
    7272      foreach(var v in allowedInputVariables.Value) {
    73         if(!dataset.RowNames.Any(x => x == v))
     73        if(!dataset.ColumnNames.Any(x => x == v))
    7474          throw new Exception($"The value of the input variable ('{v}') has no matching row name value of the dataset.");
    7575      }
     
    106106        var dictTmp = new Dictionary<string, IList>();
    107107        int c = 0;
    108         foreach (var col in item.RowNames) {
     108        foreach (var col in item.ColumnNames) {
    109109          dictTmp.Add(col, new List<double>(item.Value[c]));
    110110          ++c;
     
    116116
    117117        var variableNames = dataset.GetType().GetField(VariableNames, flags);
    118         variableNames.SetValue(dataset, item.RowNames);
     118        variableNames.SetValue(dataset, item.ColumnNames);
    119119
    120120        var dataInfo = dataset.GetType().GetField(VariableValues, flags);
     
    162162
    163163        // add list items and set their check state (based on allowed input variables)
    164         foreach(var i in matrix.RowNames) {
     164        foreach(var i in matrix.ColumnNames) {
    165165          bool isChecked = false;
    166166          foreach(var x in item.Value)
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs

    r17828 r17834  
    11using System;
    2 using System.Collections.Generic;
    32using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63using HeuristicLab.Core;
    74using HeuristicLab.Optimization;
     
    1411
    1512    public override bool CanConvertType(Type t) =>
    16       t.GetInterfaces().Any(x => x == typeof(IResultParameter));
     13      t.GetInterfaces().Any(x => x == ConvertableType);
    1714
    1815    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
    1916      IResultParameter res = value as IResultParameter;
     17      var formatter = ResultFormatter.ForType(res.DataType).Last();
    2018      return new ResultJsonItem() {
    2119        Name = res.ActualName,
    22         Description = res.Description
     20        Description = res.Description,
     21        ResultFormatterType = formatter.GetType().FullName,
     22        ValueType = res.DataType
    2323      };
    2424    }
Note: See TracChangeset for help on using the changeset viewer.