Changeset 17519


Ignore:
Timestamp:
04/27/20 15:53:26 (3 months ago)
Author:
dpiringe
Message:

#3026:

  • added error output for failed runner initialization
  • reorganised some final view models
  • TargetedJsonItemType (in JsonItemVMBase) now automatically returns the type of the defined JsonItem
  • code cleanup
  • refactored RegressionProblemDataConverter
  • added lots of comments
  • added new view for StringArrayJsonItem
  • added new UI component for concrete restricted items and used it in JsonItemConcreteItemArrayControl and JsonItemValidValuesControl
Location:
branches/3026_IntegrationIntoSymSpace
Files:
8 added
53 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs

    r17477 r17519  
    1616  internal static class Runner {
    1717    internal static void Run(string template, string config, string outputFile) {
    18       InstantiatorResult instantiatorResult = JsonTemplateInstantiator.Instantiate(template, config);
    19       IOptimizer optimizer = instantiatorResult.Optimizer;
    20       IEnumerable<IResultJsonItem> configuredResultItem = instantiatorResult.ConfiguredResultItems;
     18      try {
     19        InstantiatorResult instantiatorResult = JsonTemplateInstantiator.Instantiate(template, config);
     20        IOptimizer optimizer = instantiatorResult.Optimizer;
     21        IEnumerable<IResultJsonItem> configuredResultItem = instantiatorResult.ConfiguredResultItems;
    2122
    22       optimizer.Runs.Clear();
    23       if(optimizer is EngineAlgorithm e)
    24         e.Engine = new ParallelEngine.ParallelEngine();
    25      
    26       Task task = optimizer.StartAsync();
    27       while(!task.IsCompleted) {
     23        optimizer.Runs.Clear();
     24        if (optimizer is EngineAlgorithm e)
     25          e.Engine = new ParallelEngine.ParallelEngine();
     26
     27        Task task = optimizer.StartAsync();
     28        while (!task.IsCompleted) {
     29          WriteResultsToFile(outputFile, optimizer, configuredResultItem);
     30          Thread.Sleep(100);
     31        }
     32
    2833        WriteResultsToFile(outputFile, optimizer, configuredResultItem);
    29         Thread.Sleep(100);
     34      } catch (Exception e) {
     35        File.WriteAllText(outputFile, e.Message + "\n\n\n\n" + e.StackTrace);
    3036      }
    31      
    32       WriteResultsToFile(outputFile, optimizer, configuredResultItem);
    3337    }
    3438
     
    4751          if (configuredResults.Contains(res.Key)) {
    4852            if (res.Value is ISymbolicRegressionSolution solution) {
     53              /* TEST */
     54              var csFormatter = new CSharpSymbolicExpressionTreeStringFormatter();
     55              File.WriteAllText(@"C:\Workspace\output\csFormatted.cs", csFormatter.Format(solution.Model.SymbolicExpressionTree));
     56              /* END TEST */
    4957              var formatter = new SymbolicDataAnalysisExpressionMATLABFormatter();
    5058              var x = formatter.Format(solution.Model.SymbolicExpressionTree);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj

    r17471 r17519  
    108108    </Compile>
    109109    <Compile Include="ViewModels\ArrayValueVM.cs" />
     110    <Compile Include="ViewModels\DoubleVMs.cs" />
     111    <Compile Include="ViewModels\IntVMs.cs" />
    110112    <Compile Include="ViewModels\JsonItemVMBase.cs" />
    111113    <Compile Include="ViewModels\LookupJsonItemVM.cs" />
     
    117119    <Compile Include="ViewModels\StringValueVM.cs" />
    118120    <Compile Include="ViewModels\ValueLookupJsonItemVM.cs" />
     121    <Compile Include="Shared\ConcreteItemsRestrictor.cs">
     122      <SubType>UserControl</SubType>
     123    </Compile>
     124    <Compile Include="Shared\ConcreteItemsRestrictor.Designer.cs">
     125      <DependentUpon>ConcreteItemsRestrictor.cs</DependentUpon>
     126    </Compile>
    119127    <Compile Include="Views\ExportJsonDialog.cs">
    120128      <SubType>Form</SubType>
     
    124132    </Compile>
    125133    <Compile Include="FileManager.cs" />
     134    <Compile Include="Views\JsonItemConcreteItemArrayControl.cs">
     135      <SubType>UserControl</SubType>
     136    </Compile>
     137    <Compile Include="Views\JsonItemConcreteItemArrayControl.Designer.cs">
     138      <DependentUpon>JsonItemConcreteItemArrayControl.cs</DependentUpon>
     139    </Compile>
    126140    <Compile Include="Views\JsonItemMultiValueControl.cs">
    127141      <SubType>UserControl</SubType>
     
    224238      <DependentUpon>NumericRangeControl.cs</DependentUpon>
    225239    </EmbeddedResource>
     240    <EmbeddedResource Include="Shared\ConcreteItemsRestrictor.resx">
     241      <DependentUpon>ConcreteItemsRestrictor.cs</DependentUpon>
     242    </EmbeddedResource>
    226243    <EmbeddedResource Include="Views\ExportJsonDialog.resx">
    227244      <DependentUpon>ExportJsonDialog.cs</DependentUpon>
     245    </EmbeddedResource>
     246    <EmbeddedResource Include="Views\JsonItemConcreteItemArrayControl.resx">
     247      <DependentUpon>JsonItemConcreteItemArrayControl.cs</DependentUpon>
    228248    </EmbeddedResource>
    229249    <EmbeddedResource Include="Views\JsonItemMultiValueControl.resx">
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs

    r17484 r17519  
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1010
    11   public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> {
    12     public override Type TargetedJsonItemType => typeof(DoubleArrayJsonItem);
     11 
    1312
    14     protected override double MinTypeValue => double.MinValue;
    1513
    16     protected override double MaxTypeValue => double.MaxValue;
    1714
    18     public override UserControl Control =>
    19       new JsonItemDoubleArrayValueControl(this);
    20    
    21     public override double[] Value {
    22       get => Item.Value;
    23       set {
    24         Item.Value = value;
    25         OnPropertyChange(this, nameof(Value));
    26       }
    27     }
    28   }
    29 
    30   public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> {
    31     public override Type TargetedJsonItemType => typeof(IntArrayJsonItem);
     15  /*
     16  public class StringArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> {
     17    public override Type TargetedJsonItemType => typeof(StringArrayJsonItem);
    3218
    3319    protected override int MinTypeValue => int.MinValue;
     
    3723    public override UserControl Control =>
    3824      new JsonItemBaseControl(this, new JsonItemIntArrayValueControl(this));
    39    
     25
    4026    public override int[] Value {
    4127      get => Item.Value;
     
    4632    }
    4733  }
     34  */
     35
    4836
    4937  public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IArrayJsonItemVM
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17477 r17519  
    99
    1010namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    11   public abstract class JsonItemVMBase<JsonItemType> : IJsonItemVM<JsonItemType>
     11  public abstract class JsonItemVMBase<JsonItemType> : IJsonItemVM<JsonItemType> //TODO: RENAME, oder vlt JsonItems direkt als VM?
    1212    where JsonItemType : class, IJsonItem
    1313  {
     
    5858    }
    5959
    60     public abstract Type TargetedJsonItemType { get; }
     60    public virtual Type TargetedJsonItemType => typeof(JsonItemType);
    6161    public abstract UserControl Control { get; }
    6262
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/LookupJsonItemVM.cs

    r17473 r17519  
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    99  public class LookupJsonItemVM : JsonItemVMBase<LookupJsonItem>, ILookupJsonItemVM {
    10     public override Type TargetedJsonItemType => typeof(LookupJsonItem);
    1110
    1211    public override UserControl Control => new LookupJsonItemControl(this);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs

    r17484 r17519  
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1010
    11   public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> {
    12     public override Type TargetedJsonItemType => typeof(DoubleMatrixJsonItem);
    13     public override UserControl Control =>
    14       new JsonItemDoubleMatrixValueControl(this);
    15 
    16     public override double[][] Value {
    17       get => Item.Value;
    18       set {
    19         Item.Value = value;
    20         OnPropertyChange(this, nameof(Value));
    21       }
    22     }
    23 
    24     protected override double MinTypeValue => double.MinValue;
    25 
    26     protected override double MaxTypeValue => double.MaxValue;
    27   }
    2811
    2912  public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IMatrixJsonItemVM
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs

    r17473 r17519  
    88
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    10 
    11   public class IntRangeVM : RangeVM<int, IntRangeJsonItem> {
    12     public override Type TargetedJsonItemType => typeof(IntRangeJsonItem);
    13 
    14     protected override int MinTypeValue => int.MinValue;
    15 
    16     protected override int MaxTypeValue => int.MaxValue;
    17 
    18     public override UserControl Control =>
    19       new JsonItemRangeControl(this);
    20   }
    21 
    22   public class DoubleRangeVM : RangeVM<double, DoubleRangeJsonItem> {
    23     public override Type TargetedJsonItemType => typeof(DoubleRangeJsonItem);
    24 
    25     protected override double MinTypeValue => double.MinValue;
    26 
    27     protected override double MaxTypeValue => double.MaxValue;
    28 
    29     public override UserControl Control =>
    30       new JsonItemRangeControl(this);
    31   }
    3210
    3311  public abstract class RangeVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs

    r17473 r17519  
    88
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    10   public class IntValueVM : SingleValueVM<int, IntJsonItem> {
    11     public override Type TargetedJsonItemType => typeof(IntJsonItem);
    12 
    13     protected override int MinTypeValue => int.MinValue;
    14     protected override int MaxTypeValue => int.MaxValue;
    15 
    16     public override UserControl Control =>
    17       new JsonItemIntValueControl(this);
    18   }
    19 
    20   public class DoubleValueVM : SingleValueVM<double, DoubleJsonItem> {
    21     public override Type TargetedJsonItemType => typeof(DoubleJsonItem);
    22 
    23     protected override double MinTypeValue => double.MinValue;
    24     protected override double MaxTypeValue => double.MaxValue;
    25 
    26     public override UserControl Control =>
    27        new JsonItemDoubleValueControl(this);
    28   }
    2910
    3011  public class BoolValueVM : JsonItemVMBase<BoolJsonItem> {
    31     public override Type TargetedJsonItemType => typeof(BoolJsonItem);
    3212
    3313    public bool Value {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs

    r17473 r17519  
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1010  public class StringValueVM : JsonItemVMBase<StringJsonItem> {
    11     public override Type TargetedJsonItemType => typeof(StringJsonItem);
    1211    public override UserControl Control =>
    1312       new JsonItemValidValuesControl(this);
     
    3736      }
    3837    }
     38  }
    3939
     40  public class StringArrayVM : JsonItemVMBase<StringArrayJsonItem> {
     41    public override UserControl Control =>
     42       new JsonItemConcreteItemArrayControl(this);
     43
     44    public string[] Value {
     45      get => Item.Value;
     46      set {
     47        Item.Value = value;
     48        OnPropertyChange(this, nameof(Value));
     49      }
     50    }
     51
     52    public IEnumerable<string> Range {
     53      get => Item.ConcreteRestrictedItems;
     54      set {
     55        Item.ConcreteRestrictedItems = value;
     56        OnPropertyChange(this, nameof(Range));
     57      }
     58    }
    4059  }
    4160}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs

    r17485 r17519  
    8080      int cols = matrix.Length;
    8181      int rows = matrix.Max(x => x.Length);
    82 
     82     
    8383      Matrix = matrix;
    8484      Columns = cols;
     
    250250                                            typeof(T),
    251251                                            System.Globalization.CultureInfo.InvariantCulture);
    252       //Save(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex);
    253252      Save();
    254253    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.Designer.cs

    r17471 r17519  
    2525    private void InitializeComponent() {
    2626      this.components = new System.ComponentModel.Container();
    27       this.tableOptions = new System.Windows.Forms.TableLayoutPanel();
    2827      this.comboBoxValues = new System.Windows.Forms.ComboBox();
    2928      this.label2 = new System.Windows.Forms.Label();
    3029      this.groupBoxRange = new System.Windows.Forms.GroupBox();
     30      this.concreteItemsRestrictor = new HeuristicLab.JsonInterface.OptimizerIntegration.ConcreteItemsRestrictor();
    3131      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    3232      this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
     
    3737      this.tableLayoutPanel2.SuspendLayout();
    3838      this.SuspendLayout();
    39       //
    40       // tableOptions
    41       //
    42       this.tableOptions.AutoScroll = true;
    43       this.tableOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    44       this.tableOptions.ColumnCount = 2;
    45       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    46       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
    47       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    48       this.tableOptions.Dock = System.Windows.Forms.DockStyle.Fill;
    49       this.tableOptions.Location = new System.Drawing.Point(3, 16);
    50       this.tableOptions.Name = "tableOptions";
    51       this.tableOptions.RowCount = 1;
    52       this.tableOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
    53       this.tableOptions.Size = new System.Drawing.Size(494, 217);
    54       this.tableOptions.TabIndex = 12;
    5539      //
    5640      // comboBoxValues
     
    7963      // groupBoxRange
    8064      //
    81       this.groupBoxRange.Controls.Add(this.tableOptions);
     65      this.groupBoxRange.Controls.Add(this.concreteItemsRestrictor);
    8266      this.groupBoxRange.Dock = System.Windows.Forms.DockStyle.Fill;
    8367      this.groupBoxRange.Location = new System.Drawing.Point(0, 22);
     
    8872      this.groupBoxRange.TabStop = false;
    8973      this.groupBoxRange.Text = "Range";
     74      //
     75      // concreteItemsRestrictor
     76      //
     77      this.concreteItemsRestrictor.Dock = System.Windows.Forms.DockStyle.Fill;
     78      this.concreteItemsRestrictor.Location = new System.Drawing.Point(3, 16);
     79      this.concreteItemsRestrictor.Margin = new System.Windows.Forms.Padding(0);
     80      this.concreteItemsRestrictor.Name = "concreteItemsRestrictor";
     81      this.concreteItemsRestrictor.Size = new System.Drawing.Size(494, 217);
     82      this.concreteItemsRestrictor.TabIndex = 0;
    9083      //
    9184      // errorProvider
     
    122115      this.tableLayoutPanel2.RowCount = 1;
    123116      this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
    124       this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
     117      this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F));
    125118      this.tableLayoutPanel2.Size = new System.Drawing.Size(500, 22);
    126119      this.tableLayoutPanel2.TabIndex = 19;
     
    146139
    147140    #endregion
    148     private System.Windows.Forms.TableLayoutPanel tableOptions;
    149141    private System.Windows.Forms.ComboBox comboBoxValues;
    150142    private System.Windows.Forms.Label label2;
     
    153145    private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
    154146    private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
     147    private ConcreteItemsRestrictor concreteItemsRestrictor;
    155148  }
    156149}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs

    r17473 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.ComponentModel;
     1using System.Collections.Generic;
    42using System.Drawing;
    5 using System.Data;
    63using System.Linq;
    7 using System.Text;
    8 using System.Threading.Tasks;
    94using System.Windows.Forms;
    105
     
    1813      VM = vm;
    1914      if (VM.Item.ConcreteRestrictedItems != null) {
    20         foreach (var i in VM.Item.ConcreteRestrictedItems)
    21           SetupOption(i);
     15        concreteItemsRestrictor.OnChecked += AddComboOption;
     16        concreteItemsRestrictor.OnUnchecked += RemoveComboOption;
     17        concreteItemsRestrictor.Init(VM.Item.ConcreteRestrictedItems);
    2218        comboBoxValues.DataBindings.Add("SelectedItem", VM, nameof(StringValueVM.Value));
    2319      } else {
    24         comboBoxValues.Hide();
    2520        groupBoxRange.Hide();
    2621        TextBox tb = new TextBox();
    27         this.Controls.Add(tb);
     22        tableLayoutPanel2.Controls.Remove(comboBoxValues);
     23        tableLayoutPanel2.Controls.Add(tb, 1, 0);
     24
    2825        tb.Location = comboBoxValues.Location;
    29         tb.Size = comboBoxValues.Size;
    30         tb.Anchor = comboBoxValues.Anchor;
    31         tb.Dock = comboBoxValues.Dock;
     26        tb.Margin = new Padding(0);
     27        tb.Size = new Size(comboBoxValues.Size.Width, 20);
     28        tb.Anchor = AnchorStyles.Top | AnchorStyles.Left;
     29        tb.Dock = DockStyle.Fill;
     30
    3231        tb.DataBindings.Add("Text", VM, nameof(StringValueVM.Value));
    3332        tb.Show();
    3433      }
    3534    }
    36    
    37     private void SetupOption(string opt) {
    38       AddComboOption(opt);
    39       TextBox tb = new TextBox();
    40       tb.Text = opt;
    41       //tb.Size = new Size()
    42       tb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
    43       //tb.Dock = DockStyle.Right | DockStyle.Left;
    44       tb.ReadOnly = true;
    4535
    46       CheckBox checkBox = new CheckBox();
    47       checkBox.Checked = true;
    48      
    49       checkBox.CheckStateChanged += (o, args) => {
    50         if (checkBox.Checked)
    51           AddComboOption(opt);
    52         else
    53           RemoveComboOption(opt);
    54       };
    55       tableOptions.Controls.Add(checkBox);
    56       tableOptions.Controls.Add(tb);
    57     }
    58 
    59     private void AddComboOption(string opt) {
     36    private void AddComboOption(object opt) {
    6037      comboBoxValues.Items.Add(opt);
    6138      IList<string> items = new List<string>();
     
    6340        items.Add((string)i);
    6441      }
    65       ((StringValueVM)VM).Range = items;
     42      VM.Range = items;
    6643      comboBoxValues.Enabled = true;
    67       tableOptions.Refresh();
    6844    }
    6945
    70     private void RemoveComboOption(string opt) {
     46    private void RemoveComboOption(object opt) {
    7147      comboBoxValues.Items.Remove(opt);
    7248      IList<string> items = new List<string>();
     
    7450        items.Add((string)i);
    7551      }
    76       ((StringValueVM)VM).Range = items;
    77       if (((StringValueVM)VM).Range.Count() <= 0) {
     52      VM.Range = items;
     53      if (VM.Range.Count() <= 0) {
    7854        comboBoxValues.Enabled = false;
    7955        comboBoxValues.SelectedIndex = -1;
    8056      }
    81       tableOptions.Refresh();
    8257    }
    8358  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Constants.cs

    r17439 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  /// <summary>
    93  /// Constants for reading/writing templates.
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs

    r17484 r17519  
    88using HeuristicLab.Core;
    99using HeuristicLab.Data;
     10using HeuristicLab.Parameters;
    1011using Newtonsoft.Json.Linq;
    1112
    1213namespace HeuristicLab.JsonInterface {
    1314  public class RegressionProblemDataConverter : BaseConverter {
     15    #region Constants
    1416    private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
     17    private const string TestPartition = "TestPartition";
     18    private const string TrainingPartition = "TrainingPartition";
     19    private const string TargetVariable = "TargetVariable";
     20    private const string AllowedInputVariables = "AllowedInputVariables";
     21    private const string Dataset = "Dataset";
     22    private const string VariableValues = "variableValues";
     23    private const string VariableNames = "variableNames";
     24    private const string InputVariables = "InputVariables";
     25    private const string Rows = "rows";
     26    private const string Value = "value";
     27    private const string Parameters = "parameters";
     28    private const string CheckedItemList = "CheckedItemList";
     29    #endregion
     30
    1531    public override int Priority => 20;
     32
     33    // RegressionProblemData
    1634    public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C"));
    1735
    1836    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    19       var dictTmp = new Dictionary<string, IList>();
    20       DoubleMatrixJsonItem matrix = data.Children[0] as DoubleMatrixJsonItem;
    21       if(matrix != null) {
    22         int c = 0;
    23         foreach(var col in matrix.RowNames) {
    24           dictTmp.Add(col, new List<double>(matrix.Value[c]));
    25           ++c;
    26         }
    27       }
    28 
    29       dynamic val = (dynamic)item;
    30       object dataset = (object)val.Dataset;
    31       var rows = dataset.GetType().GetField("rows", flags);
    32       rows.SetValue(dataset, matrix.Value[0].Length);
    33 
    34       var variableNames = dataset.GetType().GetField("variableNames", flags);
    35       variableNames.SetValue(dataset, matrix.RowNames);
    36 
    37       var dataInfo = dataset.GetType().GetField("variableValues", flags);
    38       dataInfo.SetValue(dataset, dictTmp);
    39       val.TargetVariable = ((StringJsonItem)data.Children[3]).Value;
    40       val.TrainingPartition.Start = ((IntRangeJsonItem)data.Children[2]).MinValue;
    41       val.TrainingPartition.End = ((IntRangeJsonItem)data.Children[2]).MaxValue;
    42       val.TestPartition.Start = ((IntRangeJsonItem)data.Children[1]).MinValue;
    43       val.TestPartition.End = ((IntRangeJsonItem)data.Children[1]).MaxValue;
     37
     38      dynamic regressionProblemData = (dynamic)item;
     39
     40      DoubleMatrixJsonItem dataset = null;
     41      StringJsonItem targetVariable = null;
     42      IntRangeJsonItem testPartition = null;
     43      IntRangeJsonItem trainingPartition = null;
     44      StringArrayJsonItem allowedInputVariables = null;
     45
     46
     47      // search first for the items (cache them, because the
     48      // order is important for injection)
     49      foreach (var child in data.Children) {
     50
     51        if (child.Path.EndsWith(Dataset))
     52          dataset = child as DoubleMatrixJsonItem;
     53        else if (child.Path.EndsWith(TargetVariable))
     54          targetVariable = child as StringJsonItem;
     55        else if (child.Path.EndsWith(TestPartition))
     56          testPartition = child as IntRangeJsonItem;
     57        else if (child.Path.EndsWith(TrainingPartition))
     58          trainingPartition = child as IntRangeJsonItem;
     59        else if (child.Path.EndsWith(AllowedInputVariables))
     60          allowedInputVariables = child as StringArrayJsonItem;
     61
     62      }
     63
     64      // check data
     65      if(!dataset.RowNames.Any(x => x == targetVariable.Value)) {
     66        throw new Exception($"The value of the target variable ('{targetVariable.Value}') has no matching row name value of the dataset.");
     67      }
     68
     69      foreach(var v in allowedInputVariables.Value) {
     70        if(!dataset.RowNames.Any(x => x == v))
     71          throw new Exception($"The value of the input variable ('{v}') has no matching row name value of the dataset.");
     72      }
     73
     74      // inject the value of the items
     75      SetDataset(regressionProblemData, dataset);
     76      SetTargetVariable(regressionProblemData, targetVariable);
     77      SetAllowedInputVariables(regressionProblemData, allowedInputVariables, dataset);
     78      SetTestPartition(regressionProblemData, testPartition);
     79      SetTrainingPartition(regressionProblemData, trainingPartition);
     80
    4481    }
    4582
     
    5087      };
    5188
    52       dynamic val = (dynamic)value;
     89      IJsonItem ds = GetDataset(value);
     90      if(ds != null)
     91        item.AddChildren(ds);
     92
     93      item.AddChildren(GetTestPartition(value));
     94      item.AddChildren(GetTrainingPartition(value));
     95      item.AddChildren(GetTargetVariable(value));
     96      item.AddChildren(GetAllowedInputVariables(value));
     97      return item;
     98    }
     99
     100    #region Inject Helper
     101    private void SetDataset(dynamic regressionProblemData, DoubleMatrixJsonItem item) {
     102      if (item != null) {
     103        var dictTmp = new Dictionary<string, IList>();
     104        int c = 0;
     105        foreach (var col in item.RowNames) {
     106          dictTmp.Add(col, new List<double>(item.Value[c]));
     107          ++c;
     108        }
     109
     110        object dataset = (object)regressionProblemData.Dataset;
     111        var rows = dataset.GetType().GetField(Rows, flags);
     112        rows.SetValue(dataset, item.Value[0].Length);
     113
     114        var variableNames = dataset.GetType().GetField(VariableNames, flags);
     115        variableNames.SetValue(dataset, item.RowNames);
     116
     117        var dataInfo = dataset.GetType().GetField(VariableValues, flags);
     118        dataInfo.SetValue(dataset, dictTmp);
     119      }
     120    }
     121
     122    private void SetTestPartition(dynamic regressionProblemData, IntRangeJsonItem item) {
     123      if (item != null) {
     124        regressionProblemData.TestPartition.Start = item.MinValue;
     125        regressionProblemData.TestPartition.End = item.MaxValue;
     126      }
     127    }
     128
     129    private void SetTrainingPartition(dynamic regressionProblemData, IntRangeJsonItem item) {
     130      if (item != null) {
     131        regressionProblemData.TrainingPartition.Start = item.MinValue;
     132        regressionProblemData.TrainingPartition.End = item.MaxValue;
     133      }
     134    }
     135
     136    private void SetTargetVariable(dynamic regressionProblemData, StringJsonItem item) {
     137      if (item != null) {
     138        var param = (IConstrainedValueParameter<StringValue>)regressionProblemData.TargetVariableParameter;
     139        StringValue v = param.Value;
     140        FieldInfo fi = v.GetType().GetField(Value, flags);
     141        fi.SetValue(v, item.Value);
     142      }
     143    }
     144
     145    private void SetAllowedInputVariables(dynamic regressionProblemData, StringArrayJsonItem item, IMatrixJsonItem matrix) {
     146      if (item != null && regressionProblemData is IParameterizedItem p) {
     147        var regProbDataType = ((ParameterizedNamedItem)regressionProblemData).GetType(); //RegressionProblemData
     148
     149        var parameterizedNamedItemType = regProbDataType.BaseType.BaseType;
     150
     151        // reset parameter
     152        var parametersInfo = parameterizedNamedItemType.GetField(Parameters, flags);
     153        ParameterCollection col = (ParameterCollection)parametersInfo.GetValue((object)regressionProblemData);
     154        var oldParam = (FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)col[InputVariables];
     155        var value = oldParam.Value;
     156        PropertyInfo listInfo = value.GetType().GetProperty(CheckedItemList, flags);
     157        CheckedItemList<StringValue> checkedItemList = (CheckedItemList<StringValue>)listInfo.GetValue(value);
     158        checkedItemList.Clear();
     159
     160        // add list items and set their check state (based on allowed input variables)
     161        foreach(var i in matrix.RowNames) {
     162          bool isChecked = false;
     163          foreach(var x in item.Value)
     164            isChecked = isChecked || (x == i);
     165          checkedItemList.Add(new StringValue(i).AsReadOnly(), isChecked);
     166        }
     167      }
     168    }
     169    #endregion
     170
     171    #region Extract Helper
     172    private IJsonItem GetDataset(IItem item) {
     173      dynamic val = (dynamic)item;
    53174      object dataset = (object)val.Dataset;
    54       dynamic targetVariable = val.TargetVariable;
    55      
    56       FieldInfo dataInfo = dataset.GetType().GetField("variableValues", flags);
    57      
    58       if(dataInfo.GetValue(dataset) is Dictionary<string, IList> dict) {
    59         int cols = dict.Count;
    60         int rows = 0;
    61         IList<string> rowNames = new List<string>();
    62         double[][] mat = new double[cols][];
    63         int c = 0;
    64         foreach(var x in dict) {
    65           rows = Math.Max(rows, x.Value.Count);
    66           rowNames.Add(x.Key);
    67           mat[c] = new double[rows];
    68           int r = 0;
    69           foreach(var rowValue in x.Value) {
    70             // TODO: for integers and bools aswell
    71             mat[c][r] = (double)rowValue;
    72             ++r;
     175      FieldInfo dataInfo = dataset.GetType().GetField(VariableValues, flags);
     176
     177      if (dataInfo.GetValue(dataset) is Dictionary<string, IList> dict) {
     178        IEnumerator it = dict.Values.First()?.GetEnumerator();
     179
     180        if(it != null) {
     181          if(it.MoveNext() && it.Current is double) {
     182            CreateMatrix(dict, out IList<string> rowNames, out double[][] mat);
     183            return new DoubleMatrixJsonItem() {
     184              Name = Dataset,
     185              Value = mat,
     186              RowNames = rowNames,
     187              Minimum = double.MinValue,
     188              Maximum = double.MaxValue
     189            };
     190          } else if(it.Current is int) {
     191            CreateMatrix(dict, out IList<string> rowNames, out int[][] mat);
     192            return new IntMatrixJsonItem() {
     193              Name = Dataset,
     194              Value = mat,
     195              RowNames = rowNames,
     196              Minimum = int.MinValue,
     197              Maximum = int.MaxValue
     198            };
     199          } else if (it.Current is bool) {
     200            CreateMatrix(dict, out IList<string> rowNames, out bool[][] mat);
     201            return new BoolMatrixJsonItem() {
     202              Name = Dataset,
     203              Value = mat,
     204              RowNames = rowNames
     205            };
    73206          }
    74           ++c;
    75         }
    76         item.AddChildren(new DoubleMatrixJsonItem() {
    77           Name = "Dataset",
    78           Value = mat,
    79           RowNames = rowNames,
    80           Minimum = double.MinValue,
    81           Maximum = double.MaxValue
    82         });
    83       }
    84 
    85       var trainingPartition = ((IntRange)val.TrainingPartition);
    86       var testPartition = ((IntRange)val.TestPartition);
    87 
    88       item.AddChildren(new IntRangeJsonItem() {
    89         Name = "TestPartition",
    90         MinValue = testPartition.Start,
     207        }
     208      }
     209      return null;
     210    }
     211   
     212    private void CreateMatrix<T>(Dictionary<string, IList> dict, out IList<string> rowNames, out T[][] matrix) {
     213      int cols = dict.Count, rows = 0, c = 0;
     214      rowNames = new List<string>();
     215      matrix = new T[cols][];
     216      foreach (var x in dict) {
     217        rows = Math.Max(rows, x.Value.Count);
     218        rowNames.Add(x.Key);
     219
     220        matrix[c] = new T[rows];
     221        int r = 0;
     222
     223        foreach (var rowValue in x.Value) {
     224          matrix[c][r] = (T)rowValue;
     225          ++r;
     226        }
     227        ++c;
     228      }
     229    }
     230
     231    private IJsonItem GetTestPartition(IItem item) {
     232      dynamic val = (dynamic)item;
     233      var trainingPartition = (IntRange)val.TrainingPartition;
     234      var testPartition = (IntRange)val.TestPartition;
     235      return new IntRangeJsonItem() {
     236        Name = TestPartition,
     237        MinValue = testPartition.Start,
    91238        MaxValue = testPartition.End,
    92         Minimum = 0, 
     239        Minimum = 0,
    93240        Maximum = Math.Max(testPartition.End, trainingPartition.End)
    94       });
    95 
    96      
    97       item.AddChildren(new IntRangeJsonItem() {
    98         Name = "TrainingPartition",
     241      };
     242    }
     243
     244    private IJsonItem GetTrainingPartition(IItem item) {
     245      dynamic val = (dynamic)item;
     246      var trainingPartition = (IntRange)val.TrainingPartition;
     247      var testPartition = (IntRange)val.TestPartition;
     248      return new IntRangeJsonItem() {
     249        Name = TrainingPartition,
    99250        MinValue = trainingPartition.Start,
    100251        MaxValue = trainingPartition.End,
    101252        Minimum = 0,
    102253        Maximum = Math.Max(testPartition.End, trainingPartition.End)
    103       });
    104 
    105       IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
    106       item.AddChildren(new StringJsonItem() {
    107         Name = "TargetVariable",
    108         Value = (string)targetVariable,
    109         ConcreteRestrictedItems = variables.Select(x => x.Value)
    110       });
    111 
    112       /*
    113       item.AddChildren(new StringArrayJsonItem() {
    114         Name = "AllowedInputVariables",
    115         Value = (string[])val.AllowedInputVariables,
    116         Range = variables.Select(x => x.Value)
    117       });*/
    118       return item;
    119     }
     254      };
     255    }
     256     
     257
     258    private IJsonItem GetTargetVariable(IItem item) =>
     259      new StringJsonItem() {
     260        Name = TargetVariable,
     261        Value = (string)((dynamic)item).TargetVariable,
     262        //ConcreteRestrictedItems = variables.Select(x => x.Value)
     263      };
     264
     265    private IJsonItem GetAllowedInputVariables(IItem item) =>
     266      new StringArrayJsonItem() {
     267        Name = AllowedInputVariables,
     268        Value = ((IEnumerable<string>)((dynamic)item).AllowedInputVariables).ToArray(),
     269        //ConcreteRestrictedItems = variables.Select(x => x.Value)
     270      };
     271    #endregion
    120272  }
    121273}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs

    r17483 r17519  
    1818
    1919      if(parameter.ActualValue != null) {
    20           if (data.Children == null || data.Children.Count == 0)
     20          if (data.Children == null || data.Children.Count() == 0)
    2121            root.Inject(parameter.ActualValue, data, root);
    2222          else
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IArrayJsonItem.cs

    r17473 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
     1namespace HeuristicLab.JsonInterface {
    62
    7 namespace HeuristicLab.JsonInterface {
    83  public interface IArrayJsonItem : IValueJsonItem {
     4    /// <summary>
     5    /// Property to define an array item to be resizable.
     6    /// </summary>
    97    bool Resizable { get; set; }
    108  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IConcreteRestrictedJsonItem.cs

    r17473 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
     1using System.Collections.Generic;
    62
    73namespace HeuristicLab.JsonInterface {
    84  public interface IConcreteRestrictedJsonItem<T> : IJsonItem {
     5    /// <summary>
     6    /// The item,
     7    /// </summary>
    98    IEnumerable<T> ConcreteRestrictedItems { get; set; }
    109  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IIntervalRestrictedJsonItem.cs

    r17477 r17519  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    62
    73namespace HeuristicLab.JsonInterface {
     4  /// <summary>
     5  /// Interface to get a interval restrict JsonItems.
     6  /// </summary>
     7  /// <typeparam name="T"></typeparam>
    88  public interface IIntervalRestrictedJsonItem<T> : IJsonItem
    99    where T : IComparable {
     10    /// <summary>
     11    /// The allowed minimum of the JsonItem.
     12    /// </summary>
    1013    T Minimum { get; set; }
     14    /// <summary>
     15    /// The allowed maximum of the JsonItem.
     16    /// </summary>
    1117    T Maximum { get; set; }
    1218  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs

    r17477 r17519  
    1111  [JsonObject]
    1212  public interface IJsonItem : IEnumerable<IJsonItem> {
     13    /// <summary>
     14    /// Only active items are included in templates.
     15    /// </summary>
    1316    bool Active { get; set; }
     17
     18    /// <summary>
     19    /// The name of the JsonItem. Can be changed freely after fixating the path.
     20    /// If the path is not fix, changing the name will have affect of the path.
     21    /// </summary>
    1422    string Name { get; set; }
    1523
     24    /// <summary>
     25    /// A description for the JsonItem.
     26    /// </summary>
    1627    string Description { get; set; }
    1728
    18     string Path {
    19       get;
    20     }
     29    /// <summary>
     30    /// The JsonItem path in the related object graph.
     31    /// </summary>
     32    string Path { get; }
    2133
     34    /// <summary>
     35    /// IEnumerable of all sub JsonItems.
     36    /// </summary>
    2237    [JsonIgnore]
    23     IList<IJsonItem> Children { get; } //TODO: IEnumerable
     38    IEnumerable<IJsonItem> Children { get; }
    2439
     40    /// <summary>
     41    /// If the JsonItem is a children of an other JsonItem, the parent will be this other JsonItem.
     42    /// </summary>
    2543    [JsonIgnore]
    2644    IJsonItem Parent { get; set; }
    27        
     45
     46    /// <summary>
     47    /// Returns a validator with integrated caching to validate the JsonItem and all children.
     48    /// </summary>
     49    /// <returns>JsonItemValidator</returns>   
    2850    IJsonItemValidator GetValidator();
    2951
     52    /// <summary>
     53    /// Add sub JsonItems.
     54    /// </summary>
     55    /// <param name="childs"></param>
    3056    void AddChildren(params IJsonItem[] childs);
    31 
    3257    void AddChildren(IEnumerable<IJsonItem> childs);
    3358
     
    4469    void LoosenPath();
    4570
     71    /// <summary>
     72    /// Method to generate a Newtonsoft JObject, which describes the JsonItem.
     73    /// </summary>
     74    /// <returns>Newtonsoft JObject</returns>
    4675    JObject GenerateJObject();
     76
     77    /// <summary>
     78    /// To set all necessary JsonItem properties with an given Newtonsoft JObject.
     79    /// </summary>
     80    /// <param name="jObject">Newtonsoft JObject</param>
    4781    void SetJObject(JObject jObject);
    4882  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItemConverter.cs

    r17406 r17519  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    62using HeuristicLab.Core;
    7 using Newtonsoft.Json.Linq;
    83
    94namespace HeuristicLab.JsonInterface {
     
    2520    IJsonItem Extract(IItem value, IJsonItemConverter root);
    2621
     22    /// <summary>
     23    /// The targeted type for the converter.
     24    /// </summary>
    2725    Type ConvertableType { get; }
     26
     27    /// <summary>
     28    /// A given priority, higher numbers are prior.
     29    /// </summary>
    2830    int Priority { get; }
    2931  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItemValidator.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public interface IJsonItemValidator {
     3    /// <summary>
     4    /// Validate method to validate a JsonItem.
     5    /// </summary>
     6    /// <returns>
     7    /// The result of the validation process,
     8    /// contains a sucess flag and a list of errors
     9    /// (if validation failed).
     10    /// </returns>
    911    ValidationResult Validate();
    1012  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/ILookupJsonItem.cs

    r17471 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public interface ILookupJsonItem : IJsonItem {
     3    /// <summary>
     4    /// The actual name for lookup items.
     5    /// </summary>
    96    string ActualName { get; set; }
    107  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IMatrixJsonItem.cs

    r17473 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
     1using System.Collections.Generic;
    62
    73namespace HeuristicLab.JsonInterface {
    84  public interface IMatrixJsonItem : IValueJsonItem {
     5    /// <summary>
     6    /// Flag to define resizable rows.
     7    /// </summary>
    98    bool RowsResizable { get; set; }
     9    /// <summary>
     10    /// Flag to define resizable columns.
     11    /// </summary>
    1012    bool ColumnsResizable { get; set; }
     13    /// <summary>
     14    /// IEnumerable of row names.
     15    /// </summary>
    1116    IEnumerable<string> RowNames { get; set; }
     17    /// <summary>
     18    /// IEnumerable of column names.
     19    /// </summary>
    1220    IEnumerable<string> ColumnNames { get; set; }
    1321  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IRangedJsonItem.cs

    r17473 r17519  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    62
    73namespace HeuristicLab.JsonInterface {
     
    95    where T : IComparable
    106  {
     7    /// <summary>
     8    /// The lower bound of an ranged item.
     9    /// </summary>
    1110    T MinValue { get; set; }
     11    /// <summary>
     12    /// The upper bound of an ranged item.
     13    /// </summary>
    1214    T MaxValue { get; set; }
    1315  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultJsonItem.cs

    r17471 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
    8   public interface IResultJsonItem : IJsonItem {
    9   }
     1namespace HeuristicLab.JsonInterface {
     2  /// <summary>
     3  /// Empty JsonItem, which indicates a result. For example 'BestQuality'.
     4  /// Types of this JsonItems are stored in the result section of the template.
     5  /// </summary>
     6  public interface IResultJsonItem : IJsonItem { }
    107}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IValueJsonItem.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public interface IValueJsonItem : IJsonItem {
     3    /// <summary>
     4    /// Represent the value of an IItem.
     5    /// </summary>
    96    object Value { get; set; }
    107  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IValueLookupJsonItem.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using Newtonsoft.Json;
     1using Newtonsoft.Json;
    72
    83namespace HeuristicLab.JsonInterface {
    94  public interface IValueLookupJsonItem : ILookupJsonItem {
     5    /// <summary>
     6    /// The IJsonItem representation of the actual value of an IValueLookupItem.
     7    /// </summary>
    108    [JsonIgnore]
    119    IJsonItem ActualValue { get; set; }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using HeuristicLab.Common;
    5 using HeuristicLab.Core;
    6 using HeuristicLab.Data;
     1using System.Collections.Generic;
    72using HeuristicLab.Optimization;
    8 using Newtonsoft.Json;
    93using Newtonsoft.Json.Linq;
    104using HEAL.Attic;
     
    3731      #region Serialize HL File
    3832      ProtoBufSerializer serializer = new ProtoBufSerializer();
    39       string hlFilePath = fullPath + @"\" + templateName + ".hl";
     33      string hlFilePath = fullPath + templateName + ".hl";
    4034      serializer.Serialize(optimizer, hlFilePath);
    4135      #endregion
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverter.cs

    r17483 r17519  
    22using System.Collections.Generic;
    33using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    64using HeuristicLab.Core;
    7 using HeuristicLab.Data;
    8 using HeuristicLab.PluginInfrastructure;
    9 using HEAL.Attic;
    10 using System.Collections;
    11 
    125namespace HeuristicLab.JsonInterface {
    136  /// <summary>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverterFactory.cs

    r17394 r17519  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63using HeuristicLab.PluginInfrastructure;
    74
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs

    r17483 r17519  
    1 using System;
    2 using System.Collections;
    3 using System.Collections.Generic;
     1using System.Collections.Generic;
    42using System.IO;
    53using System.Linq;
    6 using System.Reflection;
    7 using System.Text;
    8 using System.Threading.Tasks;
    94using HEAL.Attic;
    10 using HeuristicLab.Core;
    11 using HeuristicLab.Data;
    125using HeuristicLab.Optimization;
    136using Newtonsoft.Json.Linq;
     
    7972    }
    8073
    81    
    8274    private IEnumerable<IResultJsonItem> CollectResults() {
    8375      IList<IResultJsonItem> res = new List<IResultJsonItem>();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ArrayJsonItem.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using Newtonsoft.Json.Linq;
     1using Newtonsoft.Json.Linq;
    72
    83namespace HeuristicLab.JsonInterface {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/BoolJsonItems.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public class BoolJsonItem : ValueJsonItem<bool> {
    93    protected override ValidationResult Validate() => ValidationResult.Successful();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ConcreteRestrictedArrayJsonItem.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    73namespace HeuristicLab.JsonInterface {
    84  public abstract class ConcreteRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IConcreteRestrictedJsonItem<T> {
     
    128      bool res = true;
    139      IList<string> errors = new List<string>();
     10      if (ConcreteRestrictedItems == null) return ValidationResult.Successful();
    1411      foreach(var x in Value) {
    1512        bool tmp = false;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ConcreteRestrictedValueJsonItem.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63
    74namespace HeuristicLab.JsonInterface {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DateTimeJsonItem.cs

    r17481 r17519  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    62using Newtonsoft.Json.Linq;
    73
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DoubleJsonItems.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using Newtonsoft.Json.Linq;
     1using Newtonsoft.Json.Linq;
    72
    83namespace HeuristicLab.JsonInterface {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/EmptyJsonItem.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public class EmptyJsonItem : JsonItem {
    93    protected override ValidationResult Validate() => ValidationResult.Successful();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntJsonItems.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using Newtonsoft.Json.Linq;
     1using Newtonsoft.Json.Linq;
    72
    83namespace HeuristicLab.JsonInterface {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntervalRestrictedArrayJsonItem.cs

    r17481 r17519  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63using Newtonsoft.Json.Linq;
    74
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntervalRestrictedMatrixJsonItem.cs

    r17481 r17519  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63using Newtonsoft.Json.Linq;
    74
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntervalRestrictedValueJsonItem.cs

    r17481 r17519  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    62using Newtonsoft.Json.Linq;
    73
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs

    r17485 r17519  
    1 using System;
    2 using System.Collections;
     1using System.Collections;
    32using System.Collections.Generic;
    43using System.Linq;
     
    7675      }
    7776    }
    78        
     77
    7978    // TODO jsonIgnore dataType?
    80 
    8179    [JsonIgnore]
    82     public virtual IList<IJsonItem> Children { get; protected set; }
     80    public virtual IEnumerable<IJsonItem> Children { get; protected set; }
    8381
    8482    [JsonIgnore]
     
    104102      if (Children == null)
    105103        Children = new List<IJsonItem>();
    106       foreach (var child in childs) {
    107         Children.Add(child);
    108         child.Parent = this;
     104      if(Children is IList<IJsonItem> list) {
     105        foreach (var child in childs) {
     106          list.Add(child);
     107          child.Parent = this;
     108        }
    109109      }
    110110    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/LookupJsonItem.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using Newtonsoft.Json.Linq;
     1using Newtonsoft.Json.Linq;
    72
    83namespace HeuristicLab.JsonInterface {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/MatrixJsonItem.cs

    r17477 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
     1using System.Collections.Generic;
    62using Newtonsoft.Json.Linq;
    73
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/RangedJsonItem.cs

    r17481 r17519  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63
    74namespace HeuristicLab.JsonInterface {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ResultJsonItem.cs

    r17481 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public class ResultJsonItem : JsonItem, IResultJsonItem {
    93    protected override ValidationResult Validate() => ValidationResult.Successful();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/StringJsonItem.cs

    r17473 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 
    7 namespace HeuristicLab.JsonInterface {
     1namespace HeuristicLab.JsonInterface {
    82  public class StringJsonItem : ConcreteRestrictedValueJsonItem<string> { }
    93  public class StringArrayJsonItem : ConcreteRestrictedArrayJsonItem<string> { }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/UnsupportedJsonItem.cs

    r17481 r17519  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    63using Newtonsoft.Json;
    74
     
    2320
    2421    [JsonIgnore]
    25     public override IList<IJsonItem> Children {
     22    public override IEnumerable<IJsonItem> Children {
    2623      get => throw new NotSupportedException();
    2724      protected set => throw new NotSupportedException();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ValueJsonItem.cs

    r17477 r17519  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    62using Newtonsoft.Json.Linq;
    73
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ValueLookupJsonItem.cs

    r17483 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using Newtonsoft.Json;
     1using System.Collections.Generic;
    72using Newtonsoft.Json.Linq;
    83
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r17180 r17519  
    178178      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
    179179      Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly()));
    180 
     180     
    181181      TransformationsParameter.Hidden = true;
    182182
  • branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs

    r17483 r17519  
    3030      HEAL.Attic.Mapper.StaticCache.UpdateRegisteredTypes();
    3131
    32 
     32     
    3333      HeuristicLabJsonInterfaceAppApplication app = new HeuristicLabJsonInterfaceAppApplication();
    3434
     
    4747      ActivateJsonItems(root);
    4848
    49       JCGenerator.GenerateTemplate(@"C:\Workspace", "Template", alg, root);
    5049     
     50      JCGenerator.GenerateTemplate(@"C:\Workspace\ConfigStarter\", "Template", alg, root);
     51     
     52
    5153      List<ICommandLineArgument> arguments = new List<ICommandLineArgument>();
    5254      arguments.Add(new StartArgument("JsonInterface"));
    53       arguments.Add(new OpenArgument(@"C:\Workspace\Template.json"));
    54       arguments.Add(new OpenArgument(@"C:\Workspace\Config.json"));
    55       arguments.Add(new StringArgument(@"C:\Workspace\Output.json"));
     55      arguments.Add(new OpenArgument(@"C:\Workspace\ConfigStarter\Template.json"));
     56      arguments.Add(new OpenArgument(@"C:\Workspace\ConfigStarter\Config.json"));
     57      arguments.Add(new StringArgument(@"C:\Workspace\ConfigStarter\Output.json"));
    5658
    5759      app.Run(arguments.ToArray());
     
    6567          i.Active = true;
    6668        }
     69        /*
     70        if(x.Name == "Dataset" && x is DoubleMatrixJsonItem mat) {
     71          mat.Value = new double[5][];
     72          mat.RowNames = new string[] { "R1", "R2", "R3" };
     73          for(int j = 0; j < 5; ++j) {
     74            mat.Value[j] = new double[10];
     75          }
     76        }*/
    6777      }
    6878    }
Note: See TracChangeset for help on using the changeset viewer.