- Timestamp:
- 11/04/21 17:04:01 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r18043 r18077 15 15 IParameter parameter = item as IParameter; 16 16 foreach (var x in GetValidValues(parameter)) 17 if(x.ToString() == cdata.Value )17 if(x.ToString() == cdata.Value && cdata.Active) 18 18 parameter.ActualValue = x; 19 19 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/EnumTypeConverter.cs
r18057 r18077 13 13 14 14 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 15 ((dynamic)item).Value = (dynamic)Enum.Parse( 16 item.GetType().GenericTypeArguments.First(), 17 ((StringJsonItem)data).Value); 15 if(data.Active) { 16 ((dynamic)item).Value = (dynamic)Enum.Parse( 17 item.GetType().GenericTypeArguments.First(), 18 ((StringJsonItem)data).Value); 19 } 18 20 } 19 21 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ExperimentConverter.cs
r18043 r18077 42 42 if (data.Children != null) { 43 43 foreach (var i in data.Children) { 44 if (i.Path.EndsWith("NumberOfWorkers") && i is IntJsonItem worker ) {44 if (i.Path.EndsWith("NumberOfWorkers") && i is IntJsonItem worker && i.Active) { 45 45 experiment.NumberOfWorkers = worker.Value; 46 46 } else { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ItemCollectionConverter.cs
r18055 r18077 40 40 foreach (var i in listItem.Value) { 41 41 var tmp = Instantiate(genericType); 42 root.Inject(tmp, i, root); 43 collection.Add((dynamic)tmp); 42 if (data.Active) { 43 i.Active = true; 44 root.Inject(tmp, i, root); 45 collection.Add((dynamic)tmp); 46 } 44 47 } 45 48 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/LookupParameterConverter.cs
r18043 r18077 10 10 t.GetInterfaces().Any(x => x == typeof(ILookupParameter)); 11 11 12 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 13 ((ILookupParameter)item).ActualName = ((ILookupJsonItem)data).ActualName as string; 12 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 13 if(data.Active) 14 ((ILookupParameter)item).ActualName = ((ILookupJsonItem)data).ActualName as string; 15 } 16 14 17 15 18 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs
r18043 r18077 17 17 IJsonItem childItem = GetChildItem(op.Name, data); 18 18 if(childItem != null) { 19 if(childItem is BoolJsonItem boolJsonItem ) {19 if(childItem is BoolJsonItem boolJsonItem && childItem.Active) { 20 20 val.Operators.SetItemCheckedState(op, boolJsonItem.Value); 21 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r18057 r18077 22 22 23 23 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 24 if (data.Children.All(x => !x.Active)) 25 return; 26 24 27 var parameter = item as ValueParameter<IRegressionProblemData>; 25 28 26 DoubleMatrixJsonItem dataset = null;27 StringJsonItem targetVariable = null;28 IntRangeJsonItem testPartition = null;29 IntRangeJsonItem trainingPartition = null;30 StringArrayJsonItem allowedInputVariables = null;29 DoubleMatrixJsonItem datasetItem = null; 30 StringJsonItem targetVariableItem = null; 31 IntRangeJsonItem testPartitionItem = null; 32 IntRangeJsonItem trainingPartitionItem = null; 33 StringArrayJsonItem allowedInputVariablesItem = null; 31 34 32 35 // get all child items 33 36 foreach (var child in data.Children) { 37 if (!child.Active) 38 continue; 39 34 40 if (child.Path.EndsWith(Dataset)) 35 dataset = child as DoubleMatrixJsonItem;41 datasetItem = child as DoubleMatrixJsonItem; 36 42 else if (child.Path.EndsWith(TargetVariable)) 37 targetVariable = child as StringJsonItem;43 targetVariableItem = child as StringJsonItem; 38 44 else if (child.Path.EndsWith(TestPartition)) 39 testPartition = child as IntRangeJsonItem;45 testPartitionItem = child as IntRangeJsonItem; 40 46 else if (child.Path.EndsWith(TrainingPartition)) 41 trainingPartition = child as IntRangeJsonItem;47 trainingPartitionItem = child as IntRangeJsonItem; 42 48 else if (child.Path.EndsWith(AllowedInputVariables)) 43 allowedInputVariables = child as StringArrayJsonItem;49 allowedInputVariablesItem = child as StringArrayJsonItem; 44 50 } 45 51 46 52 // check data 47 if(!dataset .ColumnNames.Any(x => x == targetVariable.Value)) {48 throw new Exception($"The value of the target variable ('{targetVariable .Value}') has no matching row name value of the dataset.");53 if(!datasetItem.ColumnNames.Any(x => x == targetVariableItem.Value)) { 54 throw new Exception($"The value of the target variable ('{targetVariableItem.Value}') has no matching row name value of the dataset."); 49 55 } 50 56 51 foreach(var v in allowedInputVariables .Value) {52 if(!dataset .ColumnNames.Any(x => x == v))57 foreach(var v in allowedInputVariablesItem.Value) { 58 if(!datasetItem.ColumnNames.Any(x => x == v)) 53 59 throw new Exception($"The value of the input variable ('{v}') has no matching row name value of the dataset."); 54 60 } 55 61 56 62 // create the new problemData object 63 var dataset = datasetItem == null ? 64 parameter.Value.Dataset : 65 new Dataset(datasetItem.ColumnNames, datasetItem.Value); 66 67 var allowedInputVariables = allowedInputVariablesItem == null ? 68 parameter.Value.AllowedInputVariables : 69 allowedInputVariablesItem.Value; 70 71 var targetVariable = targetVariableItem == null ? 72 parameter.Value.TargetVariable : 73 targetVariableItem.Value; 74 57 75 var problemData = new RegressionProblemData( 58 new Dataset(dataset.ColumnNames, dataset.Value),59 allowedInputVariables .Value,60 targetVariable .Value);76 dataset, 77 allowedInputVariables, 78 targetVariable); 61 79 62 80 // set the new problemData -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/StringValueConverter.cs
r18043 r18077 10 10 typeof(StringValue).IsAssignableFrom(t); 11 11 12 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 13 ((StringValue)item).Value = ((StringJsonItem)data).Value; 12 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 13 if(data.Active) 14 ((StringValue)item).Value = ((StringJsonItem)data).Value; 15 } 16 14 17 15 18 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs
r18045 r18077 13 13 IValueLookupParameter param = item as IValueLookupParameter; 14 14 IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem; 15 param.ActualName = lookupItem.ActualName; 15 if(data.Active) 16 param.ActualName = lookupItem.ActualName; 16 17 if (param.Value != null && lookupItem.ActualValue != null) 17 18 root.Inject(param.Value, lookupItem.ActualValue, root); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r18045 r18077 13 13 IParameter parameter = value as IParameter; 14 14 15 if (parameter.ActualValue == null )15 if (parameter.ActualValue == null && data.Active) 16 16 parameter.ActualValue = Instantiate(parameter.DataType); 17 17 root.Inject(parameter.ActualValue, data, root); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs
r17843 r18077 14 14 IntRange range = item as IntRange; 15 15 IntRangeJsonItem cdata = data as IntRangeJsonItem; 16 range.Start = cdata.MinValue; 17 range.End = cdata.MaxValue; 16 if(data.Active) { 17 range.Start = cdata.MinValue; 18 range.End = cdata.MaxValue; 19 } 18 20 } 19 21 … … 40 42 DoubleRange range = item as DoubleRange; 41 43 DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem; 42 range.Start = cdata.MinValue; 43 range.End = cdata.MaxValue; 44 if (data.Active) { 45 range.Start = cdata.MinValue; 46 range.End = cdata.MaxValue; 47 } 44 48 } 45 49 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs
r18043 r18077 12 12 13 13 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 14 IntArray arr = item as IntArray; 15 IntArrayJsonItem intArrayItem = data as IntArrayJsonItem; 16 bool resizeTmp = arr.Resizable; 17 arr.Resizable = true; 18 arr.Length = intArrayItem.Value.Length; 19 for (int i = 0; i < intArrayItem.Value.Length; ++i) 20 arr[i] = intArrayItem.Value[i]; 21 arr.Resizable = resizeTmp; 14 if(data.Active) { 15 IntArray arr = item as IntArray; 16 IntArrayJsonItem intArrayItem = data as IntArrayJsonItem; 17 bool resizeTmp = arr.Resizable; 18 arr.Resizable = true; 19 arr.Length = intArrayItem.Value.Length; 20 for (int i = 0; i < intArrayItem.Value.Length; ++i) 21 arr[i] = intArrayItem.Value[i]; 22 arr.Resizable = resizeTmp; 23 } 22 24 } 23 25 … … 39 41 40 42 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 41 DoubleArray arr = item as DoubleArray; 42 DoubleArrayJsonItem doubleArrayItem = data as DoubleArrayJsonItem; 43 bool resizeTmp = arr.Resizable; 44 arr.Resizable = true; 45 arr.Length = doubleArrayItem.Value.Length; 46 for (int i = 0; i < doubleArrayItem.Value.Length; ++i) 47 arr[i] = doubleArrayItem.Value[i]; 48 arr.Resizable = resizeTmp; 43 if(data.Active) { 44 DoubleArray arr = item as DoubleArray; 45 DoubleArrayJsonItem doubleArrayItem = data as DoubleArrayJsonItem; 46 bool resizeTmp = arr.Resizable; 47 arr.Resizable = true; 48 arr.Length = doubleArrayItem.Value.Length; 49 for (int i = 0; i < doubleArrayItem.Value.Length; ++i) 50 arr[i] = doubleArrayItem.Value[i]; 51 arr.Resizable = resizeTmp; 52 } 49 53 } 50 54 … … 66 70 67 71 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 68 PercentArray arr = item as PercentArray; 69 DoubleArrayJsonItem doubleArrayItem = data as DoubleArrayJsonItem; 70 bool resizeTmp = arr.Resizable; 71 arr.Resizable = true; 72 arr.Length = doubleArrayItem.Value.Length; 73 for (int i = 0; i < doubleArrayItem.Value.Length; ++i) 74 arr[i] = doubleArrayItem.Value[i]; 75 arr.Resizable = resizeTmp; 72 if(data.Active) { 73 PercentArray arr = item as PercentArray; 74 DoubleArrayJsonItem doubleArrayItem = data as DoubleArrayJsonItem; 75 bool resizeTmp = arr.Resizable; 76 arr.Resizable = true; 77 arr.Length = doubleArrayItem.Value.Length; 78 for (int i = 0; i < doubleArrayItem.Value.Length; ++i) 79 arr[i] = doubleArrayItem.Value[i]; 80 arr.Resizable = resizeTmp; 81 } 76 82 } 77 83 … … 93 99 94 100 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 95 BoolArray arr = item as BoolArray; 96 BoolArrayJsonItem boolArrayItem = data as BoolArrayJsonItem; 97 bool resizeTmp = arr.Resizable; 98 arr.Resizable = true; 99 arr.Length = boolArrayItem.Value.Length; 100 for(int i = 0; i < boolArrayItem.Value.Length; ++i) 101 arr[i] = boolArrayItem.Value[i]; 102 arr.Resizable = resizeTmp; 101 if(data.Active) { 102 BoolArray arr = item as BoolArray; 103 BoolArrayJsonItem boolArrayItem = data as BoolArrayJsonItem; 104 bool resizeTmp = arr.Resizable; 105 arr.Resizable = true; 106 arr.Length = boolArrayItem.Value.Length; 107 for (int i = 0; i < boolArrayItem.Value.Length; ++i) 108 arr[i] = boolArrayItem.Value[i]; 109 arr.Resizable = resizeTmp; 110 } 103 111 } 104 112 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs
r18043 r18077 9 9 10 10 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 11 IntMatrix mat = item as IntMatrix; 12 IntMatrixJsonItem d = data as IntMatrixJsonItem; 13 CopyMatrixData(mat, d.Value); 11 if(data.Active) { 12 IntMatrix mat = item as IntMatrix; 13 IntMatrixJsonItem d = data as IntMatrixJsonItem; 14 CopyMatrixData(mat, d.Value); 15 } 14 16 } 15 17 … … 28 30 29 31 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 30 DoubleMatrix mat = item as DoubleMatrix; 31 DoubleMatrixJsonItem d = data as DoubleMatrixJsonItem; 32 CopyMatrixData(mat, d.Value); 32 if(data.Active) { 33 DoubleMatrix mat = item as DoubleMatrix; 34 DoubleMatrixJsonItem d = data as DoubleMatrixJsonItem; 35 CopyMatrixData(mat, d.Value); 36 } 33 37 } 34 38 … … 49 53 50 54 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 51 PercentMatrix mat = item as PercentMatrix; 52 DoubleMatrixJsonItem d = data as DoubleMatrixJsonItem; 53 CopyMatrixData(mat, d.Value); 55 if(data.Active) { 56 PercentMatrix mat = item as PercentMatrix; 57 DoubleMatrixJsonItem d = data as DoubleMatrixJsonItem; 58 CopyMatrixData(mat, d.Value); 59 } 54 60 } 55 61 … … 68 74 69 75 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 70 BoolMatrix mat = item as BoolMatrix; 71 BoolMatrixJsonItem d = data as BoolMatrixJsonItem; 72 CopyMatrixData(mat, d.Value); 76 if(data.Active) { 77 BoolMatrix mat = item as BoolMatrix; 78 BoolMatrixJsonItem d = data as BoolMatrixJsonItem; 79 CopyMatrixData(mat, d.Value); 80 } 73 81 } 74 82 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeValueConverter.cs
r17843 r18077 11 11 typeof(IntValue).IsAssignableFrom(t); 12 12 13 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 14 ((IntValue)item).Value = ((IntJsonItem)data).Value; 13 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 14 if(data.Active) 15 ((IntValue)item).Value = ((IntJsonItem)data).Value; 16 } 17 15 18 16 19 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => … … 30 33 typeof(DoubleValue).IsAssignableFrom(t); 31 34 32 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 33 ((DoubleValue)item).Value = ((DoubleJsonItem)data).Value; 35 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 36 if (data.Active) 37 ((DoubleValue)item).Value = ((DoubleJsonItem)data).Value; 38 } 34 39 35 40 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => … … 49 54 typeof(PercentValue).IsAssignableFrom(t); 50 55 51 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 52 ((PercentValue)item).Value = ((DoubleJsonItem)data).Value; 56 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 57 if (data.Active) 58 ((PercentValue)item).Value = ((DoubleJsonItem)data).Value; 59 } 53 60 54 61 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => … … 68 75 typeof(BoolValue).IsAssignableFrom(t); 69 76 70 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 71 ((BoolValue)item).Value = ((BoolJsonItem)data).Value; 77 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 78 if (data.Active) 79 ((BoolValue)item).Value = ((BoolJsonItem)data).Value; 80 } 72 81 73 82 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => … … 85 94 typeof(DateTimeValue).IsAssignableFrom(t); 86 95 87 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 88 ((DateTimeValue)item).Value = ((DateTimeJsonItem)data).Value; 96 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 97 if (data.Active) 98 ((DateTimeValue)item).Value = ((DateTimeJsonItem)data).Value; 99 } 89 100 90 101 public override IJsonItem Extract(IItem value, IJsonItemConverter root) =>
Note: See TracChangeset
for help on using the changeset viewer.