Changeset 18055
- Timestamp:
- 09/16/21 15:27:07 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 7 added
- 1 deleted
- 31 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
r18050 r18055 22 22 Task task = optimizer.StartAsync(); 23 23 while (!task.IsCompleted) { 24 WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult. PostProcessors);24 WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.RunCollectionModifiers); 25 25 Thread.Sleep(100); 26 26 } 27 27 28 WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult. PostProcessors);28 WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.RunCollectionModifiers); 29 29 } 30 30 31 private static void WriteResultsToFile(string file, IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItem, IEnumerable<IR esultCollectionProcessor> postProcessors) {31 private static void WriteResultsToFile(string file, IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItem, IEnumerable<IRunCollectionModifier> runCollectionModifiers) { 32 32 if (optimizer.Runs.Count > 0) 33 File.WriteAllText(file, FetchResults(optimizer, configuredResultItem, postProcessors));33 File.WriteAllText(file, FetchResults(optimizer, configuredResultItem, runCollectionModifiers)); 34 34 } 35 35 … … 41 41 ResultFormatter?.Where(x => x.GetType().FullName == fullName).Last(); 42 42 43 private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IR esultCollectionProcessor> postProcessors) {43 private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IRunCollectionModifier> runCollectionModifiers) { 44 44 JArray arr = new JArray(); 45 45 IEnumerable<string> configuredResults = configuredResultItems.Select(x => x.Name); 46 47 foreach (var processor in runCollectionModifiers) 48 processor.Modify(new List<IRun>(optimizer.Runs.ToArray())); 49 50 foreach (var run in optimizer.Runs) { 51 JObject obj = new JObject(); 52 arr.Add(obj); 53 obj.Add("Run", JToken.FromObject(run.ToString())); 54 foreach (var result in run.Results) 55 obj.Add(result.Key, result.Value.ToString()); 46 56 57 // zip and filter the results with the ResultJsonItems 58 var filteredResults = new List<Tuple<IResultJsonItem, IItem>>(); 59 foreach (var resultItem in configuredResultItems) { 60 foreach (var result in run.Results) { 61 if (resultItem.Name == result.Key) { 62 filteredResults.Add(Tuple.Create(resultItem, result.Value)); 63 } 64 } 65 } 66 67 // add results to the JObject 68 foreach (var result in filteredResults) { 69 var formatter = GetResultFormatter(result.Item1.ResultFormatterType); 70 if (!obj.ContainsKey(result.Item1.Name)) // to prevent duplicates 71 obj.Add(result.Item1.Name, formatter.Format(result.Item2)); 72 } 73 } 74 /* 47 75 foreach (var run in optimizer.Runs) { 48 76 JObject obj = new JObject(); … … 66 94 obj.Add(result.Item1.Name, formatter.Format(result.Item2)); 67 95 } 68 69 foreach (var processor in postProcessors) 70 processor.Apply(run.Results); 71 72 foreach(var result in run.Results) 73 obj.Add(result.Key, result.Value.ToString()); 74 } 96 }*/ 75 97 return SingleLineArrayJsonWriter.Serialize(arr); 76 98 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs
r18050 r18055 1 1 using HeuristicLab.Core; 2 using HeuristicLab.Optimization; 2 3 3 4 namespace HeuristicLab.JsonInterface.OptimizerIntegration { … … 27 28 private void InitializeComponent() { 28 29 this.components = new System.ComponentModel.Container(); 30 HeuristicLab.Core.CheckedItemList<HeuristicLab.Optimization.IRunCollectionModifier> checkedItemList_11 = new HeuristicLab.Core.CheckedItemList<HeuristicLab.Optimization.IRunCollectionModifier>(); 29 31 this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 30 32 this.exportButton = new System.Windows.Forms.Button(); … … 41 43 this.tabPage2 = new System.Windows.Forms.TabPage(); 42 44 this.tabPage3 = new System.Windows.Forms.TabPage(); 45 this.postProcessorListControl = new HeuristicLab.JsonInterface.OptimizerIntegration.ResultCollectionPostProcessorControl(); 43 46 this.label1 = new System.Windows.Forms.Label(); 44 47 this.textBoxTemplateName = new System.Windows.Forms.TextBox(); … … 58 61 this.tabPage1.SuspendLayout(); 59 62 this.tabPage2.SuspendLayout(); 63 this.tabPage3.SuspendLayout(); 60 64 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 61 65 ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit(); … … 175 179 this.splitContainer2.SplitterDistance = 380; 176 180 this.splitContainer2.TabIndex = 9; 177 // postProcessorListView178 this.postProcessorListControl = new ResultCollectionPostProcessorControl();179 this.postProcessorListControl.Content = new CheckedItemList<IResultCollectionProcessor>();180 this.postProcessorListControl.Location = new System.Drawing.Point(0, 6);181 this.postProcessorListControl.Dock = System.Windows.Forms.DockStyle.Fill;182 181 // 183 182 // tabControl1 … … 224 223 this.tabPage3.Size = new System.Drawing.Size(802, 505); 225 224 this.tabPage3.TabIndex = 2; 226 this.tabPage3.Text = " Post Processors";225 this.tabPage3.Text = "Result Collection Modifiers"; 227 226 this.tabPage3.UseVisualStyleBackColor = true; 227 // 228 // postProcessorListControl 229 // 230 this.postProcessorListControl.Caption = "View"; 231 checkedItemList_11.Capacity = 0; 232 this.postProcessorListControl.Content = checkedItemList_11; 233 this.postProcessorListControl.Dock = System.Windows.Forms.DockStyle.Fill; 234 this.postProcessorListControl.Location = new System.Drawing.Point(0, 0); 235 this.postProcessorListControl.Name = "postProcessorListControl"; 236 this.postProcessorListControl.ReadOnly = false; 237 this.postProcessorListControl.Size = new System.Drawing.Size(802, 505); 238 this.postProcessorListControl.TabIndex = 0; 228 239 // 229 240 // label1 … … 282 293 this.tabPage1.ResumeLayout(false); 283 294 this.tabPage2.ResumeLayout(false); 295 this.tabPage3.ResumeLayout(false); 284 296 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 285 297 ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r18050 r18055 22 22 private IOptimizer Optimizer { get; set; } 23 23 private IList<IJsonItemVM> VMs { get; set; } 24 private ICheckedItemList<IR esultCollectionProcessor> PostProcessors { get; set; }24 private ICheckedItemList<IRunCollectionModifier> RunCollectionModifiers { get; set; } 25 25 #endregion 26 26 … … 61 61 public ExportJsonDialog() { 62 62 InitializeComponent(); 63 this. PostProcessors = this.postProcessorListControl.Content;63 this.RunCollectionModifiers = this.postProcessorListControl.Content; 64 64 this.Icon = HeuristicLab.Common.Resources.HeuristicLab.Icon; 65 65 InitCache(); … … 78 78 JsonTemplateGenerator.GenerateTemplate( 79 79 Path.Combine(FolderBrowserDialog.SelectedPath, textBoxTemplateName.Text), 80 Optimizer, Root, PostProcessors.CheckedItems.Select(x => x.Value));80 Optimizer, Root, RunCollectionModifiers.CheckedItems.Select(x => x.Value)); 81 81 Close(); 82 82 } catch (Exception ex) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultCollectionPostProcessorControl.cs
r18050 r18055 9 9 using System.Windows.Forms; 10 10 using HeuristicLab.Collections; 11 using HeuristicLab.Optimization; 11 12 12 13 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 13 public partial class ResultCollectionPostProcessorControl : Core.Views.CheckedItemListView<IR esultCollectionProcessor> {14 public partial class ResultCollectionPostProcessorControl : Core.Views.CheckedItemListView<IRunCollectionModifier> { 14 15 public ResultCollectionPostProcessorControl() { 15 16 InitializeComponent(); 16 17 } 17 18 18 protected override string GroupBoxText => "R esult Collection Processors";19 protected override string GroupBoxText => "Run Collection Modifiers"; 19 20 20 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Constants.cs
r18050 r18055 10 10 internal const string Parameters = "Parameters"; 11 11 internal const string Results = "Results"; 12 internal const string R esultCollectionProcessorItems = "ResultCollectionProcessors";12 internal const string RunCollectionModifiers = "RunCollectionModifiers"; 13 13 14 14 internal const string Template = @"{ … … 19 19 '" + Parameters + @"': [], 20 20 '" + Results + @"': [], 21 '" + R esultCollectionProcessorItems + @"': []21 '" + RunCollectionModifiers + @"': [] 22 22 }"; 23 23 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r18050 r18055 66 66 <Compile Include="Converters\BatchRunConverter.cs" /> 67 67 <Compile Include="Converters\ExperimentConverter.cs" /> 68 <Compile Include="Converters\ ObervableListConverter.cs" />68 <Compile Include="Converters\ItemCollectionConverter.cs" /> 69 69 <Compile Include="Converters\RegressionProblemDataConverter.cs" /> 70 70 <Compile Include="Converters\ResultConverter.cs" /> … … 84 84 <Compile Include="Interfaces\IValueJsonItem.cs" /> 85 85 <Compile Include="Interfaces\IValueLookupJsonItem.cs" /> 86 <Compile Include="Interfaces\I ResultCollectionProcessor.cs" />86 <Compile Include="Interfaces\IListJsonItem.cs" /> 87 87 <Compile Include="JsonItems\ArrayJsonItem.cs" /> 88 88 <Compile Include="JsonItems\BoolJsonItems.cs" /> … … 98 98 <Compile Include="JsonItems\IntJsonItems.cs" /> 99 99 <Compile Include="JsonItems\JsonItem.cs" /> 100 <Compile Include="JsonItems\ListJsonItem.cs" /> 100 101 <Compile Include="JsonItems\LookupJsonItem.cs" /> 101 102 <Compile Include="JsonItems\MatrixJsonItem.cs" /> … … 106 107 <Compile Include="JsonItems\ValueJsonItem.cs" /> 107 108 <Compile Include="JsonItems\ValueLookupJsonItem.cs" /> 109 <Compile Include="ResultCollectionProcessors\AbstractProcessors\RunCollectionSRSolutionFormatter.cs" /> 108 110 <Compile Include="ResultCollectionProcessors\FilterResultCollectionProcessor.cs" /> 109 <Compile Include="ResultCollectionProcessors\SymRegPythonProcessor.cs" /> 111 <Compile Include="ResultCollectionProcessors\RunCollectionSRSolutionGraphVizFormatter.cs" /> 112 <Compile Include="ResultCollectionProcessors\RunCollectionSRSolutionLatexFormatter.cs" /> 113 <Compile Include="ResultCollectionProcessors\RunCollectionSRSolutionPythonFormatter.cs" /> 110 114 <Compile Include="ResultFormatters\MatlabResultFormatter.cs" /> 111 115 <Compile Include="ResultFormatters\PythonResultFormatter.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ArrayJsonItem.cs
r17519 r18055 1 1 using Newtonsoft.Json.Linq; 2 using HEAL.Attic; 2 3 3 4 namespace HeuristicLab.JsonInterface { 5 [StorableType("1A448B57-6587-4EB4-9A0A-B05C376894C6")] 4 6 public abstract class ArrayJsonItem<T> : ValueJsonItem<T[]>, IArrayJsonItem { 5 7 public virtual bool Resizable { get; set; } … … 8 10 Resizable = (jObject[nameof(IArrayJsonItem.Resizable)]?.ToObject<bool>()).GetValueOrDefault(); 9 11 } 12 13 public ArrayJsonItem() { } 14 15 [StorableConstructor] 16 protected ArrayJsonItem(StorableConstructorFlag _) : base(_) { } 17 10 18 } 11 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/BoolJsonItems.cs
r17519 r18055 1 namespace HeuristicLab.JsonInterface { 1 using HEAL.Attic; 2 3 namespace HeuristicLab.JsonInterface { 4 [StorableType("01F11732-16D0-4115-82B7-1BE3A731DC14")] 2 5 public class BoolJsonItem : ValueJsonItem<bool> { 3 6 protected override ValidationResult Validate() => ValidationResult.Successful(); 7 8 public BoolJsonItem() { } 9 10 [StorableConstructor] 11 protected BoolJsonItem(StorableConstructorFlag _) : base(_) { } 4 12 } 5 13 14 [StorableType("49995C46-3B9B-49FC-952C-85645D0B565A")] 6 15 public class BoolArrayJsonItem : ArrayJsonItem<bool> { 7 16 protected override ValidationResult Validate() => ValidationResult.Successful(); 17 18 public BoolArrayJsonItem() { } 19 20 [StorableConstructor] 21 protected BoolArrayJsonItem(StorableConstructorFlag _) : base(_) { } 8 22 } 9 23 24 [StorableType("5680A943-A5C4-4310-977E-261252810766")] 10 25 public class BoolMatrixJsonItem : MatrixJsonItem<bool> { 11 26 protected override ValidationResult Validate() => ValidationResult.Successful(); 27 28 public BoolMatrixJsonItem() { } 29 30 [StorableConstructor] 31 protected BoolMatrixJsonItem(StorableConstructorFlag _) : base(_) { } 12 32 } 13 33 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ConcreteRestrictedArrayJsonItem.cs
r17519 r18055 1 1 using System.Collections.Generic; 2 2 using System.Linq; 3 using HEAL.Attic; 4 3 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("4333B6C0-26F7-41BA-A297-071AB50307F9")] 4 7 public abstract class ConcreteRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IConcreteRestrictedJsonItem<T> { 5 8 public IEnumerable<T> ConcreteRestrictedItems { get; set; } … … 9 12 IList<string> errors = new List<string>(); 10 13 if (ConcreteRestrictedItems == null) return ValidationResult.Successful(); 11 foreach (var x in Value) {14 foreach (var x in Value) { 12 15 bool tmp = false; 13 foreach (var restrictedItem in ConcreteRestrictedItems) {16 foreach (var restrictedItem in ConcreteRestrictedItems) { 14 17 tmp = tmp || x.Equals(restrictedItem); //if one tmp is true, it stays true (match found) 15 18 } … … 19 22 res = res && tmp; //if one tmp is false, res will set false 20 23 } 21 if (res) 24 if (res) 22 25 return ValidationResult.Successful(); 23 else 26 else 24 27 return ValidationResult.Faulty(errors); 25 28 } 29 30 public ConcreteRestrictedArrayJsonItem() { } 31 32 [StorableConstructor] 33 protected ConcreteRestrictedArrayJsonItem(StorableConstructorFlag _) : base(_) { } 26 34 } 27 35 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ConcreteRestrictedValueJsonItem.cs
r18043 r18055 1 1 using System.Collections.Generic; 2 2 using System.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 5 6 [StorableType("4B3B7E23-4317-4804-BB51-88ABFD58CD03")] 6 7 public abstract class ConcreteRestrictedValueJsonItem<T> : ValueJsonItem<T>, IConcreteRestrictedJsonItem<T> { 7 8 … … 16 17 $"'{ string.Join(",", ConcreteRestrictedItems.Select(s => s.ToString()).ToArray()) }'."); 17 18 } 19 20 public ConcreteRestrictedValueJsonItem() { } 21 22 [StorableConstructor] 23 protected ConcreteRestrictedValueJsonItem(StorableConstructorFlag _) : base(_) { } 18 24 } 19 25 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/DateTimeJsonItem.cs
r17519 r18055 1 1 using System; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("C700603D-50E5-448B-B785-9974463A91A8")] 5 7 public class DateTimeJsonItem : IntervalRestrictedValueJsonItem<DateTime> { 6 8 7 9 public override JObject GenerateJObject() { 8 10 var obj = base.GenerateJObject(); … … 22 24 base.SetJObject(jObject); 23 25 } 26 27 public DateTimeJsonItem() { } 28 29 [StorableConstructor] 30 protected DateTimeJsonItem(StorableConstructorFlag _) : base(_) { } 24 31 } 25 32 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/DoubleJsonItems.cs
r17519 r18055 1 1 using Newtonsoft.Json.Linq; 2 using HEAL.Attic; 2 3 3 4 namespace HeuristicLab.JsonInterface { 5 [StorableType("B9B3843E-90B9-453F-AB7F-B3A4B8DF6809")] 4 6 public class DoubleJsonItem : IntervalRestrictedValueJsonItem<double> { 5 7 public override JObject GenerateJObject() { … … 20 22 base.SetJObject(jObject); 21 23 } 24 25 public DoubleJsonItem() { } 26 27 [StorableConstructor] 28 protected DoubleJsonItem(StorableConstructorFlag _) : base(_) { } 22 29 } 30 31 [StorableType("D7E2BA3D-E9F7-4062-8423-182B517FA7CA")] 23 32 public class DoubleArrayJsonItem : IntervalRestrictedArrayJsonItem<double> { 24 33 public override JObject GenerateJObject() { … … 39 48 base.SetJObject(jObject); 40 49 } 50 51 public DoubleArrayJsonItem() { } 52 53 [StorableConstructor] 54 protected DoubleArrayJsonItem(StorableConstructorFlag _) : base(_) { } 41 55 } 56 57 [StorableType("4ED29A62-F368-476B-B551-4283E428F7B9")] 42 58 public class DoubleRangeJsonItem : RangedJsonItem<double> { 43 59 public override JObject GenerateJObject() { … … 58 74 base.SetJObject(jObject); 59 75 } 76 77 public DoubleRangeJsonItem() { } 78 79 [StorableConstructor] 80 protected DoubleRangeJsonItem(StorableConstructorFlag _) : base(_) { } 60 81 } 82 83 [StorableType("39C117DA-6274-4C1F-8CA8-A57B1A7A9C72")] 61 84 public class DoubleMatrixJsonItem : IntervalRestrictedMatrixJsonItem<double> { 62 85 public override JObject GenerateJObject() { … … 77 100 base.SetJObject(jObject); 78 101 } 102 103 public DoubleMatrixJsonItem() { } 104 105 [StorableConstructor] 106 protected DoubleMatrixJsonItem(StorableConstructorFlag _) : base(_) { } 79 107 } 80 108 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/EmptyJsonItem.cs
r17519 r18055 1 namespace HeuristicLab.JsonInterface { 1 using HEAL.Attic; 2 3 namespace HeuristicLab.JsonInterface { 4 [StorableType("B33EA674-10D1-4184-A564-9EE7F7BFC55B")] 2 5 public class EmptyJsonItem : JsonItem { 3 6 protected override ValidationResult Validate() => ValidationResult.Successful(); 7 8 public EmptyJsonItem() { } 9 10 [StorableConstructor] 11 protected EmptyJsonItem(StorableConstructorFlag _) : base(_) { } 4 12 } 5 13 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntJsonItems.cs
r17519 r18055 1 1 using Newtonsoft.Json.Linq; 2 using HEAL.Attic; 2 3 3 4 namespace HeuristicLab.JsonInterface { 5 [StorableType("4FFDAC9B-34F3-4FDB-ABD1-BB2128CE5A49")] 4 6 public class IntJsonItem : IntervalRestrictedValueJsonItem<int> { 5 7 public override JObject GenerateJObject() { … … 20 22 base.SetJObject(jObject); 21 23 } 24 25 public IntJsonItem() { } 26 27 [StorableConstructor] 28 protected IntJsonItem(StorableConstructorFlag _) : base(_) { } 22 29 } 30 31 [StorableType("73E22461-6CA0-4BE1-A5FE-9EF7FFD320AD")] 23 32 public class IntArrayJsonItem : IntervalRestrictedArrayJsonItem<int> { 24 33 public override JObject GenerateJObject() { … … 39 48 base.SetJObject(jObject); 40 49 } 50 51 public IntArrayJsonItem() { } 52 53 [StorableConstructor] 54 protected IntArrayJsonItem(StorableConstructorFlag _) : base(_) { } 41 55 } 56 57 [StorableType("A6FBA509-FC37-4E54-9578-5AFB764CFB89")] 42 58 public class IntRangeJsonItem : RangedJsonItem<int> { 43 59 public override JObject GenerateJObject() { … … 58 74 base.SetJObject(jObject); 59 75 } 76 77 public IntRangeJsonItem() { } 78 79 [StorableConstructor] 80 protected IntRangeJsonItem(StorableConstructorFlag _) : base(_) { } 60 81 } 82 83 [StorableType("3CFF8D3E-8608-41BA-85A5-42CD4DA45685")] 61 84 public class IntMatrixJsonItem : IntervalRestrictedMatrixJsonItem<int> { 62 85 public override JObject GenerateJObject() { … … 77 100 base.SetJObject(jObject); 78 101 } 102 103 public IntMatrixJsonItem() { } 104 105 [StorableConstructor] 106 protected IntMatrixJsonItem(StorableConstructorFlag _) : base(_) { } 79 107 } 80 108 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedArrayJsonItem.cs
r17519 r18055 2 2 using System.Collections.Generic; 3 3 using Newtonsoft.Json.Linq; 4 using HEAL.Attic; 4 5 5 6 namespace HeuristicLab.JsonInterface { 7 [StorableType("97466581-CCF1-45BD-B5F8-87B8660DBE13")] 6 8 public abstract class IntervalRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IIntervalRestrictedJsonItem<T> 7 where T : IComparable {9 where T : IComparable { 8 10 public T Minimum { get; set; } 9 11 public T Maximum { get; set; } … … 31 33 if (maxProp != null) Maximum = maxProp.ToObject<T>(); 32 34 } 35 36 public IntervalRestrictedArrayJsonItem() { } 37 38 [StorableConstructor] 39 protected IntervalRestrictedArrayJsonItem(StorableConstructorFlag _) : base(_) { } 33 40 } 34 41 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedJsonItem.cs
r18043 r18055 1 1 using System; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("4D76601B-9627-4ABD-A24B-49179D59AB11")] 5 7 public abstract class IntervalRestrictedJsonItem<T> : JsonItem, IIntervalRestrictedJsonItem<T> 6 where T : IComparable {8 where T : IComparable { 7 9 public T Minimum { get; set; } 8 10 public T Maximum { get; set; } … … 17 19 if (maxProp != null) Maximum = maxProp.ToObject<T>(); 18 20 } 21 22 public IntervalRestrictedJsonItem() { } 23 24 [StorableConstructor] 25 protected IntervalRestrictedJsonItem(StorableConstructorFlag _) : base(_) { } 19 26 } 20 27 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedMatrixJsonItem.cs
r17519 r18055 2 2 using System.Collections.Generic; 3 3 using Newtonsoft.Json.Linq; 4 using HEAL.Attic; 4 5 5 6 namespace HeuristicLab.JsonInterface { 7 [StorableType("4FEDB1E0-B4B7-4EAD-8D5E-B2AA13C37F40")] 6 8 public abstract class IntervalRestrictedMatrixJsonItem<T> : MatrixJsonItem<T>, IIntervalRestrictedJsonItem<T> 7 where T : IComparable {9 where T : IComparable { 8 10 public T Minimum { get; set; } 9 11 public T Maximum { get; set; } … … 33 35 if (maxProp != null) Maximum = maxProp.ToObject<T>(); 34 36 } 37 38 public IntervalRestrictedMatrixJsonItem() { } 39 40 [StorableConstructor] 41 protected IntervalRestrictedMatrixJsonItem(StorableConstructorFlag _) : base(_) { } 35 42 } 36 43 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedValueJsonItem.cs
r18040 r18055 1 1 using System; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 5 public abstract class IntervalRestrictedValueJsonItem<T> : ValueJsonItem<T>, IIntervalRestrictedJsonItem<T> // TODO: intervalrestriction before value? 6 where T : IComparable { 6 [StorableType("5BD32AD9-7CA2-4837-B1C3-D47D0CD83035")] 7 public abstract class IntervalRestrictedValueJsonItem<T> : ValueJsonItem<T>, IIntervalRestrictedJsonItem<T> 8 where T : IComparable { 7 9 public T Minimum { get; set; } 8 10 public T Maximum { get; set; } … … 23 25 if (maxProp != null) Maximum = maxProp.ToObject<T>(); 24 26 } 27 28 public IntervalRestrictedValueJsonItem() { } 29 30 [StorableConstructor] 31 protected IntervalRestrictedValueJsonItem(StorableConstructorFlag _) : base(_) { } 25 32 } 26 33 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/JsonItem.cs
r17843 r18055 6 6 using Newtonsoft.Json; 7 7 using Newtonsoft.Json.Linq; 8 using HEAL.Attic; 8 9 9 10 namespace HeuristicLab.JsonInterface { … … 32 33 } 33 34 35 [StorableType("B1270D98-B0D9-40FB-B089-F6E70C65CD65")] 34 36 /// <summary> 35 37 /// Main data class for json interface. … … 38 40 39 41 public class JsonItemValidator : IJsonItemValidator { 40 private IDictionary<int, bool> Cache = new Dictionary<int, bool>();42 //private IDictionary<int, bool> Cache = new Dictionary<int, bool>(); 41 43 private JsonItem Root { get; set; } 42 44 public JsonItemValidator(JsonItem root) { … … 47 49 List<string> errors = new List<string>(); 48 50 bool success = true; 49 foreach (var x in Root) {51 foreach (var x in Root) { 50 52 JsonItem item = x as JsonItem; 51 if (item.Active) {53 if (item.Active) { 52 54 var res = ((JsonItem)x).Validate(); 53 55 //if one success is false -> whole validation is false … … 68 70 IJsonItem tmp = Parent; 69 71 StringBuilder builder = new StringBuilder(this.Name); 70 while (tmp != null) {72 while (tmp != null) { 71 73 builder.Insert(0, tmp.Name + "."); 72 74 tmp = tmp.Parent; … … 86 88 87 89 #region Constructors 90 [StorableConstructor] 91 protected JsonItem(StorableConstructorFlag _) { } 92 88 93 public JsonItem() { } 89 94 … … 92 97 } 93 98 #endregion 94 99 95 100 #region Public Methods 96 public void AddChildren(params IJsonItem[] childs) => 101 public void AddChildren(params IJsonItem[] childs) => 97 102 AddChildren(childs as IEnumerable<IJsonItem>); 98 103 … … 101 106 if (Children == null) 102 107 Children = new List<IJsonItem>(); 103 if (Children is IList<IJsonItem> list) {108 if (Children is IList<IJsonItem> list) { 104 109 foreach (var child in childs) { 105 110 list.Add(child); … … 131 136 public virtual IEnumerator<IJsonItem> GetEnumerator() { 132 137 yield return this; 133 138 134 139 if (Children != null) { 135 140 foreach (var x in Children) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/LookupJsonItem.cs
r17519 r18055 1 1 using Newtonsoft.Json.Linq; 2 using HEAL.Attic; 2 3 3 4 namespace HeuristicLab.JsonInterface { 5 [StorableType("DE16C5EB-998D-4D34-BD98-7BF0E02A56BC")] 4 6 public class LookupJsonItem : JsonItem, ILookupJsonItem { 5 7 public virtual string ActualName { get; set; } … … 11 13 12 14 protected override ValidationResult Validate() => ValidationResult.Successful(); 15 16 public LookupJsonItem() { } 17 18 [StorableConstructor] 19 protected LookupJsonItem(StorableConstructorFlag _) : base(_) { } 13 20 } 14 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/MatrixJsonItem.cs
r17519 r18055 1 1 using System.Collections.Generic; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("2DCBBBA5-B29F-4E97-A3BC-99F7C9E15759")] 5 7 public abstract class MatrixJsonItem<T> : ValueJsonItem<T[][]>, IMatrixJsonItem { 6 8 public virtual bool RowsResizable { get; set; } … … 26 28 ColumnNames = jObject[nameof(IMatrixJsonItem.ColumnNames)]?.ToObject<IEnumerable<string>>(); 27 29 } 30 31 public MatrixJsonItem() { } 32 33 [StorableConstructor] 34 protected MatrixJsonItem(StorableConstructorFlag _) : base(_) { } 28 35 } 29 36 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/RangedJsonItem.cs
r18040 r18055 2 2 using System.Collections.Generic; 3 3 using Newtonsoft.Json.Linq; 4 using HEAL.Attic; 4 5 5 6 namespace HeuristicLab.JsonInterface { 7 [StorableType("856DE916-D830-43A8-9B40-37E512A177DB")] 6 8 public abstract class RangedJsonItem<T> : IntervalRestrictedJsonItem<T>, IRangedJsonItem<T> 7 where T : IComparable {9 where T : IComparable { 8 10 public T MinValue { get; set; } 9 11 10 12 public T MaxValue { get; set; } 11 13 … … 30 32 } 31 33 34 public RangedJsonItem() { } 35 36 [StorableConstructor] 37 protected RangedJsonItem(StorableConstructorFlag _) : base(_) { } 38 32 39 } 33 40 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ResultJsonItem.cs
r17843 r18055 1 1 using System; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("AA00656C-56D5-4F4E-9843-BA15636FC399")] 5 7 public class ResultJsonItem : JsonItem, IResultJsonItem { 6 8 public string ResultFormatterType { get; set; } … … 15 17 } 16 18 19 public ResultJsonItem() { } 20 21 [StorableConstructor] 22 protected ResultJsonItem(StorableConstructorFlag _) : base(_) { } 23 17 24 } 18 25 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/StringJsonItem.cs
r17519 r18055 1 namespace HeuristicLab.JsonInterface { 2 public class StringJsonItem : ConcreteRestrictedValueJsonItem<string> { } 3 public class StringArrayJsonItem : ConcreteRestrictedArrayJsonItem<string> { } 1 using HEAL.Attic; 2 3 namespace HeuristicLab.JsonInterface { 4 [StorableType("81C18291-25B0-4B6C-8707-7B59125B7A93")] 5 public class StringJsonItem : ConcreteRestrictedValueJsonItem<string> { 6 public StringJsonItem() { } 7 8 [StorableConstructor] 9 protected StringJsonItem(StorableConstructorFlag _) : base(_) { } 10 } 11 12 [StorableType("6086E5FB-2DC2-4848-9388-0D957B887795")] 13 public class StringArrayJsonItem : ConcreteRestrictedArrayJsonItem<string> { 14 public StringArrayJsonItem() { } 15 16 [StorableConstructor] 17 protected StringArrayJsonItem(StorableConstructorFlag _) : base(_) { } 18 } 19 /* 20 public class StringArrayValueJsonItem : ArrayJsonItem<string> { 21 protected override ValidationResult Validate() => ValidationResult.Successful(); 22 }*/ 4 23 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/UnsupportedJsonItem.cs
r18043 r18055 3 3 using System.Linq; 4 4 using Newtonsoft.Json; 5 using HEAL.Attic; 5 6 6 7 namespace HeuristicLab.JsonInterface { 8 [StorableType("0E2CA132-AA19-4FC7-B2FD-09572F2E0967")] 7 9 public class UnsupportedJsonItem : JsonItem { 8 10 … … 14 16 15 17 protected override ValidationResult Validate() => ValidationResult.Successful(); 18 19 public UnsupportedJsonItem() { } 20 21 [StorableConstructor] 22 protected UnsupportedJsonItem(StorableConstructorFlag _) : base(_) { } 16 23 } 17 24 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ValueJsonItem.cs
r17519 r18055 1 1 using System; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("29139288-7ABB-4391-926E-5975CF38141E")] 5 7 public abstract class ValueJsonItem : JsonItem, IValueJsonItem { 6 8 public object Value { get; set; } … … 10 12 } 11 13 14 public ValueJsonItem() { } 15 16 [StorableConstructor] 17 protected ValueJsonItem(StorableConstructorFlag _) : base(_) { 18 } 19 12 20 } 13 21 22 [StorableType("86085358-50D6-4486-9265-F6CEA8C8FA19")] 14 23 public abstract class ValueJsonItem<T> : ValueJsonItem, IValueJsonItem<T> { 15 24 public new T Value { … … 29 38 30 39 public override void SetJObject(JObject jObject) { 31 if (jObject[nameof(IValueJsonItem<T>.Value)] != null)40 if (jObject[nameof(IValueJsonItem<T>.Value)] != null) 32 41 Value = jObject[nameof(IValueJsonItem<T>.Value)].ToObject<T>(); 33 42 } 43 44 public ValueJsonItem() { } 45 46 [StorableConstructor] 47 protected ValueJsonItem(StorableConstructorFlag _) : base(_) { } 34 48 } 35 49 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ValueLookupJsonItem.cs
r17519 r18055 1 1 using System.Collections.Generic; 2 2 using Newtonsoft.Json.Linq; 3 using HEAL.Attic; 3 4 4 5 namespace HeuristicLab.JsonInterface { 6 [StorableType("D2521F37-3968-4FAC-AEE9-F083AA86C06C")] 5 7 public class ValueLookupJsonItem : LookupJsonItem, IValueLookupJsonItem { 6 8 public IJsonItem ActualValue { get; set; } … … 13 15 public override JObject GenerateJObject() { 14 16 var obj = base.GenerateJObject(); 15 if (ActualValue != null) {17 if (ActualValue != null) { 16 18 obj.Add(nameof(IValueLookupJsonItem.ActualValue), ActualValue.Path); 17 19 } … … 21 23 public override IEnumerator<IJsonItem> GetEnumerator() { 22 24 using (var it = base.GetEnumerator()) { 23 while (it.MoveNext()) {25 while (it.MoveNext()) { 24 26 yield return it.Current; 25 27 } 26 28 } 27 if (ActualValue != null) {29 if (ActualValue != null) { 28 30 using (var it = ActualValue.GetEnumerator()) { 29 31 while (it.MoveNext()) { … … 33 35 } 34 36 } 37 38 public ValueLookupJsonItem() { } 39 40 [StorableConstructor] 41 protected ValueLookupJsonItem(StorableConstructorFlag _) : base(_) { } 35 42 } 36 43 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateGenerator.cs
r18050 r18055 19 19 /// <param name="optimizer">the optimizer object to serialize</param> 20 20 /// <param name="rootItem">Root JsonItem for serialization, considers only active JsonItems for serialization</param> 21 public static void GenerateTemplate(string templatePath, IOptimizer optimizer, IJsonItem rootItem, IEnumerable<IR esultCollectionProcessor> resultCollectionProcessors) {21 public static void GenerateTemplate(string templatePath, IOptimizer optimizer, IJsonItem rootItem, IEnumerable<IRunCollectionModifier> runCollectionModifiers) { 22 22 // clear all runs 23 23 if (optimizer.ExecutionState == ExecutionState.Paused) … … 34 34 JArray parameterItems = new JArray(); 35 35 JArray resultItems = new JArray(); 36 JArray r esultCollectionProcessorItems = new JArray();36 JArray runCollectionModifierItems = new JArray(); 37 37 string templateName = Path.GetFileName(templatePath); 38 38 string templateDirectory = Path.GetDirectoryName(templatePath); … … 60 60 #endregion 61 61 62 #region R esultCollectionProcessorSerialization63 foreach (var proc in r esultCollectionProcessors) {62 #region RunCollectionModifiers Serialization 63 foreach (var proc in runCollectionModifiers) { 64 64 JArray rcpParameterItems = new JArray(); 65 65 var guid = StorableTypeAttribute.GetStorableTypeAttribute(proc.GetType()).Guid.ToString(); … … 77 77 processorObj.Add("GUID", guid); 78 78 processorObj.Add(Constants.Parameters, rcpParameterItems); 79 r esultCollectionProcessorItems.Add(processorObj);79 runCollectionModifierItems.Add(processorObj); 80 80 } 81 81 #endregion … … 86 86 template[Constants.Parameters] = parameterItems; 87 87 template[Constants.Results] = resultItems; 88 template[Constants.R esultCollectionProcessorItems] = resultCollectionProcessorItems;88 template[Constants.RunCollectionModifiers] = runCollectionModifierItems; 89 89 #endregion 90 90 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r18050 r18055 14 14 Optimizer = optimizer; 15 15 ConfiguredResultItems = configuredResultItems; 16 PostProcessors = Enumerable.Empty<IResultCollectionProcessor>();16 RunCollectionModifiers = Enumerable.Empty<IRunCollectionModifier>(); 17 17 } 18 18 19 public InstantiatorResult(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IR esultCollectionProcessor> postProcessors) {19 public InstantiatorResult(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IRunCollectionModifier> runCollectionModifiers) { 20 20 Optimizer = optimizer; 21 21 ConfiguredResultItems = configuredResultItems; 22 PostProcessors = postProcessors;22 RunCollectionModifiers = runCollectionModifiers; 23 23 } 24 24 25 25 public IOptimizer Optimizer { get; } 26 26 public IEnumerable<IResultJsonItem> ConfiguredResultItems { get; } 27 public IEnumerable<IR esultCollectionProcessor> PostProcessors { get; }27 public IEnumerable<IRunCollectionModifier> RunCollectionModifiers { get; } 28 28 } 29 29 … … 94 94 JsonItemConverter.Inject(optimizer, rootItem); 95 95 96 return new InstantiatorResult(optimizer, CollectResults(), CollectR esultCollectionProcessors());96 return new InstantiatorResult(optimizer, CollectResults(), CollectRunCollectionModifiers()); 97 97 } 98 98 … … 100 100 /// Instantiates all defined (in template) ResultCollectionProcessors and injects the configured parameters. 101 101 /// </summary> 102 private IEnumerable<IR esultCollectionProcessor> CollectResultCollectionProcessors() {103 IList<IR esultCollectionProcessor> postProcessorList = new List<IResultCollectionProcessor>();104 foreach (JObject obj in Template[Constants.R esultCollectionProcessorItems]) {102 private IEnumerable<IRunCollectionModifier> CollectRunCollectionModifiers() { 103 IList<IRunCollectionModifier> runCollectionModifiers = new List<IRunCollectionModifier>(); 104 foreach (JObject obj in Template[Constants.RunCollectionModifiers]) { 105 105 var guid = obj["GUID"].ToString(); 106 106 var parameters = obj[Constants.Parameters]; 107 107 var type = Mapper.StaticCache.GetType(new Guid(guid)); 108 var rcp = (IR esultCollectionProcessor)Activator.CreateInstance(type);108 var rcp = (IRunCollectionModifier)Activator.CreateInstance(type); 109 109 var rcpItem = JsonItemConverter.Extract(rcp); 110 110 … … 117 117 118 118 JsonItemConverter.Inject(rcp, rcpItem); 119 postProcessorList.Add(rcp);119 runCollectionModifiers.Add(rcp); 120 120 } 121 return postProcessorList;121 return runCollectionModifiers; 122 122 } 123 123 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultCollectionProcessors/FilterResultCollectionProcessor.cs
r18050 r18055 12 12 13 13 namespace HeuristicLab.JsonInterface { 14 /* 14 15 [StorableType("4AF9EF94-2EF3-4F54-8B8D-942454CF8DDF")] 15 public class FilterResultCollectionProcessor : ParameterizedNamedItem, IR esultCollectionProcessor {16 public class FilterResultCollectionProcessor : ParameterizedNamedItem, IRunCollectionModifier { 16 17 17 18 #region Constants 18 19 private const string FilterStringParameterName = "Filters"; 20 private const string Filter2StringParameterName = "Filters2"; 19 21 #endregion 20 22 … … 22 24 public IFixedValueParameter<StringValue> FilterStringParameter => 23 25 (IFixedValueParameter<StringValue>)Parameters[FilterStringParameterName]; 26 public IFixedValueParameter<ItemList<StringValue>> Filter2StringParameter => 27 (IFixedValueParameter<ItemList<StringValue>>)Parameters[Filter2StringParameterName]; 24 28 #endregion 25 29 … … 29 33 public FilterResultCollectionProcessor() { 30 34 Parameters.Add(new FixedValueParameter<StringValue>(FilterStringParameterName, "", new StringValue())); 35 Parameters.Add(new FixedValueParameter<ItemList<StringValue>>(Filter2StringParameterName, "", new ItemList<StringValue>())); 31 36 } 32 37 public FilterResultCollectionProcessor(FilterResultCollectionProcessor original, Cloner cloner) : base(original, cloner) { } … … 39 44 var filters = FilterStringParameter.Value.Value.Split(';'); 40 45 41 42 /* 43 foreach (var filter in FilterStringParameter.Value) { 44 if (results.ContainsKey(filter.Value)) 45 results.Remove(filter.Value); 46 }*/ 46 foreach (var filter in filters) { 47 if (results.ContainsKey(filter)) 48 results.Remove(filter); 49 } 47 50 } 48 } 51 }*/ 49 52 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultCollectionProcessors/RunCollectionSRSolutionPythonFormatter.cs
r18054 r18055 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using HeuristicLab.Collections; 7 using HeuristicLab.Common; 1 using HeuristicLab.Common; 2 using HeuristicLab.Problems.DataAnalysis.Symbolic; 3 using HEAL.Attic; 4 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 8 5 using HeuristicLab.Core; 9 using HeuristicLab.Optimization;10 using HeuristicLab.Problems.DataAnalysis.Symbolic;11 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;12 using HEAL.Attic;13 using HeuristicLab.Data;14 6 15 7 namespace HeuristicLab.JsonInterface { 8 [Item(Name = "RunCollection SymbolicRegressionSolution Python Formatter")] 16 9 [StorableType("844F2887-B7A0-4BD4-89B8-F9155C65D214")] 17 public class SymRegPythonProcessor : ParameterizedNamedItem, IResultCollectionProcessor { 10 public class RunCollectionSRSolutionPythonFormatter : RunCollectionSRSolutionFormatter { 11 protected override ISymbolicExpressionTreeStringFormatter Formatter => 12 new SymbolicDataAnalysisExpressionPythonFormatter(); 18 13 19 14 #region Constructors & Cloning 20 15 [StorableConstructor] 21 protected SymRegPythonProcessor(StorableConstructorFlag _) : base(_) { }22 public SymRegPythonProcessor() {}23 public SymRegPythonProcessor(SymRegPythonProcessor original, Cloner cloner) : base(original, cloner) { }16 protected RunCollectionSRSolutionPythonFormatter(StorableConstructorFlag _) : base(_) { } 17 public RunCollectionSRSolutionPythonFormatter() { Suffix = "Python"; } 18 public RunCollectionSRSolutionPythonFormatter(RunCollectionSRSolutionPythonFormatter original, Cloner cloner) : base(original, cloner) { } 24 19 25 20 public override IDeepCloneable Clone(Cloner cloner) { 26 return new SymRegPythonProcessor(this, cloner);21 return new RunCollectionSRSolutionPythonFormatter(this, cloner); 27 22 } 28 23 #endregion 29 30 public void Apply(IObservableDictionary<string, IItem> results) {31 var formatter = new SymbolicDataAnalysisExpressionPythonFormatter();32 var resultCopy = new ObservableDictionary<string, IItem>(results);33 foreach (var kvp in resultCopy) {34 if (kvp.Value is ISymbolicRegressionSolution sol) {35 results.Add($"{kvp.Key} - Python" , new StringValue(formatter.Format(sol.Model.SymbolicExpressionTree)));36 }37 }38 }39 24 } 40 25 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Optimization/3.3/RunCollectionModification/RunCollectionValueRemover.cs
r17180 r18055 27 27 using HeuristicLab.Parameters; 28 28 using HEAL.Attic; 29 using HeuristicLab.Collections; 29 30 30 31 namespace HeuristicLab.Optimization { … … 38 39 } 39 40 41 public IFixedValueParameter<BoolValue> InvertParameter { 42 get { return (IFixedValueParameter<BoolValue>)Parameters["Invert"]; } 43 } 44 40 45 public IEnumerable<string> Values { 41 46 get { return ValuesParameter.Value.CheckedItems.Select(v => v.Value); } 42 47 } 48 49 public bool Invert => InvertParameter.Value.Value; 43 50 44 51 #region Construction & Cloning … … 49 56 } 50 57 public RunCollectionValueRemover() { 51 Parameters.Add(new ValueParameter<CheckedItemCollection<StringValue>>("Values", "The result or parameter values to be removed from each run.")); 58 Parameters.Add(new ValueParameter<CheckedItemCollection<StringValue>>("Values", "The result or parameter values to be removed from each run.")); 59 Parameters.Add(new FixedValueParameter<BoolValue>("Invert", "Inverts the filter strategy: Blackbox <-> Whitebox (Default: Blackbox)", new BoolValue(false))); 52 60 } 53 61 public override IDeepCloneable Clone(Cloner cloner) { … … 56 64 #endregion 57 65 58 public void Modify(List<IRun> runs) { 66 public void Modify(List<IRun> runs) { 59 67 foreach (var run in runs) { 60 foreach (var value in Values) { 61 run.Parameters.Remove(value); 62 run.Results.Remove(value); 63 } 64 } 68 if (Invert) { //Whitebox 69 var parametersCopy = new ObservableDictionary<string, IItem>(run.Parameters); 70 var resultsCopy = new ObservableDictionary<string, IItem>(run.Results); 71 foreach(var param in parametersCopy) 72 if (!Values.Any(x => x == param.Key)) 73 run.Parameters.Remove(param.Key); 74 foreach (var result in resultsCopy) 75 if (!Values.Any(x => x == result.Key)) 76 run.Results.Remove(result.Key); 77 } else { //Blackbox 78 foreach (var value in Values) { 79 run.Parameters.Remove(value); 80 run.Results.Remove(value); 81 } 82 } 83 } 65 84 } 66 85
Note: See TracChangeset
for help on using the changeset viewer.