- Timestamp:
- 02/25/20 17:18:00 (5 years ago)
- 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 38 38 </PropertyGroup> 39 39 <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> 40 46 <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> 41 47 <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> … … 43 49 <Reference Include="System" /> 44 50 <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> 45 55 <Reference Include="System.Xml.Linq" /> 46 56 <Reference Include="System.Data.DataSetExtensions" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
r17442 r17451 22 22 Thread.Sleep(100); 23 23 } 24 24 25 WriteResultsToFile(outputFile, optimizer, allowedResultNames); 25 26 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj
r17446 r17451 81 81 <Compile Include="Interfaces\IJsonItemVM.cs" /> 82 82 <Compile Include="Interfaces\IMatrixJsonItemVM.cs" /> 83 <Compile Include="Interfaces\INamedMatrixJsonItemVM.cs" /> 83 84 <Compile Include="Properties\Resources.Designer.cs"> 84 85 <AutoGen>True</AutoGen> … … 101 102 <Compile Include="ViewModels\JsonItemVMBase.cs" /> 102 103 <Compile Include="ViewModels\MatrixValueVM.cs" /> 104 <Compile Include="ViewModels\NamedMatrixValueVM.cs" /> 103 105 <Compile Include="ViewModels\RangedValueBaseVM.cs" /> 104 106 <Compile Include="ViewModels\RangeVM.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs
r17446 r17451 39 39 public virtual Type JsonItemType => typeof(JsonItem); 40 40 41 private bool selected = true;41 42 42 public bool Selected { 43 get => selected;43 get => Item.Active; 44 44 set { 45 selected= value;45 Item.Active = value; 46 46 if(TreeNode != null) { 47 TreeNode.ForeColor = ( selected ? Color.Black : Color.Red);47 TreeNode.ForeColor = (Selected ? Color.Black : Color.Red); 48 48 TreeNode.Checked = value; 49 49 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs
r17446 r17451 7 7 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 8 8 public class ResultItemVM : JsonItemVMBase { 9 public override Type JsonItemType => typeof(Result Item);9 public override Type JsonItemType => typeof(ResultJsonItem); 10 10 public override JsonItemBaseControl Control => 11 11 new JsonItemBaseControl(this); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs
r17446 r17451 30 30 this.groupBoxDetails = new System.Windows.Forms.GroupBox(); 31 31 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(); 34 33 this.treeViewResults = new System.Windows.Forms.TreeView(); 34 this.groupBox = new System.Windows.Forms.GroupBox(); 35 this.panelResultDetails = new System.Windows.Forms.Panel(); 35 36 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 36 37 this.tabControl1 = new System.Windows.Forms.TabControl(); … … 40 41 this.textBoxTemplateName = new System.Windows.Forms.TextBox(); 41 42 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();45 43 this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components); 46 44 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(); 48 50 ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); 49 51 this.splitContainer2.Panel1.SuspendLayout(); … … 54 56 this.tabPage2.SuspendLayout(); 55 57 ((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();61 58 ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit(); 62 59 this.SuspendLayout(); … … 85 82 this.treeView.Location = new System.Drawing.Point(0, 6); 86 83 this.treeView.Name = "treeView"; 87 this.treeView.Size = new System.Drawing.Size(3 70, 493);84 this.treeView.Size = new System.Drawing.Size(380, 492); 88 85 this.treeView.TabIndex = 3; 89 86 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); … … 95 92 this.groupBoxDetails.Location = new System.Drawing.Point(0, 0); 96 93 this.groupBoxDetails.Name = "groupBoxDetails"; 97 this.groupBoxDetails.Size = new System.Drawing.Size(4 22, 499);94 this.groupBoxDetails.Size = new System.Drawing.Size(412, 499); 98 95 this.groupBoxDetails.TabIndex = 4; 99 96 this.groupBoxDetails.TabStop = false; … … 106 103 this.panelParameterDetails.Location = new System.Drawing.Point(3, 16); 107 104 this.panelParameterDetails.Name = "panelParameterDetails"; 108 this.panelParameterDetails.Size = new System.Drawing.Size(4 16, 480);105 this.panelParameterDetails.Size = new System.Drawing.Size(406, 480); 109 106 this.panelParameterDetails.TabIndex = 0; 110 107 // 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; 134 125 // 135 126 // treeViewResults 136 127 // 137 128 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); 139 131 this.treeViewResults.Name = "treeViewResults"; 140 this.treeViewResults.Size = new System.Drawing.Size( 777, 63);132 this.treeViewResults.Size = new System.Drawing.Size(380, 492); 141 133 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; 142 156 // 143 157 // splitContainer2 … … 150 164 // 151 165 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); 153 167 // 154 168 // splitContainer2.Panel2 … … 156 170 this.splitContainer2.Panel2.Controls.Add(this.groupBoxDetails); 157 171 this.splitContainer2.Size = new System.Drawing.Size(796, 499); 158 this.splitContainer2.SplitterDistance = 3 70;172 this.splitContainer2.SplitterDistance = 380; 159 173 this.splitContainer2.TabIndex = 9; 160 174 // … … 185 199 // tabPage2 186 200 // 187 this.tabPage2.Controls.Add(this. groupBox3);201 this.tabPage2.Controls.Add(this.splitContainer1); 188 202 this.tabPage2.Location = new System.Drawing.Point(4, 22); 189 203 this.tabPage2.Name = "tabPage2"; … … 219 233 this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; 220 234 this.errorProvider.ContainerControl = this; 221 //222 // splitContainer1223 //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.Panel1231 //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.Panel2236 //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 // groupBox243 //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 // panelResultDetails254 //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;261 235 // 262 236 // jsonItemBindingSource … … 278 252 this.Text = "Export Json"; 279 253 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); 281 259 this.splitContainer2.Panel1.ResumeLayout(false); 282 260 this.splitContainer2.Panel2.ResumeLayout(false); … … 287 265 this.tabPage2.ResumeLayout(false); 288 266 ((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);294 267 ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit(); 295 268 this.ResumeLayout(false); … … 307 280 private System.Windows.Forms.GroupBox groupBoxDetails; 308 281 private System.Windows.Forms.Panel panelParameterDetails; 309 private System.Windows.Forms.CheckedListBox resultItems;310 private System.Windows.Forms.GroupBox groupBox3;311 282 private System.Windows.Forms.SplitContainer splitContainer2; 312 283 private System.Windows.Forms.TabControl tabControl1; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r17446 r17451 17 17 public partial class ExportJsonDialog : Form { 18 18 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>(); 20 20 private IDictionary<TreeNode, IJsonItemVM> Node2VM { get; set; } = new Dictionary<TreeNode, IJsonItemVM>(); 21 private IDictionary<Type, Type> JI2VM { get; set; } 21 22 private IJsonItem Root { get; set; } 22 23 private IOptimizer Optimizer { get; set; } 23 24 private IList<IJsonItemVM> VMs { get; set; } 24 25 private JCGenerator Generator { get; set; } = new JCGenerator(); 25 private IDictionary<string, IJsonItem> ResultItems { get; set; } = new Dictionary<string, IJsonItem>();26 26 27 27 private IContent content; … … 33 33 VMs = new List<IJsonItemVM>(); 34 34 treeView.Nodes.Clear(); 35 ResultItems.Clear(); 36 resultItems.Items.Clear(); 35 treeViewResults.Nodes.Clear(); 37 36 38 37 Optimizer = content as IOptimizer; … … 47 46 } 48 47 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 56 49 57 private IDictionary<Type, Type> JI2VM { get; set; }58 50 59 51 private void InitCache() { … … 71 63 72 64 private void exportButton_Click(object sender, EventArgs e) { 65 // to set default value for disabled items 66 JsonItemConverter.Inject(Optimizer, Root); 67 /* 73 68 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); 76 74 } 77 75 } 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 89 78 IList<IJsonItem> faultyItems = new List<IJsonItem>(); 90 79 … … 110 99 111 100 private void BuildTreeNode(TreeNode node, IJsonItem item) { 112 RegisterItem(node, item );101 RegisterItem(node, item, treeView); 113 102 if (item.Children != null) { 114 103 foreach (var c in item.Children) { 115 104 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) { 119 106 TreeNode childNode = new TreeNode(c.Name); 120 107 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; 123 111 } else { 124 112 TreeNode childNode = new TreeNode(c.Name); … … 131 119 } 132 120 133 private void RegisterItem(TreeNode node, IJsonItem item ) {121 private void RegisterItem(TreeNode node, IJsonItem item, TreeView tv) { 134 122 if (JI2VM.TryGetValue(item.GetType(), out Type vmType)) { 135 123 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); … … 137 125 vm.Item = item; 138 126 vm.TreeNode = node; 139 vm.TreeView = t reeView;140 node.Checked = vm.Selected;127 vm.TreeView = tv; 128 vm.Selected = false; 141 129 142 130 VMs.Add(vm); 143 131 Node2VM.Add(node, vm); 144 132 UserControl control = vm.Control; 145 Hash2Control.Add(node.GetHashCode(), control);133 Node2Control.Add(node, control); 146 134 } 147 135 } … … 155 143 } 156 144 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); 158 146 } 159 147 160 148 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)) { 162 150 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); 163 157 } 164 158 } … … 170 164 } else { 171 165 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);179 166 } 180 167 } … … 191 178 panel.Refresh(); 192 179 } 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 } 193 196 } 194 197 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs
r17446 r17451 10 10 11 11 namespace 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 13 31 public class JsonItemDoubleMatrixValueControl : JsonItemMultiValueControl<double> { 32 protected override IEnumerable<string> RowNames { get => null; set { } } 33 protected override IEnumerable<string> ColumnNames { get => null; set { } } 14 34 15 35 public JsonItemDoubleMatrixValueControl(DoubleMatrixValueVM vm) : base(vm, vm.Value) { } 36 16 37 protected override void SaveCellData(double data, int row, int col) { 17 38 DoubleMatrixValueVM vm = VM as DoubleMatrixValueVM; … … 21 42 22 43 public class JsonItemIntArrayValueControl : JsonItemMultiValueControl<int> { 44 protected override IEnumerable<string> RowNames { get => null; set { } } 45 protected override IEnumerable<string> ColumnNames { get => null; set { } } 46 23 47 public JsonItemIntArrayValueControl(IntArrayValueVM vm) : base(vm, vm.Value) { } 24 48 … … 30 54 31 55 public class JsonItemDoubleArrayValueControl : JsonItemMultiValueControl<double> { 56 protected override IEnumerable<string> RowNames { get => null; set { } } 57 protected override IEnumerable<string> ColumnNames { get => null; set { } } 58 32 59 public JsonItemDoubleArrayValueControl(DoubleArrayValueVM vm) : base(vm, vm.Value) { } 33 60 … … 60 87 private T[][] Matrix { get; set; } 61 88 89 protected abstract IEnumerable<string> RowNames { get; set; } 90 protected abstract IEnumerable<string> ColumnNames { get; set; } 91 62 92 public JsonItemMultiValueControl(IMatrixJsonItemVM vm, T[][] matrix) : base(vm) { 63 93 InitializeComponent(); … … 66 96 checkBoxColumns.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.ColumnsResizable)); 67 97 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); 70 100 71 101 Matrix = matrix; … … 85 115 int length = array.Length; 86 116 87 Matrix = new T[array.Length][]; 117 Matrix = new T[1][]; 118 Matrix[0] = array; 119 /* 88 120 for (int r = 0; r < length; ++r) { 89 121 Matrix[r] = new T[1]; 90 122 Matrix[r][0] = array[r]; 91 123 } 92 124 */ 93 125 _cols = 1; 94 126 _rows = length; … … 125 157 126 158 T[][] tmp = Matrix; 127 Matrix = new T[ Rows][];159 Matrix = new T[Columns][]; 128 160 129 161 // 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; 139 177 } 140 178 … … 144 182 for (int r = 0; r < Rows; ++r) { 145 183 //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}"; 148 189 } 149 190 } … … 214 255 private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { 215 256 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(",", "."), 217 258 typeof(T), 218 259 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); 220 261 } 221 262 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs
r17444 r17451 27 27 IAlgorithm algorithm = value as IAlgorithm; 28 28 foreach (var res in algorithm.Results) { 29 item.AddChildren(new Result Item() {29 item.AddChildren(new ResultJsonItem() { 30 30 Name = res.Name, 31 31 Description = res.Description -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17433 r17451 1 1 using System; 2 using System.Collections; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 7 8 using HeuristicLab.Core; 8 9 using HeuristicLab.Data; 10 using Newtonsoft.Json.Linq; 9 11 10 12 namespace HeuristicLab.JsonInterface { … … 15 17 16 18 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(); 19 50 } 20 51 … … 28 59 object dataset = (object)val.Dataset; 29 60 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)} 35 102 }); 36 103 … … 42 109 }); 43 110 44 45 item.AddChildren(new JsonItem() {111 /* 112 item.AddChildren(new StringArrayJsonItem() { 46 113 Name = "AllowedInputVariables", 47 Value = ( object)val.AllowedInputVariables,114 Value = (string[])val.AllowedInputVariables, 48 115 Range = variables.Select(x => x.Value) 49 }); 116 });*/ 50 117 return item; 51 118 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs
r17446 r17451 15 15 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { 16 16 IResultParameter res = value as IResultParameter; 17 return new Result Item() {17 return new ResultJsonItem() { 18 18 Name = res.ActualName, 19 19 ActualName = res.ActualName, -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs
r17433 r17451 27 27 item = tmp; 28 28 } 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; 30 35 } 31 36 item.Name = param.Name; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs
r17433 r17451 17 17 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 18 18 IntRange range = item as IntRange; 19 Int ArrayJsonItem cdata = data as IntArrayJsonItem;19 IntRangeJsonItem cdata = data as IntRangeJsonItem; 20 20 range.Start = cdata.Value[0]; 21 21 range.End = cdata.Value[1]; … … 39 39 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 40 40 DoubleRange range = item as DoubleRange; 41 Double ArrayJsonItem cdata = data as DoubleArrayJsonItem;41 DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem; 42 42 range.Start = cdata.Value[0]; 43 43 range.End = cdata.Value[1]; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs
r17433 r17451 40 40 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 41 41 DoubleArray arr = item as DoubleArray; 42 double[] d = CastValue<double[]>(data); 42 DoubleArrayJsonItem doubleItem = data as DoubleArrayJsonItem; 43 //double[] d = CastValue<double[]>(data); 43 44 bool resizeTmp = arr.Resizable; 44 45 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]; 48 50 arr.Resizable = resizeTmp; 49 51 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs
r17433 r17451 33 33 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 34 34 DoubleMatrix mat = item as DoubleMatrix; 35 Double MatrixJsonItem d = data as DoubleMatrixJsonItem;35 DoubleNamedMatrixJsonItem d = data as DoubleNamedMatrixJsonItem; 36 36 CopyMatrixData(mat, d.Value); 37 37 } 38 38 39 39 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 40 new Double MatrixJsonItem() {40 new DoubleNamedMatrixJsonItem() { 41 41 Name = "[OverridableParamName]", 42 42 Description = value.ItemDescription, 43 43 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 45 47 }; 46 48 } … … 90 92 #region Helper 91 93 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; 94 96 95 97 var rowInfo = matrix.GetType().GetProperty("Rows"); … … 100 102 for (int x = 0; x < rows; ++x) { 101 103 for (int y = 0; y < cols; ++y) { 102 matrix[x, y] = data[ x][y];104 matrix[x, y] = data[y][x]; 103 105 } 104 106 } … … 106 108 107 109 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]; 113 115 } 114 116 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r17446 r17451 71 71 <Compile Include="Interfaces\IJsonItemValidator.cs" /> 72 72 <Compile Include="Interfaces\IMatrixJsonItem.cs" /> 73 <Compile Include="Interfaces\INamedMatrixJsonItem.cs" /> 73 74 <Compile Include="Models\ArrayJsonItemBase.cs" /> 74 75 <Compile Include="Models\BoolJsonItems.cs" /> … … 79 80 <Compile Include="Models\JsonItem.cs" /> 80 81 <Compile Include="Models\MatrixJsonItemBase.cs" /> 81 <Compile Include="Models\ResultItem.cs" /> 82 <Compile Include="Models\NamedMatrixJsonItemBase.cs" /> 83 <Compile Include="Models\ResultJsonItem.cs" /> 82 84 <Compile Include="Models\StringJsonItem.cs" /> 83 85 <Compile Include="Models\UnsupportedJsonItem.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs
r17446 r17451 9 9 namespace HeuristicLab.JsonInterface { 10 10 public interface IJsonItem { 11 bool Active { get; set; } 11 12 string Name { get; set; } 12 13 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs
r17439 r17451 41 41 // filter result items 42 42 foreach (var item in jsonItems) { 43 if (item is Result Item)43 if (item is ResultJsonItem) 44 44 resultItems.Add(Serialize(item)); 45 45 else … … 60 60 // serializes ParameterizedItems and saves them in list "JsonItems". 61 61 private void PopulateJsonItems(IJsonItem item, IList<IJsonItem> jsonItems) { 62 IEnumerable<IJsonItem> tmpParameter= item.Children;62 IEnumerable<IJsonItem> children = item.Children; 63 63 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)) { 65 65 jsonItems.Add(item); 66 66 } 67 67 68 if ( tmpParameter!= null) {69 foreach (var p in tmpParameter) {68 if (children != null) { 69 foreach (var p in children) { 70 70 PopulateJsonItems(p, jsonItems); 71 71 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DoubleJsonItems.cs
r17446 r17451 23 23 } 24 24 } 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 } 25 37 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntJsonItems.cs
r17446 r17451 6 6 7 7 namespace 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 } 9 14 public class IntArrayJsonItem : ArrayJsonItemBase<int> { } 10 15 public class IntRangeJsonItem : ArrayJsonItemBase<int> { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs
r17446 r17451 66 66 public virtual IEnumerable<object> Range { get; set; } 67 67 68 // TODO eigene items für LookUp? 68 69 public virtual string ActualName { get; set; } 70 71 // TODO jsonIgnore dataType? 69 72 70 73 [JsonIgnore] … … 73 76 [JsonIgnore] 74 77 public virtual IJsonItem Parent { get; set; } 78 79 [JsonIgnore] 80 public virtual bool Active { get; set; } 75 81 76 82 #region Constructors … … 81 87 } 82 88 #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 99 90 #region Public Methods 100 91 public void AddChildren(params IJsonItem[] childs) => … … 124 115 125 116 #region Helper 117 /* 118 * TODO protected abstract bool Validate(); 119 */ 120 126 121 protected virtual bool IsInRange() { 127 122 bool b1 = true, b2 = true; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ResultJsonItem.cs
r17450 r17451 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class Result Item : JsonItem {8 public class ResultJsonItem : JsonItem { 9 9 10 10 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/StringJsonItem.cs
r17446 r17451 7 7 namespace HeuristicLab.JsonInterface { 8 8 public class StringJsonItem : JsonItem<string> { } 9 public class StringArrayJsonItem : JsonItem<string[], string> { } 9 10 } -
branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs
r17442 r17451 43 43 SymbolicRegressionSingleObjectiveProblem prop = new SymbolicRegressionSingleObjectiveProblem(); 44 44 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 46 52 47 53 JCGenerator generator = new JCGenerator(); 48 generator.GenerateTemplate(@"C:\Workspace", "Template", alg );54 generator.GenerateTemplate(@"C:\Workspace", "Template", alg, root); 49 55 //JsonTemplateInstantiator.Instantiate(@"C:\Workspace\Template.json"); 50 56
Note: See TracChangeset
for help on using the changeset viewer.