Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17451


Ignore:
Timestamp:
02/25/20 17:18:00 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • renamed ResultItem to ResultJsonItem
  • implemented RegressionProblemDataConverter
  • added support for "named matrices" (named = rows and columns have names) -> INamedMatrixJsonItem incl. base classes and views
  • added a bool property Active in IJsonItem -> marks items, which should be written into the template
Location:
branches/3026_IntegrationIntoSymSpace
Files:
4 added
23 edited
1 moved

Legend:

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

    r17442 r17451  
    3838  </PropertyGroup>
    3939  <ItemGroup>
     40    <Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
     41      <HintPath>..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
     42    </Reference>
     43    <Reference Include="HEAL.Attic, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     44      <HintPath>..\packages\HEAL.Attic.1.4.0\lib\net461\HEAL.Attic.dll</HintPath>
     45    </Reference>
    4046    <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
    4147      <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
     
    4349    <Reference Include="System" />
    4450    <Reference Include="System.Core" />
     51    <Reference Include="System.Drawing" />
     52    <Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
     53      <HintPath>..\packages\System.Drawing.Common.4.5.1\lib\net461\System.Drawing.Common.dll</HintPath>
     54    </Reference>
    4555    <Reference Include="System.Xml.Linq" />
    4656    <Reference Include="System.Data.DataSetExtensions" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs

    r17442 r17451  
    2222        Thread.Sleep(100);
    2323      }
     24     
    2425      WriteResultsToFile(outputFile, optimizer, allowedResultNames);
    2526    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj

    r17446 r17451  
    8181    <Compile Include="Interfaces\IJsonItemVM.cs" />
    8282    <Compile Include="Interfaces\IMatrixJsonItemVM.cs" />
     83    <Compile Include="Interfaces\INamedMatrixJsonItemVM.cs" />
    8384    <Compile Include="Properties\Resources.Designer.cs">
    8485      <AutoGen>True</AutoGen>
     
    101102    <Compile Include="ViewModels\JsonItemVMBase.cs" />
    102103    <Compile Include="ViewModels\MatrixValueVM.cs" />
     104    <Compile Include="ViewModels\NamedMatrixValueVM.cs" />
    103105    <Compile Include="ViewModels\RangedValueBaseVM.cs" />
    104106    <Compile Include="ViewModels\RangeVM.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17446 r17451  
    3939    public virtual Type JsonItemType => typeof(JsonItem);
    4040
    41     private bool selected = true;
     41   
    4242    public bool Selected {
    43       get => selected;
     43      get => Item.Active;
    4444      set {
    45         selected = value;
     45        Item.Active = value;
    4646        if(TreeNode != null) {
    47           TreeNode.ForeColor = (selected ? Color.Black : Color.Red);
     47          TreeNode.ForeColor = (Selected ? Color.Black : Color.Red);
    4848          TreeNode.Checked = value;
    4949        }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs

    r17446 r17451  
    77namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    88  public class ResultItemVM : JsonItemVMBase {
    9     public override Type JsonItemType => typeof(ResultItem);
     9    public override Type JsonItemType => typeof(ResultJsonItem);
    1010    public override JsonItemBaseControl Control =>
    1111      new JsonItemBaseControl(this);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs

    r17446 r17451  
    3030      this.groupBoxDetails = new System.Windows.Forms.GroupBox();
    3131      this.panelParameterDetails = new System.Windows.Forms.Panel();
    32       this.resultItems = new System.Windows.Forms.CheckedListBox();
    33       this.groupBox3 = new System.Windows.Forms.GroupBox();
     32      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    3433      this.treeViewResults = new System.Windows.Forms.TreeView();
     34      this.groupBox = new System.Windows.Forms.GroupBox();
     35      this.panelResultDetails = new System.Windows.Forms.Panel();
    3536      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    3637      this.tabControl1 = new System.Windows.Forms.TabControl();
     
    4041      this.textBoxTemplateName = new System.Windows.Forms.TextBox();
    4142      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    42       this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    43       this.groupBox = new System.Windows.Forms.GroupBox();
    44       this.panelResultDetails = new System.Windows.Forms.Panel();
    4543      this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
    4644      this.groupBoxDetails.SuspendLayout();
    47       this.groupBox3.SuspendLayout();
     45      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
     46      this.splitContainer1.Panel1.SuspendLayout();
     47      this.splitContainer1.Panel2.SuspendLayout();
     48      this.splitContainer1.SuspendLayout();
     49      this.groupBox.SuspendLayout();
    4850      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
    4951      this.splitContainer2.Panel1.SuspendLayout();
     
    5456      this.tabPage2.SuspendLayout();
    5557      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    56       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
    57       this.splitContainer1.Panel1.SuspendLayout();
    58       this.splitContainer1.Panel2.SuspendLayout();
    59       this.splitContainer1.SuspendLayout();
    60       this.groupBox.SuspendLayout();
    6158      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit();
    6259      this.SuspendLayout();
     
    8582      this.treeView.Location = new System.Drawing.Point(0, 6);
    8683      this.treeView.Name = "treeView";
    87       this.treeView.Size = new System.Drawing.Size(370, 493);
     84      this.treeView.Size = new System.Drawing.Size(380, 492);
    8885      this.treeView.TabIndex = 3;
    8986      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
     
    9592      this.groupBoxDetails.Location = new System.Drawing.Point(0, 0);
    9693      this.groupBoxDetails.Name = "groupBoxDetails";
    97       this.groupBoxDetails.Size = new System.Drawing.Size(422, 499);
     94      this.groupBoxDetails.Size = new System.Drawing.Size(412, 499);
    9895      this.groupBoxDetails.TabIndex = 4;
    9996      this.groupBoxDetails.TabStop = false;
     
    106103      this.panelParameterDetails.Location = new System.Drawing.Point(3, 16);
    107104      this.panelParameterDetails.Name = "panelParameterDetails";
    108       this.panelParameterDetails.Size = new System.Drawing.Size(416, 480);
     105      this.panelParameterDetails.Size = new System.Drawing.Size(406, 480);
    109106      this.panelParameterDetails.TabIndex = 0;
    110107      //
    111       // resultItems
    112       //
    113       this.resultItems.Dock = System.Windows.Forms.DockStyle.Fill;
    114       this.resultItems.FormattingEnabled = true;
    115       this.resultItems.Location = new System.Drawing.Point(0, 6);
    116       this.resultItems.Name = "resultItems";
    117       this.resultItems.Size = new System.Drawing.Size(373, 393);
    118       this.resultItems.TabIndex = 5;
    119       this.resultItems.SelectedValueChanged += new System.EventHandler(this.resultItems_SelectedValueChanged);
    120       //
    121       // groupBox3
    122       //
    123       this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    124             | System.Windows.Forms.AnchorStyles.Left)
    125             | System.Windows.Forms.AnchorStyles.Right)));
    126       this.groupBox3.Controls.Add(this.splitContainer1);
    127       this.groupBox3.Controls.Add(this.treeViewResults);
    128       this.groupBox3.Location = new System.Drawing.Point(6, 6);
    129       this.groupBox3.Name = "groupBox3";
    130       this.groupBox3.Size = new System.Drawing.Size(790, 493);
    131       this.groupBox3.TabIndex = 7;
    132       this.groupBox3.TabStop = false;
    133       this.groupBox3.Text = "Result Elements";
     108      // splitContainer1
     109      //
     110      this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
     111      this.splitContainer1.Location = new System.Drawing.Point(3, 3);
     112      this.splitContainer1.Name = "splitContainer1";
     113      //
     114      // splitContainer1.Panel1
     115      //
     116      this.splitContainer1.Panel1.Controls.Add(this.treeViewResults);
     117      this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 1);
     118      //
     119      // splitContainer1.Panel2
     120      //
     121      this.splitContainer1.Panel2.Controls.Add(this.groupBox);
     122      this.splitContainer1.Size = new System.Drawing.Size(796, 499);
     123      this.splitContainer1.SplitterDistance = 380;
     124      this.splitContainer1.TabIndex = 7;
    134125      //
    135126      // treeViewResults
    136127      //
    137128      this.treeViewResults.CheckBoxes = true;
    138       this.treeViewResults.Location = new System.Drawing.Point(6, 19);
     129      this.treeViewResults.Dock = System.Windows.Forms.DockStyle.Fill;
     130      this.treeViewResults.Location = new System.Drawing.Point(0, 6);
    139131      this.treeViewResults.Name = "treeViewResults";
    140       this.treeViewResults.Size = new System.Drawing.Size(777, 63);
     132      this.treeViewResults.Size = new System.Drawing.Size(380, 492);
    141133      this.treeViewResults.TabIndex = 6;
     134      this.treeViewResults.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewResults_AfterCheck);
     135      this.treeViewResults.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewResults_AfterSelect);
     136      //
     137      // groupBox
     138      //
     139      this.groupBox.Controls.Add(this.panelResultDetails);
     140      this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     141      this.groupBox.Location = new System.Drawing.Point(0, 0);
     142      this.groupBox.Name = "groupBox";
     143      this.groupBox.Size = new System.Drawing.Size(412, 499);
     144      this.groupBox.TabIndex = 5;
     145      this.groupBox.TabStop = false;
     146      this.groupBox.Text = "Details";
     147      //
     148      // panelResultDetails
     149      //
     150      this.panelResultDetails.AutoScroll = true;
     151      this.panelResultDetails.Dock = System.Windows.Forms.DockStyle.Fill;
     152      this.panelResultDetails.Location = new System.Drawing.Point(3, 16);
     153      this.panelResultDetails.Name = "panelResultDetails";
     154      this.panelResultDetails.Size = new System.Drawing.Size(406, 480);
     155      this.panelResultDetails.TabIndex = 0;
    142156      //
    143157      // splitContainer2
     
    150164      //
    151165      this.splitContainer2.Panel1.Controls.Add(this.treeView);
    152       this.splitContainer2.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
     166      this.splitContainer2.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 1);
    153167      //
    154168      // splitContainer2.Panel2
     
    156170      this.splitContainer2.Panel2.Controls.Add(this.groupBoxDetails);
    157171      this.splitContainer2.Size = new System.Drawing.Size(796, 499);
    158       this.splitContainer2.SplitterDistance = 370;
     172      this.splitContainer2.SplitterDistance = 380;
    159173      this.splitContainer2.TabIndex = 9;
    160174      //
     
    185199      // tabPage2
    186200      //
    187       this.tabPage2.Controls.Add(this.groupBox3);
     201      this.tabPage2.Controls.Add(this.splitContainer1);
    188202      this.tabPage2.Location = new System.Drawing.Point(4, 22);
    189203      this.tabPage2.Name = "tabPage2";
     
    219233      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
    220234      this.errorProvider.ContainerControl = this;
    221       //
    222       // splitContainer1
    223       //
    224       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    225             | System.Windows.Forms.AnchorStyles.Left)
    226             | System.Windows.Forms.AnchorStyles.Right)));
    227       this.splitContainer1.Location = new System.Drawing.Point(6, 88);
    228       this.splitContainer1.Name = "splitContainer1";
    229       //
    230       // splitContainer1.Panel1
    231       //
    232       this.splitContainer1.Panel1.Controls.Add(this.resultItems);
    233       this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
    234       //
    235       // splitContainer1.Panel2
    236       //
    237       this.splitContainer1.Panel2.Controls.Add(this.groupBox);
    238       this.splitContainer1.Size = new System.Drawing.Size(778, 399);
    239       this.splitContainer1.SplitterDistance = 373;
    240       this.splitContainer1.TabIndex = 7;
    241       //
    242       // groupBox
    243       //
    244       this.groupBox.Controls.Add(this.panelResultDetails);
    245       this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    246       this.groupBox.Location = new System.Drawing.Point(0, 0);
    247       this.groupBox.Name = "groupBox";
    248       this.groupBox.Size = new System.Drawing.Size(401, 399);
    249       this.groupBox.TabIndex = 5;
    250       this.groupBox.TabStop = false;
    251       this.groupBox.Text = "Details";
    252       //
    253       // panelResultDetails
    254       //
    255       this.panelResultDetails.AutoScroll = true;
    256       this.panelResultDetails.Dock = System.Windows.Forms.DockStyle.Fill;
    257       this.panelResultDetails.Location = new System.Drawing.Point(3, 16);
    258       this.panelResultDetails.Name = "panelResultDetails";
    259       this.panelResultDetails.Size = new System.Drawing.Size(395, 380);
    260       this.panelResultDetails.TabIndex = 0;
    261235      //
    262236      // jsonItemBindingSource
     
    278252      this.Text = "Export Json";
    279253      this.groupBoxDetails.ResumeLayout(false);
    280       this.groupBox3.ResumeLayout(false);
     254      this.splitContainer1.Panel1.ResumeLayout(false);
     255      this.splitContainer1.Panel2.ResumeLayout(false);
     256      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
     257      this.splitContainer1.ResumeLayout(false);
     258      this.groupBox.ResumeLayout(false);
    281259      this.splitContainer2.Panel1.ResumeLayout(false);
    282260      this.splitContainer2.Panel2.ResumeLayout(false);
     
    287265      this.tabPage2.ResumeLayout(false);
    288266      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    289       this.splitContainer1.Panel1.ResumeLayout(false);
    290       this.splitContainer1.Panel2.ResumeLayout(false);
    291       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
    292       this.splitContainer1.ResumeLayout(false);
    293       this.groupBox.ResumeLayout(false);
    294267      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit();
    295268      this.ResumeLayout(false);
     
    307280    private System.Windows.Forms.GroupBox groupBoxDetails;
    308281    private System.Windows.Forms.Panel panelParameterDetails;
    309     private System.Windows.Forms.CheckedListBox resultItems;
    310     private System.Windows.Forms.GroupBox groupBox3;
    311282    private System.Windows.Forms.SplitContainer splitContainer2;
    312283    private System.Windows.Forms.TabControl tabControl1;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r17446 r17451  
    1717  public partial class ExportJsonDialog : Form {
    1818    private static FolderBrowserDialog FolderBrowserDialog { get; set; }
    19     private IDictionary<int, UserControl> Hash2Control { get; set; } = new Dictionary<int, UserControl>();
     19    private IDictionary<TreeNode, UserControl> Node2Control { get; set; } = new Dictionary<TreeNode, UserControl>();
    2020    private IDictionary<TreeNode, IJsonItemVM> Node2VM { get; set; } = new Dictionary<TreeNode, IJsonItemVM>();
     21    private IDictionary<Type, Type> JI2VM { get; set; }
    2122    private IJsonItem Root { get; set; }
    2223    private IOptimizer Optimizer { get; set; }
    2324    private IList<IJsonItemVM> VMs { get; set; }
    2425    private JCGenerator Generator { get; set; } = new JCGenerator();
    25     private IDictionary<string, IJsonItem> ResultItems { get; set; } = new Dictionary<string, IJsonItem>();
    2626
    2727    private IContent content;
     
    3333        VMs = new List<IJsonItemVM>();
    3434        treeView.Nodes.Clear();
    35         ResultItems.Clear();
    36         resultItems.Items.Clear();
     35        treeViewResults.Nodes.Clear();
    3736
    3837        Optimizer = content as IOptimizer;
     
    4746    }
    4847
    49     private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) {
    50       if (e.Action != TreeViewAction.Unknown) {
    51         if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) {
    52           vm.Selected = e.Node.Checked;
    53         }
    54       }
    55     }
     48   
    5649
    57     private IDictionary<Type, Type> JI2VM { get; set; }
    5850
    5951    private void InitCache() {
     
    7163
    7264    private void exportButton_Click(object sender, EventArgs e) {
     65      // to set default value for disabled items
     66      JsonItemConverter.Inject(Optimizer, Root);
     67      /*
    7368      foreach (var x in VMs) {
    74         if (!(x is ResultItemVM) && !x.Selected) {
    75           x.Item.Parent.Children.Remove(x.Item);
     69        if (!x.Selected) {
     70          x.Item.Parent?.Children?.Remove(x.Item);
     71        } else if(x is ResultItemVM) {
     72          x.Item.Parent?.Children?.Remove(x.Item);
     73          Root.AddChildren(x.Item);
    7674        }
    7775      }
    78 
    79       foreach (var x in ResultItems.Values) {
    80         x.Parent.Children.Remove(x);
    81       }
    82 
    83       foreach (var x in resultItems.CheckedItems) {
    84         if (ResultItems.TryGetValue((string)x, out IJsonItem item)) {
    85           Root.AddChildren(item);
    86         }
    87       }
    88 
     76      */
     77     
    8978      IList<IJsonItem> faultyItems = new List<IJsonItem>();
    9079     
     
    11099
    111100    private void BuildTreeNode(TreeNode node, IJsonItem item) {
    112       RegisterItem(node, item);
     101      RegisterItem(node, item, treeView);
    113102      if (item.Children != null) {
    114103        foreach (var c in item.Children) {
    115104          if (IsDrawableItem(c)) {
    116             if (c is ResultItem) {
    117               resultItems.Items.Add(c.Name, true);
    118               ResultItems.Add(c.Name, c);
     105            if (c is ResultJsonItem) {
    119106              TreeNode childNode = new TreeNode(c.Name);
    120107              treeViewResults.Nodes.Add(childNode);
    121               RegisterItem(childNode, c);
    122               //Hash2Control.Add(c.GetHashCode(), new JsonItemBaseControl(new JsonItemVMBase() { Item = c }));
     108              RegisterItem(childNode, c, treeViewResults);
     109              if(Node2VM.TryGetValue(childNode, out IJsonItemVM vm))
     110                vm.Selected = true;
    123111            } else {
    124112              TreeNode childNode = new TreeNode(c.Name);
     
    131119    }
    132120
    133     private void RegisterItem(TreeNode node, IJsonItem item) {
     121    private void RegisterItem(TreeNode node, IJsonItem item, TreeView tv) {
    134122      if (JI2VM.TryGetValue(item.GetType(), out Type vmType)) {
    135123        IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType);
     
    137125        vm.Item = item;
    138126        vm.TreeNode = node;
    139         vm.TreeView = treeView;
    140         node.Checked = vm.Selected;
     127        vm.TreeView = tv;
     128        vm.Selected = false;
    141129
    142130        VMs.Add(vm);
    143131        Node2VM.Add(node, vm);
    144132        UserControl control = vm.Control;
    145         Hash2Control.Add(node.GetHashCode(), control);
     133        Node2Control.Add(node, control);
    146134      }
    147135    }
     
    155143      }
    156144     
    157       return b || (item.Value != null || item.Range != null || item.ActualName != null);
     145      return b || (item.Value != null || item.Range != null || item.ActualName != null || item is ResultJsonItem);
    158146    }
    159147   
    160148    private void treeView_AfterSelect(object sender, TreeViewEventArgs e) {
    161       if(Hash2Control.TryGetValue(treeView.SelectedNode.GetHashCode(), out UserControl control)) {
     149      if(Node2Control.TryGetValue(treeView.SelectedNode, out UserControl control)) {
    162150        SetControlOnPanel(control, panelParameterDetails);
     151      }
     152    }
     153
     154    private void treeViewResults_AfterSelect(object sender, TreeViewEventArgs e) {
     155      if (Node2Control.TryGetValue(treeViewResults.SelectedNode, out UserControl control)) {
     156        SetControlOnPanel(control, panelResultDetails);
    163157      }
    164158    }
     
    170164      } else {
    171165        errorProvider.SetError(textBoxTemplateName, null);
    172       }
    173     }
    174 
    175     private void resultItems_SelectedValueChanged(object sender, EventArgs e) {
    176       if(ResultItems.TryGetValue(resultItems.SelectedItem.ToString(), out IJsonItem item) &&
    177         Hash2Control.TryGetValue(item.GetHashCode(), out UserControl control)) {
    178         SetControlOnPanel(control, panelResultDetails);
    179166      }
    180167    }
     
    191178      panel.Refresh();
    192179    }
     180
     181    private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) {
     182      if (e.Action != TreeViewAction.Unknown) {
     183        if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) {
     184          vm.Selected = e.Node.Checked;
     185        }
     186      }
     187    }
     188
     189    private void treeViewResults_AfterCheck(object sender, TreeViewEventArgs e) {
     190      if (e.Action != TreeViewAction.Unknown) {
     191        if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) {
     192          vm.Selected = e.Node.Checked;
     193        }
     194      }
     195    }
    193196  }
    194197}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs

    r17446 r17451  
    1010
    1111namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    12  
     12
     13  public class JsonItemDoubleNamedMatrixValueControl : JsonItemMultiValueControl<double> {
     14    protected override IEnumerable<string> RowNames {
     15      get => ((DoubleNamedMatrixValueVM)VM).RowNames;
     16      set => ((DoubleNamedMatrixValueVM)VM).RowNames = value;
     17    }
     18    protected override IEnumerable<string> ColumnNames {
     19      get => ((DoubleNamedMatrixValueVM)VM).ColumnNames;
     20      set => ((DoubleNamedMatrixValueVM)VM).ColumnNames = value;
     21    }
     22
     23    public JsonItemDoubleNamedMatrixValueControl(DoubleNamedMatrixValueVM vm) : base(vm, vm.Value) { }
     24
     25    protected override void SaveCellData(double data, int row, int col) {
     26      DoubleNamedMatrixValueVM vm = VM as DoubleNamedMatrixValueVM;
     27      vm.SetCellValue(data, row, col);
     28    }
     29  }
     30
    1331  public class JsonItemDoubleMatrixValueControl : JsonItemMultiValueControl<double> {
     32    protected override IEnumerable<string> RowNames { get => null; set { } }
     33    protected override IEnumerable<string> ColumnNames { get => null; set { } }
    1434
    1535    public JsonItemDoubleMatrixValueControl(DoubleMatrixValueVM vm) : base(vm, vm.Value) { }
     36
    1637    protected override void SaveCellData(double data, int row, int col) {
    1738      DoubleMatrixValueVM vm = VM as DoubleMatrixValueVM;
     
    2142
    2243  public class JsonItemIntArrayValueControl : JsonItemMultiValueControl<int> {
     44    protected override IEnumerable<string> RowNames { get => null; set { } }
     45    protected override IEnumerable<string> ColumnNames { get => null; set { } }
     46
    2347    public JsonItemIntArrayValueControl(IntArrayValueVM vm) : base(vm, vm.Value) { }
    2448
     
    3054
    3155  public class JsonItemDoubleArrayValueControl : JsonItemMultiValueControl<double> {
     56    protected override IEnumerable<string> RowNames { get => null; set { } }
     57    protected override IEnumerable<string> ColumnNames { get => null; set { } }
     58
    3259    public JsonItemDoubleArrayValueControl(DoubleArrayValueVM vm) : base(vm, vm.Value) { }
    3360
     
    6087    private T[][] Matrix { get; set; }
    6188
     89    protected abstract IEnumerable<string> RowNames { get; set; }
     90    protected abstract IEnumerable<string> ColumnNames { get; set; }
     91
    6292    public JsonItemMultiValueControl(IMatrixJsonItemVM vm, T[][] matrix) : base(vm) {
    6393      InitializeComponent();
     
    6696      checkBoxColumns.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.ColumnsResizable));
    6797
    68       int rows = matrix.Length;
    69       int cols = matrix.Max(x => x.Length);
     98      int cols = matrix.Length;
     99      int rows = matrix.Max(x => x.Length);
    70100
    71101      Matrix = matrix;
     
    85115      int length = array.Length;
    86116
    87       Matrix = new T[array.Length][];
     117      Matrix = new T[1][];
     118      Matrix[0] = array;
     119      /*
    88120      for (int r = 0; r < length; ++r) {
    89121        Matrix[r] = new T[1];
    90122        Matrix[r][0] = array[r];
    91123      }
    92 
     124      */
    93125      _cols = 1;
    94126      _rows = length;
     
    125157
    126158      T[][] tmp = Matrix;
    127       Matrix = new T[Rows][];
     159      Matrix = new T[Columns][];
    128160
    129161      // columns must added first
    130       for(int c = 0; c < Columns; ++c) {
    131         dataGridView.Columns.Add($"Column {c}", $"Column {c}");
    132       }
    133 
    134       for (int r = 0; r < Rows; ++r) {
    135         T[] newCol = new T[Columns];
    136         if(r < tmp.Length)
    137           Array.Copy(tmp[r], 0, newCol, 0, Math.Min(tmp[r].Length, Columns));
    138         Matrix[r] = newCol;
     162      if(RowNames != null && RowNames.Count() == Columns) {
     163        foreach(var name in RowNames) {
     164          dataGridView.Columns.Add(name, name);
     165        }
     166      } else {
     167        for(int c = 0; c < Columns; ++c) {
     168          dataGridView.Columns.Add($"Column {c}", $"Column {c}");
     169        }
     170      }
     171
     172      for (int c = 0; c < Columns; ++c) {
     173        T[] newCol = new T[Rows];
     174        if(c < tmp.Length)
     175          Array.Copy(tmp[c], 0, newCol, 0, Math.Min(tmp[c].Length, Rows));
     176        Matrix[c] = newCol;
    139177      }
    140178
     
    144182          for (int r = 0; r < Rows; ++r) {
    145183            //col and row is switched for dataGridView
    146             dataGridView[c, r].Value = Matrix[r][c];
    147             dataGridView.Rows[r].HeaderCell.Value = $"Row {r}";
     184            dataGridView[c, r].Value = Matrix[c][r];
     185            if (ColumnNames != null && r < ColumnNames.Count())
     186              dataGridView.Rows[r].HeaderCell.Value = ColumnNames.ElementAt(r);
     187            else
     188              dataGridView.Rows[r].HeaderCell.Value = $"Row {r}";
    148189          }
    149190        }
     
    214255    private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
    215256      object val = dataGridView[e.ColumnIndex, e.RowIndex].Value;
    216       Matrix[e.RowIndex][e.ColumnIndex] = (T)Convert.ChangeType(val.ToString().Replace(",", "."),
     257      Matrix[e.ColumnIndex][e.RowIndex] = (T)Convert.ChangeType(val.ToString().Replace(",", "."),
    217258                                            typeof(T),
    218259                                            System.Globalization.CultureInfo.InvariantCulture);
    219       SaveCellData(Matrix[e.RowIndex][e.ColumnIndex], e.RowIndex, e.ColumnIndex);
     260      SaveCellData(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex);
    220261    }
    221262  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs

    r17444 r17451  
    2727      IAlgorithm algorithm = value as IAlgorithm;
    2828      foreach (var res in algorithm.Results) {
    29         item.AddChildren(new ResultItem() {
     29        item.AddChildren(new ResultJsonItem() {
    3030          Name = res.Name,
    3131          Description = res.Description
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs

    r17433 r17451  
    11using System;
     2using System.Collections;
    23using System.Collections.Generic;
    34using System.Linq;
     
    78using HeuristicLab.Core;
    89using HeuristicLab.Data;
     10using Newtonsoft.Json.Linq;
    911
    1012namespace HeuristicLab.JsonInterface {
     
    1517
    1618    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    17       // TODO: inject data
    18       throw new NotImplementedException();
     19      //Dictionary<string, IList<double>> dict = null;
     20      var dictTmp = new Dictionary<string, IList>();
     21      /*if (data.Children[0].Value is JObject jObj) {
     22        dict = jObj.ToObject<Dictionary<string, IList<double>>>();
     23        foreach (var x in dict) {
     24          dictTmp.Add(x.Key, (IList)x.Value);
     25        }
     26      } else if(data.Children[0].Value is Dictionary<string, IList<double>> d) {
     27        dict = d;
     28      } else {
     29        dictTmp = (Dictionary<string, IList>)data.Children[0].Value;
     30      }
     31      */
     32      DoubleNamedMatrixJsonItem matrix = data.Children[0] as DoubleNamedMatrixJsonItem;
     33      if(matrix != null) {
     34        int c = 0;
     35        foreach(var col in matrix.RowNames) {
     36          dictTmp.Add(col, new List<double>(matrix.Value[c]));
     37          ++c;
     38        }
     39      }
     40
     41      dynamic val = (dynamic)item;
     42      object dataset = (object)val.Dataset;
     43      var dataInfo = dataset.GetType().GetField("variableValues", flags);
     44      dataInfo.SetValue(dataset, dictTmp);
     45      val.TargetVariable = (string)data.Children[3].Value;
     46      val.TrainingPartition.Start = ((IntRangeJsonItem)data.Children[2]).Value.First();
     47      val.TrainingPartition.End = ((IntRangeJsonItem)data.Children[2]).Value.Last();
     48      val.TestPartition.Start = ((IntRangeJsonItem)data.Children[1]).Value.First();
     49      val.TestPartition.End = ((IntRangeJsonItem)data.Children[1]).Value.Last();
    1950    }
    2051
     
    2859      object dataset = (object)val.Dataset;
    2960      dynamic targetVariable = val.TargetVariable;
    30       FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
    31       // TODO: aufteilen in trainings und test daten abschnitte
    32       item.AddChildren(new JsonItem() {
    33         Name = "Dataset",
    34         Value = dataInfo.GetValue(dataset)
     61     
     62      FieldInfo dataInfo = dataset.GetType().GetField("variableValues", flags);
     63     
     64      if(dataInfo.GetValue(dataset) is Dictionary<string, IList> dict) {
     65        int cols = dict.Count;
     66        int rows = 0;
     67        IList<string> rowNames = new List<string>();
     68        double[][] mat = new double[cols][];
     69        int c = 0;
     70        foreach(var x in dict) {
     71          rows = Math.Max(rows, x.Value.Count);
     72          rowNames.Add(x.Key);
     73          mat[c] = new double[rows];
     74          int r = 0;
     75          foreach(var rowValue in x.Value) {
     76            mat[c][r] = (double)rowValue;
     77            ++r;
     78          }
     79          ++c;
     80        }
     81        item.AddChildren(new DoubleNamedMatrixJsonItem() {
     82          Name = "Dataset",
     83          Value = mat,
     84          RowNames = rowNames
     85        });
     86      }
     87
     88      var trainingPartition = ((IntRange)val.TrainingPartition);
     89      var testPartition = ((IntRange)val.TestPartition);
     90
     91      item.AddChildren(new IntRangeJsonItem() {
     92        Name = "TestPartition",
     93        Value = new int[] { testPartition.Start, testPartition.End },
     94        Range = new int[] { 0, Math.Max(testPartition.End, trainingPartition.End) }
     95      });
     96
     97     
     98      item.AddChildren(new IntRangeJsonItem() {
     99        Name = "TrainingPartition",
     100        Value = new int[] { trainingPartition.Start, trainingPartition.End },
     101        Range = new int[] { 0, Math.Max(testPartition.End, trainingPartition.End)}
    35102      });
    36103
     
    42109      });
    43110
    44 
    45       item.AddChildren(new JsonItem() {
     111      /*
     112      item.AddChildren(new StringArrayJsonItem() {
    46113        Name = "AllowedInputVariables",
    47         Value = (object)val.AllowedInputVariables,
     114        Value = (string[])val.AllowedInputVariables,
    48115        Range = variables.Select(x => x.Value)
    49       });
     116      });*/
    50117      return item;
    51118    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs

    r17446 r17451  
    1515    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
    1616      IResultParameter res = value as IResultParameter;
    17       return new ResultItem() {
     17      return new ResultJsonItem() {
    1818        Name = res.ActualName,
    1919        ActualName = res.ActualName,
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs

    r17433 r17451  
    2727        item = tmp;
    2828      } else {
    29         item.Range = new object[] { GetMinValue(param.DataType), GetMaxValue(param.DataType) };
     29        var min = GetMinValue(param.DataType);
     30        var max = GetMaxValue(param.DataType);
     31        if (min != null && max != null)
     32          item.Range = new object[] { min, max };
     33        else
     34          item.Range = null;
    3035      }
    3136      item.Name = param.Name;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs

    r17433 r17451  
    1717    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    1818      IntRange range = item as IntRange;
    19       IntArrayJsonItem cdata = data as IntArrayJsonItem;
     19      IntRangeJsonItem cdata = data as IntRangeJsonItem;
    2020      range.Start = cdata.Value[0];
    2121      range.End = cdata.Value[1];
     
    3939    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    4040      DoubleRange range = item as DoubleRange;
    41       DoubleArrayJsonItem cdata = data as DoubleArrayJsonItem;
     41      DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem;
    4242      range.Start = cdata.Value[0];
    4343      range.End = cdata.Value[1];
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs

    r17433 r17451  
    4040    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    4141      DoubleArray arr = item as DoubleArray;
    42       double[] d = CastValue<double[]>(data);
     42      DoubleArrayJsonItem doubleItem = data as DoubleArrayJsonItem;
     43      //double[] d = CastValue<double[]>(data);
    4344      bool resizeTmp = arr.Resizable;
    4445      arr.Resizable = true;
    45       arr.Length = d.Length;
    46       for (int i = 0; i < d.Length; ++i)
    47         arr[i] = d[i];
     46      //arr.Length = d.Length;
     47      arr.Length = doubleItem.Value.Length;
     48      for (int i = 0; i < doubleItem.Value.Length; ++i)
     49        arr[i] = doubleItem.Value[i];
    4850      arr.Resizable = resizeTmp;
    4951    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs

    r17433 r17451  
    3333    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    3434      DoubleMatrix mat = item as DoubleMatrix;
    35       DoubleMatrixJsonItem d = data as DoubleMatrixJsonItem;
     35      DoubleNamedMatrixJsonItem d = data as DoubleNamedMatrixJsonItem;
    3636      CopyMatrixData(mat, d.Value);
    3737    }
    3838
    3939    public override IJsonItem Extract(IItem value, IJsonItemConverter root) =>
    40       new DoubleMatrixJsonItem() {
     40      new DoubleNamedMatrixJsonItem() {
    4141        Name = "[OverridableParamName]",
    4242        Description = value.ItemDescription,
    4343        Value = Transform((DoubleMatrix)value),
    44         Range = new double[] { double.MinValue, double.MaxValue }
     44        Range = new double[] { double.MinValue, double.MaxValue },
     45        RowNames = ((DoubleMatrix)value).RowNames,
     46        ColumnNames = ((DoubleMatrix)value).ColumnNames
    4547      };
    4648  }
     
    9092    #region Helper
    9193    protected void CopyMatrixData(MatrixType matrix, T[][] data) {
    92       var rows = data.Length;
    93       var cols = data.Length > 0 ? data[0].Length : 0;
     94      var cols = data.Length;
     95      var rows = data.Length > 0 ? data[0].Length : 0;
    9496
    9597      var rowInfo = matrix.GetType().GetProperty("Rows");
     
    100102      for (int x = 0; x < rows; ++x) {
    101103        for (int y = 0; y < cols; ++y) {
    102           matrix[x, y] = data[x][y];
     104          matrix[x, y] = data[y][x];
    103105        }
    104106      }
     
    106108
    107109    protected T[][] Transform(MatrixType matrix) {
    108       T[][] m = new T[matrix.Rows][];
    109       for (int r = 0; r < matrix.Rows; ++r) {
    110         m[r] = new T[matrix.Columns];
    111         for (int c = 0; c < matrix.Columns; ++c) {
    112           m[r][c] = matrix[r, c];
     110      T[][] m = new T[matrix.Columns][];
     111      for (int column = 0; column < matrix.Columns; ++column) {
     112        m[column] = new T[matrix.Rows];
     113        for (int row = 0; row < matrix.Rows; ++row) {
     114          m[column][row] = matrix[row, column];
    113115        }
    114116      }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj

    r17446 r17451  
    7171    <Compile Include="Interfaces\IJsonItemValidator.cs" />
    7272    <Compile Include="Interfaces\IMatrixJsonItem.cs" />
     73    <Compile Include="Interfaces\INamedMatrixJsonItem.cs" />
    7374    <Compile Include="Models\ArrayJsonItemBase.cs" />
    7475    <Compile Include="Models\BoolJsonItems.cs" />
     
    7980    <Compile Include="Models\JsonItem.cs" />
    8081    <Compile Include="Models\MatrixJsonItemBase.cs" />
    81     <Compile Include="Models\ResultItem.cs" />
     82    <Compile Include="Models\NamedMatrixJsonItemBase.cs" />
     83    <Compile Include="Models\ResultJsonItem.cs" />
    8284    <Compile Include="Models\StringJsonItem.cs" />
    8385    <Compile Include="Models\UnsupportedJsonItem.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs

    r17446 r17451  
    99namespace HeuristicLab.JsonInterface {
    1010  public interface IJsonItem {
     11    bool Active { get; set; }
    1112    string Name { get; set; }
    1213
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs

    r17439 r17451  
    4141      // filter result items
    4242      foreach (var item in jsonItems) {
    43         if (item is ResultItem)
     43        if (item is ResultJsonItem)
    4444          resultItems.Add(Serialize(item));
    4545        else
     
    6060    // serializes ParameterizedItems and saves them in list "JsonItems".
    6161    private void PopulateJsonItems(IJsonItem item, IList<IJsonItem> jsonItems) {
    62       IEnumerable<IJsonItem> tmpParameter = item.Children;
     62      IEnumerable<IJsonItem> children = item.Children;
    6363     
    64       if (item.Value != null || item.Range != null || item is ResultItem || item.ActualName != null) {
     64      if (item.Active && (item.Value != null || item.Range != null || item is ResultJsonItem || item.ActualName != null)) {
    6565        jsonItems.Add(item);
    6666      }
    6767
    68       if (tmpParameter != null) {
    69         foreach (var p in tmpParameter) {
     68      if (children != null) {
     69        foreach (var p in children) {
    7070          PopulateJsonItems(p, jsonItems);
    7171        }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DoubleJsonItems.cs

    r17446 r17451  
    2323    }
    2424  }
     25
     26  public class DoubleNamedMatrixJsonItem : NamedMatrixJsonItemBase<double> {
     27    protected override bool IsInRange() {
     28      for (int c = 0; c < Value.Length; ++c) {
     29        for (int r = 0; r < Value[c].Length; ++r) {
     30          if (Value[c][r] < Range.First() && Range.Last() < Value[c][r])
     31            return false;
     32        }
     33      }
     34      return true;
     35    }
     36  }
    2537}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntJsonItems.cs

    r17446 r17451  
    66
    77namespace HeuristicLab.JsonInterface {
    8   public class IntJsonItem : JsonItem<int> { }
     8  public class IntJsonItem : JsonItem<int> {
     9    /*I
     10    public int MinValue { get; set; }
     11    public int MaxValue { get; set; }
     12    */
     13  }
    914  public class IntArrayJsonItem : ArrayJsonItemBase<int> { }
    1015  public class IntRangeJsonItem : ArrayJsonItemBase<int> {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs

    r17446 r17451  
    6666    public virtual IEnumerable<object> Range { get; set; }
    6767   
     68    // TODO eigene items für LookUp?
    6869    public virtual string ActualName { get; set; }
     70
     71    // TODO jsonIgnore dataType?
    6972
    7073    [JsonIgnore]
     
    7376    [JsonIgnore]
    7477    public virtual IJsonItem Parent { get; set; }
     78
     79    [JsonIgnore]
     80    public virtual bool Active { get; set; }
    7581
    7682    #region Constructors
     
    8187    }
    8288    #endregion
    83 
    84     #region Public Static Methods
    85     public static void Merge(JsonItem target, JsonItem from) {
    86       target.Name = from.Name ?? target.Name;
    87       target.Range = from.Range ?? target.Range;
    88       target.Value = from.Value ?? target.Value;
    89       target.ActualName = from.ActualName ?? target.ActualName;
    90       if(target.Children != null) {
    91         if (from.Children != null)
    92           ((List<IJsonItem>)from.Children).AddRange(target.Children);
    93       } else {
    94         target.Children = from.Children;
    95       }
    96     }
    97     #endregion
    98 
     89   
    9990    #region Public Methods
    10091    public void AddChildren(params IJsonItem[] childs) =>
     
    124115
    125116    #region Helper
     117    /*
     118     * TODO protected abstract bool Validate();
     119     */
     120
    126121    protected virtual bool IsInRange() {
    127122      bool b1 = true, b2 = true;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ResultJsonItem.cs

    r17450 r17451  
    66
    77namespace HeuristicLab.JsonInterface {
    8   public class ResultItem : JsonItem {
     8  public class ResultJsonItem : JsonItem {
    99
    1010  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/StringJsonItem.cs

    r17446 r17451  
    77namespace HeuristicLab.JsonInterface {
    88  public class StringJsonItem : JsonItem<string> { }
     9  public class StringArrayJsonItem : JsonItem<string[], string> { }
    910}
  • branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs

    r17442 r17451  
    4343      SymbolicRegressionSingleObjectiveProblem prop = new SymbolicRegressionSingleObjectiveProblem();
    4444     
    45       alg.Problem = tsp;
     45      alg.Problem = prop;
     46
     47      IJsonItem root = JsonItemConverter.Extract(alg);
     48      var x = root.Children[0];
     49      root.Children.Remove(x);
     50      x.Parent = null;
     51
    4652
    4753      JCGenerator generator = new JCGenerator();
    48       generator.GenerateTemplate(@"C:\Workspace", "Template", alg);
     54      generator.GenerateTemplate(@"C:\Workspace", "Template", alg, root);
    4955      //JsonTemplateInstantiator.Instantiate(@"C:\Workspace\Template.json");
    5056     
Note: See TracChangeset for help on using the changeset viewer.