Changeset 18031


Ignore:
Timestamp:
07/26/21 17:59:15 (10 months ago)
Author:
dpiringe
Message:

#3026

  • fixed wrong inheritance for RangedJsonItem
  • added VariableRanges automatic injection for RegressionProblemDataConverter
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface
Files:
2 edited

Legend:

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

    r17843 r18031  
    99using HeuristicLab.Data;
    1010using HeuristicLab.Parameters;
     11using HeuristicLab.Problems.DataAnalysis;
    1112using Newtonsoft.Json.Linq;
    1213
     
    2324    private const string VariableNames = "variableNames";
    2425    private const string InputVariables = "InputVariables";
     26    private const string VariableRanges = "VariableRanges";
    2527    private const string Rows = "rows";
    2628    private const string Value = "value";
     
    7880      SetTestPartition(regressionProblemData, testPartition);
    7981      SetTrainingPartition(regressionProblemData, trainingPartition);
    80 
     82      SetVariableRanges(regressionProblemData, dataset);
    8183    }
    8284
     
    166168        }
    167169      }
     170    }
     171
     172    private void SetVariableRanges(dynamic regressionProblemData, DoubleMatrixJsonItem item) {
     173      // TODO
     174      if (item != null) {
     175        object variableRanges = (object)regressionProblemData.VariableRanges; //IRegressionProblemData.cs
     176        IntervalCollection collection = new IntervalCollection();
     177        int count = 0;
     178        foreach (var column in item.ColumnNames) {
     179          collection.AddInterval(column, new Interval(item.Value[count].Min(), item.Value[count].Max()));
     180          count++;
     181        }
     182
     183        var variableRangesInfo = regressionProblemData.GetType().GetField(VariableRanges, flags);
     184        variableRangesInfo.SetValue(regressionProblemData, collection);
     185      }
     186    }
     187
     188    private void SetShapeConstraints() {
     189      // TODO
    168190    }
    169191    #endregion
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/RangedJsonItem.cs

    r17519 r18031  
    11using System;
    22using System.Collections.Generic;
     3using Newtonsoft.Json.Linq;
    34
    45namespace HeuristicLab.JsonInterface {
    5   public abstract class RangedJsonItem<T> : JsonItem, IRangedJsonItem<T>
     6  public abstract class RangedJsonItem<T> : IntervalRestrictedValueJsonItem<T>, IRangedJsonItem<T>
    67    where T : IComparable {
    78    public T MinValue { get; set; }
    89    public T MaxValue { get; set; }
    9     public T Minimum { get; set; }
    10     public T Maximum { get; set; }
    1110
    1211    protected override ValidationResult Validate() {
     
    1918
    2019    }
    21      
     20
     21    public override void SetJObject(JObject jObject) {
     22      var minValueProp = jObject[nameof(IRangedJsonItem<T>.MinValue)];
     23      if (minValueProp != null) MinValue = minValueProp.ToObject<T>();
     24
     25      var maxValueProp = jObject[nameof(IRangedJsonItem<T>.MaxValue)];
     26      if (maxValueProp != null) MaxValue = maxValueProp.ToObject<T>();
     27
     28      base.SetJObject(jObject);
     29    }
     30
    2231  }
    2332}
Note: See TracChangeset for help on using the changeset viewer.