- Timestamp:
- 04/27/20 15:53:26 (4 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 8 added
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
r17477 r17519 16 16 internal static class Runner { 17 17 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; 21 22 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 28 33 WriteResultsToFile(outputFile, optimizer, configuredResultItem); 29 Thread.Sleep(100); 34 } catch (Exception e) { 35 File.WriteAllText(outputFile, e.Message + "\n\n\n\n" + e.StackTrace); 30 36 } 31 32 WriteResultsToFile(outputFile, optimizer, configuredResultItem);33 37 } 34 38 … … 47 51 if (configuredResults.Contains(res.Key)) { 48 52 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 */ 49 57 var formatter = new SymbolicDataAnalysisExpressionMATLABFormatter(); 50 58 var x = formatter.Format(solution.Model.SymbolicExpressionTree); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj
r17471 r17519 108 108 </Compile> 109 109 <Compile Include="ViewModels\ArrayValueVM.cs" /> 110 <Compile Include="ViewModels\DoubleVMs.cs" /> 111 <Compile Include="ViewModels\IntVMs.cs" /> 110 112 <Compile Include="ViewModels\JsonItemVMBase.cs" /> 111 113 <Compile Include="ViewModels\LookupJsonItemVM.cs" /> … … 117 119 <Compile Include="ViewModels\StringValueVM.cs" /> 118 120 <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> 119 127 <Compile Include="Views\ExportJsonDialog.cs"> 120 128 <SubType>Form</SubType> … … 124 132 </Compile> 125 133 <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> 126 140 <Compile Include="Views\JsonItemMultiValueControl.cs"> 127 141 <SubType>UserControl</SubType> … … 224 238 <DependentUpon>NumericRangeControl.cs</DependentUpon> 225 239 </EmbeddedResource> 240 <EmbeddedResource Include="Shared\ConcreteItemsRestrictor.resx"> 241 <DependentUpon>ConcreteItemsRestrictor.cs</DependentUpon> 242 </EmbeddedResource> 226 243 <EmbeddedResource Include="Views\ExportJsonDialog.resx"> 227 244 <DependentUpon>ExportJsonDialog.cs</DependentUpon> 245 </EmbeddedResource> 246 <EmbeddedResource Include="Views\JsonItemConcreteItemArrayControl.resx"> 247 <DependentUpon>JsonItemConcreteItemArrayControl.cs</DependentUpon> 228 248 </EmbeddedResource> 229 249 <EmbeddedResource Include="Views\JsonItemMultiValueControl.resx"> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs
r17484 r17519 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 10 11 public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> { 12 public override Type TargetedJsonItemType => typeof(DoubleArrayJsonItem); 11 13 12 14 protected override double MinTypeValue => double.MinValue;15 13 16 protected override double MaxTypeValue => double.MaxValue;17 14 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); 32 18 33 19 protected override int MinTypeValue => int.MinValue; … … 37 23 public override UserControl Control => 38 24 new JsonItemBaseControl(this, new JsonItemIntArrayValueControl(this)); 39 25 40 26 public override int[] Value { 41 27 get => Item.Value; … … 46 32 } 47 33 } 34 */ 35 48 36 49 37 public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IArrayJsonItemVM -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs
r17477 r17519 9 9 10 10 namespace 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? 12 12 where JsonItemType : class, IJsonItem 13 13 { … … 58 58 } 59 59 60 public abstract Type TargetedJsonItemType { get; }60 public virtual Type TargetedJsonItemType => typeof(JsonItemType); 61 61 public abstract UserControl Control { get; } 62 62 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/LookupJsonItemVM.cs
r17473 r17519 8 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 9 public class LookupJsonItemVM : JsonItemVMBase<LookupJsonItem>, ILookupJsonItemVM { 10 public override Type TargetedJsonItemType => typeof(LookupJsonItem);11 10 12 11 public override UserControl Control => new LookupJsonItemControl(this); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs
r17484 r17519 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 10 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 }28 11 29 12 public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IMatrixJsonItemVM -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs
r17473 r17519 8 8 9 9 namespace 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 }32 10 33 11 public abstract class RangeVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs
r17473 r17519 8 8 9 9 namespace 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 }29 10 30 11 public class BoolValueVM : JsonItemVMBase<BoolJsonItem> { 31 public override Type TargetedJsonItemType => typeof(BoolJsonItem);32 12 33 13 public bool Value { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs
r17473 r17519 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 10 public class StringValueVM : JsonItemVMBase<StringJsonItem> { 11 public override Type TargetedJsonItemType => typeof(StringJsonItem);12 11 public override UserControl Control => 13 12 new JsonItemValidValuesControl(this); … … 37 36 } 38 37 } 38 } 39 39 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 } 40 59 } 41 60 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs
r17485 r17519 80 80 int cols = matrix.Length; 81 81 int rows = matrix.Max(x => x.Length); 82 82 83 83 Matrix = matrix; 84 84 Columns = cols; … … 250 250 typeof(T), 251 251 System.Globalization.CultureInfo.InvariantCulture); 252 //Save(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex);253 252 Save(); 254 253 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.Designer.cs
r17471 r17519 25 25 private void InitializeComponent() { 26 26 this.components = new System.ComponentModel.Container(); 27 this.tableOptions = new System.Windows.Forms.TableLayoutPanel();28 27 this.comboBoxValues = new System.Windows.Forms.ComboBox(); 29 28 this.label2 = new System.Windows.Forms.Label(); 30 29 this.groupBoxRange = new System.Windows.Forms.GroupBox(); 30 this.concreteItemsRestrictor = new HeuristicLab.JsonInterface.OptimizerIntegration.ConcreteItemsRestrictor(); 31 31 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 32 32 this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); … … 37 37 this.tableLayoutPanel2.SuspendLayout(); 38 38 this.SuspendLayout(); 39 //40 // tableOptions41 //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;55 39 // 56 40 // comboBoxValues … … 79 63 // groupBoxRange 80 64 // 81 this.groupBoxRange.Controls.Add(this. tableOptions);65 this.groupBoxRange.Controls.Add(this.concreteItemsRestrictor); 82 66 this.groupBoxRange.Dock = System.Windows.Forms.DockStyle.Fill; 83 67 this.groupBoxRange.Location = new System.Drawing.Point(0, 22); … … 88 72 this.groupBoxRange.TabStop = false; 89 73 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; 90 83 // 91 84 // errorProvider … … 122 115 this.tableLayoutPanel2.RowCount = 1; 123 116 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, 2 0F));117 this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F)); 125 118 this.tableLayoutPanel2.Size = new System.Drawing.Size(500, 22); 126 119 this.tableLayoutPanel2.TabIndex = 19; … … 146 139 147 140 #endregion 148 private System.Windows.Forms.TableLayoutPanel tableOptions;149 141 private System.Windows.Forms.ComboBox comboBoxValues; 150 142 private System.Windows.Forms.Label label2; … … 153 145 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; 154 146 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 147 private ConcreteItemsRestrictor concreteItemsRestrictor; 155 148 } 156 149 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs
r17473 r17519 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 1 using System.Collections.Generic; 4 2 using System.Drawing; 5 using System.Data;6 3 using System.Linq; 7 using System.Text;8 using System.Threading.Tasks;9 4 using System.Windows.Forms; 10 5 … … 18 13 VM = vm; 19 14 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); 22 18 comboBoxValues.DataBindings.Add("SelectedItem", VM, nameof(StringValueVM.Value)); 23 19 } else { 24 comboBoxValues.Hide();25 20 groupBoxRange.Hide(); 26 21 TextBox tb = new TextBox(); 27 this.Controls.Add(tb); 22 tableLayoutPanel2.Controls.Remove(comboBoxValues); 23 tableLayoutPanel2.Controls.Add(tb, 1, 0); 24 28 25 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 32 31 tb.DataBindings.Add("Text", VM, nameof(StringValueVM.Value)); 33 32 tb.Show(); 34 33 } 35 34 } 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;45 35 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) { 60 37 comboBoxValues.Items.Add(opt); 61 38 IList<string> items = new List<string>(); … … 63 40 items.Add((string)i); 64 41 } 65 ((StringValueVM)VM).Range = items;42 VM.Range = items; 66 43 comboBoxValues.Enabled = true; 67 tableOptions.Refresh();68 44 } 69 45 70 private void RemoveComboOption( stringopt) {46 private void RemoveComboOption(object opt) { 71 47 comboBoxValues.Items.Remove(opt); 72 48 IList<string> items = new List<string>(); … … 74 50 items.Add((string)i); 75 51 } 76 ((StringValueVM)VM).Range = items;77 if ( ((StringValueVM)VM).Range.Count() <= 0) {52 VM.Range = items; 53 if (VM.Range.Count() <= 0) { 78 54 comboBoxValues.Enabled = false; 79 55 comboBoxValues.SelectedIndex = -1; 80 56 } 81 tableOptions.Refresh();82 57 } 83 58 } -
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 { 1 namespace HeuristicLab.JsonInterface { 8 2 /// <summary> 9 3 /// Constants for reading/writing templates. -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17484 r17519 8 8 using HeuristicLab.Core; 9 9 using HeuristicLab.Data; 10 using HeuristicLab.Parameters; 10 11 using Newtonsoft.Json.Linq; 11 12 12 13 namespace HeuristicLab.JsonInterface { 13 14 public class RegressionProblemDataConverter : BaseConverter { 15 #region Constants 14 16 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 15 31 public override int Priority => 20; 32 33 // RegressionProblemData 16 34 public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C")); 17 35 18 36 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 44 81 } 45 82 … … 50 87 }; 51 88 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; 53 174 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 }; 73 206 } 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, 91 238 MaxValue = testPartition.End, 92 Minimum = 0, 239 Minimum = 0, 93 240 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, 99 250 MinValue = trainingPartition.Start, 100 251 MaxValue = trainingPartition.End, 101 252 Minimum = 0, 102 253 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 120 272 } 121 273 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r17483 r17519 18 18 19 19 if(parameter.ActualValue != null) { 20 if (data.Children == null || data.Children.Count == 0)20 if (data.Children == null || data.Children.Count() == 0) 21 21 root.Inject(parameter.ActualValue, data, root); 22 22 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; 1 namespace HeuristicLab.JsonInterface { 6 2 7 namespace HeuristicLab.JsonInterface {8 3 public interface IArrayJsonItem : IValueJsonItem { 4 /// <summary> 5 /// Property to define an array item to be resizable. 6 /// </summary> 9 7 bool Resizable { get; set; } 10 8 } -
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; 1 using System.Collections.Generic; 6 2 7 3 namespace HeuristicLab.JsonInterface { 8 4 public interface IConcreteRestrictedJsonItem<T> : IJsonItem { 5 /// <summary> 6 /// The item, 7 /// </summary> 9 8 IEnumerable<T> ConcreteRestrictedItems { get; set; } 10 9 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IIntervalRestrictedJsonItem.cs
r17477 r17519 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 7 3 namespace HeuristicLab.JsonInterface { 4 /// <summary> 5 /// Interface to get a interval restrict JsonItems. 6 /// </summary> 7 /// <typeparam name="T"></typeparam> 8 8 public interface IIntervalRestrictedJsonItem<T> : IJsonItem 9 9 where T : IComparable { 10 /// <summary> 11 /// The allowed minimum of the JsonItem. 12 /// </summary> 10 13 T Minimum { get; set; } 14 /// <summary> 15 /// The allowed maximum of the JsonItem. 16 /// </summary> 11 17 T Maximum { get; set; } 12 18 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs
r17477 r17519 11 11 [JsonObject] 12 12 public interface IJsonItem : IEnumerable<IJsonItem> { 13 /// <summary> 14 /// Only active items are included in templates. 15 /// </summary> 13 16 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> 14 22 string Name { get; set; } 15 23 24 /// <summary> 25 /// A description for the JsonItem. 26 /// </summary> 16 27 string Description { get; set; } 17 28 18 string Path { 19 get; 20 } 29 /// <summary> 30 /// The JsonItem path in the related object graph. 31 /// </summary> 32 string Path { get; } 21 33 34 /// <summary> 35 /// IEnumerable of all sub JsonItems. 36 /// </summary> 22 37 [JsonIgnore] 23 I List<IJsonItem> Children { get; } //TODO: IEnumerable38 IEnumerable<IJsonItem> Children { get; } 24 39 40 /// <summary> 41 /// If the JsonItem is a children of an other JsonItem, the parent will be this other JsonItem. 42 /// </summary> 25 43 [JsonIgnore] 26 44 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> 28 50 IJsonItemValidator GetValidator(); 29 51 52 /// <summary> 53 /// Add sub JsonItems. 54 /// </summary> 55 /// <param name="childs"></param> 30 56 void AddChildren(params IJsonItem[] childs); 31 32 57 void AddChildren(IEnumerable<IJsonItem> childs); 33 58 … … 44 69 void LoosenPath(); 45 70 71 /// <summary> 72 /// Method to generate a Newtonsoft JObject, which describes the JsonItem. 73 /// </summary> 74 /// <returns>Newtonsoft JObject</returns> 46 75 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> 47 81 void SetJObject(JObject jObject); 48 82 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItemConverter.cs
r17406 r17519 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using HeuristicLab.Core; 7 using Newtonsoft.Json.Linq;8 3 9 4 namespace HeuristicLab.JsonInterface { … … 25 20 IJsonItem Extract(IItem value, IJsonItemConverter root); 26 21 22 /// <summary> 23 /// The targeted type for the converter. 24 /// </summary> 27 25 Type ConvertableType { get; } 26 27 /// <summary> 28 /// A given priority, higher numbers are prior. 29 /// </summary> 28 30 int Priority { get; } 29 31 } -
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 { 1 namespace HeuristicLab.JsonInterface { 8 2 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> 9 11 ValidationResult Validate(); 10 12 } -
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 { 1 namespace HeuristicLab.JsonInterface { 8 2 public interface ILookupJsonItem : IJsonItem { 3 /// <summary> 4 /// The actual name for lookup items. 5 /// </summary> 9 6 string ActualName { get; set; } 10 7 } -
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; 1 using System.Collections.Generic; 6 2 7 3 namespace HeuristicLab.JsonInterface { 8 4 public interface IMatrixJsonItem : IValueJsonItem { 5 /// <summary> 6 /// Flag to define resizable rows. 7 /// </summary> 9 8 bool RowsResizable { get; set; } 9 /// <summary> 10 /// Flag to define resizable columns. 11 /// </summary> 10 12 bool ColumnsResizable { get; set; } 13 /// <summary> 14 /// IEnumerable of row names. 15 /// </summary> 11 16 IEnumerable<string> RowNames { get; set; } 17 /// <summary> 18 /// IEnumerable of column names. 19 /// </summary> 12 20 IEnumerable<string> ColumnNames { get; set; } 13 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IRangedJsonItem.cs
r17473 r17519 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 7 3 namespace HeuristicLab.JsonInterface { … … 9 5 where T : IComparable 10 6 { 7 /// <summary> 8 /// The lower bound of an ranged item. 9 /// </summary> 11 10 T MinValue { get; set; } 11 /// <summary> 12 /// The upper bound of an ranged item. 13 /// </summary> 12 14 T MaxValue { get; set; } 13 15 } -
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 } 1 namespace 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 { } 10 7 } -
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 { 1 namespace HeuristicLab.JsonInterface { 8 2 public interface IValueJsonItem : IJsonItem { 3 /// <summary> 4 /// Represent the value of an IItem. 5 /// </summary> 9 6 object Value { get; set; } 10 7 } -
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; 1 using Newtonsoft.Json; 7 2 8 3 namespace HeuristicLab.JsonInterface { 9 4 public interface IValueLookupJsonItem : ILookupJsonItem { 5 /// <summary> 6 /// The IJsonItem representation of the actual value of an IValueLookupItem. 7 /// </summary> 10 8 [JsonIgnore] 11 9 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; 1 using System.Collections.Generic; 7 2 using HeuristicLab.Optimization; 8 using Newtonsoft.Json;9 3 using Newtonsoft.Json.Linq; 10 4 using HEAL.Attic; … … 37 31 #region Serialize HL File 38 32 ProtoBufSerializer serializer = new ProtoBufSerializer(); 39 string hlFilePath = fullPath + @"\" +templateName + ".hl";33 string hlFilePath = fullPath + templateName + ".hl"; 40 34 serializer.Serialize(optimizer, hlFilePath); 41 35 #endregion -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverter.cs
r17483 r17519 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Text;5 using System.Threading.Tasks;6 4 using HeuristicLab.Core; 7 using HeuristicLab.Data;8 using HeuristicLab.PluginInfrastructure;9 using HEAL.Attic;10 using System.Collections;11 12 5 namespace HeuristicLab.JsonInterface { 13 6 /// <summary> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverterFactory.cs
r17394 r17519 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 3 using HeuristicLab.PluginInfrastructure; 7 4 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r17483 r17519 1 using System; 2 using System.Collections; 3 using System.Collections.Generic; 1 using System.Collections.Generic; 4 2 using System.IO; 5 3 using System.Linq; 6 using System.Reflection;7 using System.Text;8 using System.Threading.Tasks;9 4 using HEAL.Attic; 10 using HeuristicLab.Core;11 using HeuristicLab.Data;12 5 using HeuristicLab.Optimization; 13 6 using Newtonsoft.Json.Linq; … … 79 72 } 80 73 81 82 74 private IEnumerable<IResultJsonItem> CollectResults() { 83 75 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; 1 using Newtonsoft.Json.Linq; 7 2 8 3 namespace 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 { 1 namespace HeuristicLab.JsonInterface { 8 2 public class BoolJsonItem : ValueJsonItem<bool> { 9 3 protected override ValidationResult Validate() => ValidationResult.Successful(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ConcreteRestrictedArrayJsonItem.cs
r17481 r17519 1 using System; 2 using System.Collections.Generic; 1 using System.Collections.Generic; 3 2 using System.Linq; 4 using System.Text;5 using System.Threading.Tasks;6 7 3 namespace HeuristicLab.JsonInterface { 8 4 public abstract class ConcreteRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IConcreteRestrictedJsonItem<T> { … … 12 8 bool res = true; 13 9 IList<string> errors = new List<string>(); 10 if (ConcreteRestrictedItems == null) return ValidationResult.Successful(); 14 11 foreach(var x in Value) { 15 12 bool tmp = false; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ConcreteRestrictedValueJsonItem.cs
r17481 r17519 1 using System; 2 using System.Collections.Generic; 1 using System.Collections.Generic; 3 2 using System.Linq; 4 using System.Text;5 using System.Threading.Tasks;6 3 7 4 namespace HeuristicLab.JsonInterface { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DateTimeJsonItem.cs
r17481 r17519 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using Newtonsoft.Json.Linq; 7 3 -
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; 1 using Newtonsoft.Json.Linq; 7 2 8 3 namespace 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 { 1 namespace HeuristicLab.JsonInterface { 8 2 public class EmptyJsonItem : JsonItem { 9 3 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; 1 using Newtonsoft.Json.Linq; 7 2 8 3 namespace HeuristicLab.JsonInterface { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntervalRestrictedArrayJsonItem.cs
r17481 r17519 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 3 using Newtonsoft.Json.Linq; 7 4 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntervalRestrictedMatrixJsonItem.cs
r17481 r17519 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 3 using Newtonsoft.Json.Linq; 7 4 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntervalRestrictedValueJsonItem.cs
r17481 r17519 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using Newtonsoft.Json.Linq; 7 3 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs
r17485 r17519 1 using System; 2 using System.Collections; 1 using System.Collections; 3 2 using System.Collections.Generic; 4 3 using System.Linq; … … 76 75 } 77 76 } 78 77 79 78 // TODO jsonIgnore dataType? 80 81 79 [JsonIgnore] 82 public virtual I List<IJsonItem> Children { get; protected set; }80 public virtual IEnumerable<IJsonItem> Children { get; protected set; } 83 81 84 82 [JsonIgnore] … … 104 102 if (Children == null) 105 103 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 } 109 109 } 110 110 } -
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; 1 using Newtonsoft.Json.Linq; 7 2 8 3 namespace 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; 1 using System.Collections.Generic; 6 2 using Newtonsoft.Json.Linq; 7 3 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/RangedJsonItem.cs
r17481 r17519 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 3 7 4 namespace 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 { 1 namespace HeuristicLab.JsonInterface { 8 2 public class ResultJsonItem : JsonItem, IResultJsonItem { 9 3 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 { 1 namespace HeuristicLab.JsonInterface { 8 2 public class StringJsonItem : ConcreteRestrictedValueJsonItem<string> { } 9 3 public class StringArrayJsonItem : ConcreteRestrictedArrayJsonItem<string> { } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/UnsupportedJsonItem.cs
r17481 r17519 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 3 using Newtonsoft.Json; 7 4 … … 23 20 24 21 [JsonIgnore] 25 public override I List<IJsonItem> Children {22 public override IEnumerable<IJsonItem> Children { 26 23 get => throw new NotSupportedException(); 27 24 protected set => throw new NotSupportedException(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ValueJsonItem.cs
r17477 r17519 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using Newtonsoft.Json.Linq; 7 3 -
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; 1 using System.Collections.Generic; 7 2 using Newtonsoft.Json.Linq; 8 3 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r17180 r17519 178 178 Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd))); 179 179 Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly())); 180 180 181 181 TransformationsParameter.Hidden = true; 182 182 -
branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs
r17483 r17519 30 30 HEAL.Attic.Mapper.StaticCache.UpdateRegisteredTypes(); 31 31 32 32 33 33 HeuristicLabJsonInterfaceAppApplication app = new HeuristicLabJsonInterfaceAppApplication(); 34 34 … … 47 47 ActivateJsonItems(root); 48 48 49 JCGenerator.GenerateTemplate(@"C:\Workspace", "Template", alg, root);50 49 50 JCGenerator.GenerateTemplate(@"C:\Workspace\ConfigStarter\", "Template", alg, root); 51 52 51 53 List<ICommandLineArgument> arguments = new List<ICommandLineArgument>(); 52 54 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")); 56 58 57 59 app.Run(arguments.ToArray()); … … 65 67 i.Active = true; 66 68 } 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 }*/ 67 77 } 68 78 }
Note: See TracChangeset
for help on using the changeset viewer.