Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/16/21 15:27:07 (3 years ago)
Author:
dpiringe
Message:

#3026

  • added StorableTypeAttribute and StorableConstructorAttribute to all JsonItems
  • added a new JsonItem ListJsonItem + Interfaces IListJsonItem
  • renamed SymRegPythonProcessor to RunCollectionSRSolutionPythonFormatter
  • removed Interface IResultCollectionProcessor -> using the interface IRunCollectionModifier now (has aleady implementations)
  • renamed all related variables/fields/properties with a connection to ResultCollectionProcessor
  • added new implementations for IRunCollectionModifier
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  
    2222      Task task = optimizer.StartAsync();
    2323      while (!task.IsCompleted) {
    24         WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.PostProcessors);
     24        WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.RunCollectionModifiers);
    2525        Thread.Sleep(100);
    2626      }
    2727
    28       WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.PostProcessors);
     28      WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.RunCollectionModifiers);
    2929    }
    3030
    31     private static void WriteResultsToFile(string file, IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItem, IEnumerable<IResultCollectionProcessor> postProcessors) {
     31    private static void WriteResultsToFile(string file, IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItem, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    3232      if (optimizer.Runs.Count > 0)
    33         File.WriteAllText(file, FetchResults(optimizer, configuredResultItem, postProcessors));
     33        File.WriteAllText(file, FetchResults(optimizer, configuredResultItem, runCollectionModifiers));
    3434    }
    3535     
     
    4141      ResultFormatter?.Where(x => x.GetType().FullName == fullName).Last();
    4242
    43     private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IResultCollectionProcessor> postProcessors) {
     43    private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    4444      JArray arr = new JArray();
    4545      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());
    4656
     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      /*
    4775      foreach (var run in optimizer.Runs) {
    4876        JObject obj = new JObject();
     
    6694            obj.Add(result.Item1.Name, formatter.Format(result.Item2));
    6795        }
    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      }*/
    7597      return SingleLineArrayJsonWriter.Serialize(arr);
    7698    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs

    r18050 r18055  
    11using HeuristicLab.Core;
     2using HeuristicLab.Optimization;
    23
    34namespace HeuristicLab.JsonInterface.OptimizerIntegration {
     
    2728    private void InitializeComponent() {
    2829      this.components = new System.ComponentModel.Container();
     30      HeuristicLab.Core.CheckedItemList<HeuristicLab.Optimization.IRunCollectionModifier> checkedItemList_11 = new HeuristicLab.Core.CheckedItemList<HeuristicLab.Optimization.IRunCollectionModifier>();
    2931      this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
    3032      this.exportButton = new System.Windows.Forms.Button();
     
    4143      this.tabPage2 = new System.Windows.Forms.TabPage();
    4244      this.tabPage3 = new System.Windows.Forms.TabPage();
     45      this.postProcessorListControl = new HeuristicLab.JsonInterface.OptimizerIntegration.ResultCollectionPostProcessorControl();
    4346      this.label1 = new System.Windows.Forms.Label();
    4447      this.textBoxTemplateName = new System.Windows.Forms.TextBox();
     
    5861      this.tabPage1.SuspendLayout();
    5962      this.tabPage2.SuspendLayout();
     63      this.tabPage3.SuspendLayout();
    6064      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6165      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit();
     
    175179      this.splitContainer2.SplitterDistance = 380;
    176180      this.splitContainer2.TabIndex = 9;
    177       // postProcessorListView
    178       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;
    182181      //
    183182      // tabControl1
     
    224223      this.tabPage3.Size = new System.Drawing.Size(802, 505);
    225224      this.tabPage3.TabIndex = 2;
    226       this.tabPage3.Text = "Post Processors";
     225      this.tabPage3.Text = "Result Collection Modifiers";
    227226      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;
    228239      //
    229240      // label1
     
    282293      this.tabPage1.ResumeLayout(false);
    283294      this.tabPage2.ResumeLayout(false);
     295      this.tabPage3.ResumeLayout(false);
    284296      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    285297      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r18050 r18055  
    2222    private IOptimizer Optimizer { get; set; }
    2323    private IList<IJsonItemVM> VMs { get; set; }
    24     private ICheckedItemList<IResultCollectionProcessor> PostProcessors { get; set; }
     24    private ICheckedItemList<IRunCollectionModifier> RunCollectionModifiers { get; set; }
    2525    #endregion
    2626
     
    6161    public ExportJsonDialog() {
    6262      InitializeComponent();
    63       this.PostProcessors = this.postProcessorListControl.Content;
     63      this.RunCollectionModifiers = this.postProcessorListControl.Content;
    6464      this.Icon = HeuristicLab.Common.Resources.HeuristicLab.Icon;
    6565      InitCache();
     
    7878          JsonTemplateGenerator.GenerateTemplate(
    7979            Path.Combine(FolderBrowserDialog.SelectedPath, textBoxTemplateName.Text),
    80             Optimizer, Root, PostProcessors.CheckedItems.Select(x => x.Value));
     80            Optimizer, Root, RunCollectionModifiers.CheckedItems.Select(x => x.Value));
    8181          Close();
    8282        } catch (Exception ex) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultCollectionPostProcessorControl.cs

    r18050 r18055  
    99using System.Windows.Forms;
    1010using HeuristicLab.Collections;
     11using HeuristicLab.Optimization;
    1112
    1213namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    13   public partial class ResultCollectionPostProcessorControl : Core.Views.CheckedItemListView<IResultCollectionProcessor> {
     14  public partial class ResultCollectionPostProcessorControl : Core.Views.CheckedItemListView<IRunCollectionModifier> {
    1415    public ResultCollectionPostProcessorControl() {
    1516      InitializeComponent();
    1617    }
    1718
    18     protected override string GroupBoxText => "Result Collection Processors";
     19    protected override string GroupBoxText => "Run Collection Modifiers";
    1920
    2021  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Constants.cs

    r18050 r18055  
    1010    internal const string Parameters = "Parameters";
    1111    internal const string Results = "Results";
    12     internal const string ResultCollectionProcessorItems = "ResultCollectionProcessors";
     12    internal const string RunCollectionModifiers = "RunCollectionModifiers";
    1313
    1414    internal const string Template = @"{
     
    1919      '" + Parameters + @"': [],
    2020      '" + Results + @"': [],
    21       '" + ResultCollectionProcessorItems + @"': []
     21      '" + RunCollectionModifiers + @"': []
    2222    }";
    2323  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj

    r18050 r18055  
    6666    <Compile Include="Converters\BatchRunConverter.cs" />
    6767    <Compile Include="Converters\ExperimentConverter.cs" />
    68     <Compile Include="Converters\ObervableListConverter.cs" />
     68    <Compile Include="Converters\ItemCollectionConverter.cs" />
    6969    <Compile Include="Converters\RegressionProblemDataConverter.cs" />
    7070    <Compile Include="Converters\ResultConverter.cs" />
     
    8484    <Compile Include="Interfaces\IValueJsonItem.cs" />
    8585    <Compile Include="Interfaces\IValueLookupJsonItem.cs" />
    86     <Compile Include="Interfaces\IResultCollectionProcessor.cs" />
     86    <Compile Include="Interfaces\IListJsonItem.cs" />
    8787    <Compile Include="JsonItems\ArrayJsonItem.cs" />
    8888    <Compile Include="JsonItems\BoolJsonItems.cs" />
     
    9898    <Compile Include="JsonItems\IntJsonItems.cs" />
    9999    <Compile Include="JsonItems\JsonItem.cs" />
     100    <Compile Include="JsonItems\ListJsonItem.cs" />
    100101    <Compile Include="JsonItems\LookupJsonItem.cs" />
    101102    <Compile Include="JsonItems\MatrixJsonItem.cs" />
     
    106107    <Compile Include="JsonItems\ValueJsonItem.cs" />
    107108    <Compile Include="JsonItems\ValueLookupJsonItem.cs" />
     109    <Compile Include="ResultCollectionProcessors\AbstractProcessors\RunCollectionSRSolutionFormatter.cs" />
    108110    <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" />
    110114    <Compile Include="ResultFormatters\MatlabResultFormatter.cs" />
    111115    <Compile Include="ResultFormatters\PythonResultFormatter.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ArrayJsonItem.cs

    r17519 r18055  
    11using Newtonsoft.Json.Linq;
     2using HEAL.Attic;
    23
    34namespace HeuristicLab.JsonInterface {
     5  [StorableType("1A448B57-6587-4EB4-9A0A-B05C376894C6")]
    46  public abstract class ArrayJsonItem<T> : ValueJsonItem<T[]>, IArrayJsonItem {
    57    public virtual bool Resizable { get; set; }
     
    810      Resizable = (jObject[nameof(IArrayJsonItem.Resizable)]?.ToObject<bool>()).GetValueOrDefault();
    911    }
     12
     13    public ArrayJsonItem() { }
     14
     15    [StorableConstructor]
     16    protected ArrayJsonItem(StorableConstructorFlag _) : base(_) { }
     17
    1018  }
    1119}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/BoolJsonItems.cs

    r17519 r18055  
    1 namespace HeuristicLab.JsonInterface {
     1using HEAL.Attic;
     2
     3namespace HeuristicLab.JsonInterface {
     4  [StorableType("01F11732-16D0-4115-82B7-1BE3A731DC14")]
    25  public class BoolJsonItem : ValueJsonItem<bool> {
    36    protected override ValidationResult Validate() => ValidationResult.Successful();
     7
     8    public BoolJsonItem() { }
     9
     10    [StorableConstructor]
     11    protected BoolJsonItem(StorableConstructorFlag _) : base(_) { }
    412  }
    513
     14  [StorableType("49995C46-3B9B-49FC-952C-85645D0B565A")]
    615  public class BoolArrayJsonItem : ArrayJsonItem<bool> {
    716    protected override ValidationResult Validate() => ValidationResult.Successful();
     17
     18    public BoolArrayJsonItem() { }
     19
     20    [StorableConstructor]
     21    protected BoolArrayJsonItem(StorableConstructorFlag _) : base(_) { }
    822  }
    923
     24  [StorableType("5680A943-A5C4-4310-977E-261252810766")]
    1025  public class BoolMatrixJsonItem : MatrixJsonItem<bool> {
    1126    protected override ValidationResult Validate() => ValidationResult.Successful();
     27
     28    public BoolMatrixJsonItem() { }
     29
     30    [StorableConstructor]
     31    protected BoolMatrixJsonItem(StorableConstructorFlag _) : base(_) { }
    1232  }
    1333}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ConcreteRestrictedArrayJsonItem.cs

    r17519 r18055  
    11using System.Collections.Generic;
    22using System.Linq;
     3using HEAL.Attic;
     4
    35namespace HeuristicLab.JsonInterface {
     6  [StorableType("4333B6C0-26F7-41BA-A297-071AB50307F9")]
    47  public abstract class ConcreteRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IConcreteRestrictedJsonItem<T> {
    58    public IEnumerable<T> ConcreteRestrictedItems { get; set; }
     
    912      IList<string> errors = new List<string>();
    1013      if (ConcreteRestrictedItems == null) return ValidationResult.Successful();
    11       foreach(var x in Value) {
     14      foreach (var x in Value) {
    1215        bool tmp = false;
    13         foreach(var restrictedItem in ConcreteRestrictedItems) {
     16        foreach (var restrictedItem in ConcreteRestrictedItems) {
    1417          tmp = tmp || x.Equals(restrictedItem); //if one tmp is true, it stays true (match found)
    1518        }
     
    1922        res = res && tmp; //if one tmp is false, res will set false
    2023      }
    21       if (res) 
     24      if (res)
    2225        return ValidationResult.Successful();
    23       else 
     26      else
    2427        return ValidationResult.Faulty(errors);
    2528    }
     29
     30    public ConcreteRestrictedArrayJsonItem() { }
     31
     32    [StorableConstructor]
     33    protected ConcreteRestrictedArrayJsonItem(StorableConstructorFlag _) : base(_) { }
    2634  }
    2735}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ConcreteRestrictedValueJsonItem.cs

    r18043 r18055  
    11using System.Collections.Generic;
    22using System.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
    5 
     6  [StorableType("4B3B7E23-4317-4804-BB51-88ABFD58CD03")]
    67  public abstract class ConcreteRestrictedValueJsonItem<T> : ValueJsonItem<T>, IConcreteRestrictedJsonItem<T> {
    78
     
    1617        $"'{ string.Join(",", ConcreteRestrictedItems.Select(s => s.ToString()).ToArray()) }'.");
    1718    }
     19
     20    public ConcreteRestrictedValueJsonItem() { }
     21
     22    [StorableConstructor]
     23    protected ConcreteRestrictedValueJsonItem(StorableConstructorFlag _) : base(_) { }
    1824  }
    1925}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/DateTimeJsonItem.cs

    r17519 r18055  
    11using System;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
     6  [StorableType("C700603D-50E5-448B-B785-9974463A91A8")]
    57  public class DateTimeJsonItem : IntervalRestrictedValueJsonItem<DateTime> {
    6    
     8
    79    public override JObject GenerateJObject() {
    810      var obj = base.GenerateJObject();
     
    2224      base.SetJObject(jObject);
    2325    }
     26
     27    public DateTimeJsonItem() { }
     28
     29    [StorableConstructor]
     30    protected DateTimeJsonItem(StorableConstructorFlag _) : base(_) { }
    2431  }
    2532}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/DoubleJsonItems.cs

    r17519 r18055  
    11using Newtonsoft.Json.Linq;
     2using HEAL.Attic;
    23
    34namespace HeuristicLab.JsonInterface {
     5  [StorableType("B9B3843E-90B9-453F-AB7F-B3A4B8DF6809")]
    46  public class DoubleJsonItem : IntervalRestrictedValueJsonItem<double> {
    57    public override JObject GenerateJObject() {
     
    2022      base.SetJObject(jObject);
    2123    }
     24
     25    public DoubleJsonItem() { }
     26
     27    [StorableConstructor]
     28    protected DoubleJsonItem(StorableConstructorFlag _) : base(_) { }
    2229  }
     30
     31  [StorableType("D7E2BA3D-E9F7-4062-8423-182B517FA7CA")]
    2332  public class DoubleArrayJsonItem : IntervalRestrictedArrayJsonItem<double> {
    2433    public override JObject GenerateJObject() {
     
    3948      base.SetJObject(jObject);
    4049    }
     50
     51    public DoubleArrayJsonItem() { }
     52
     53    [StorableConstructor]
     54    protected DoubleArrayJsonItem(StorableConstructorFlag _) : base(_) { }
    4155  }
     56
     57  [StorableType("4ED29A62-F368-476B-B551-4283E428F7B9")]
    4258  public class DoubleRangeJsonItem : RangedJsonItem<double> {
    4359    public override JObject GenerateJObject() {
     
    5874      base.SetJObject(jObject);
    5975    }
     76
     77    public DoubleRangeJsonItem() { }
     78
     79    [StorableConstructor]
     80    protected DoubleRangeJsonItem(StorableConstructorFlag _) : base(_) { }
    6081  }
     82
     83  [StorableType("39C117DA-6274-4C1F-8CA8-A57B1A7A9C72")]
    6184  public class DoubleMatrixJsonItem : IntervalRestrictedMatrixJsonItem<double> {
    6285    public override JObject GenerateJObject() {
     
    77100      base.SetJObject(jObject);
    78101    }
     102
     103    public DoubleMatrixJsonItem() { }
     104
     105    [StorableConstructor]
     106    protected DoubleMatrixJsonItem(StorableConstructorFlag _) : base(_) { }
    79107  }
    80108}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/EmptyJsonItem.cs

    r17519 r18055  
    1 namespace HeuristicLab.JsonInterface {
     1using HEAL.Attic;
     2
     3namespace HeuristicLab.JsonInterface {
     4  [StorableType("B33EA674-10D1-4184-A564-9EE7F7BFC55B")]
    25  public class EmptyJsonItem : JsonItem {
    36    protected override ValidationResult Validate() => ValidationResult.Successful();
     7
     8    public EmptyJsonItem() { }
     9
     10    [StorableConstructor]
     11    protected EmptyJsonItem(StorableConstructorFlag _) : base(_) { }
    412  }
    513}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntJsonItems.cs

    r17519 r18055  
    11using Newtonsoft.Json.Linq;
     2using HEAL.Attic;
    23
    34namespace HeuristicLab.JsonInterface {
     5  [StorableType("4FFDAC9B-34F3-4FDB-ABD1-BB2128CE5A49")]
    46  public class IntJsonItem : IntervalRestrictedValueJsonItem<int> {
    57    public override JObject GenerateJObject() {
     
    2022      base.SetJObject(jObject);
    2123    }
     24
     25    public IntJsonItem() { }
     26
     27    [StorableConstructor]
     28    protected IntJsonItem(StorableConstructorFlag _) : base(_) { }
    2229  }
     30
     31  [StorableType("73E22461-6CA0-4BE1-A5FE-9EF7FFD320AD")]
    2332  public class IntArrayJsonItem : IntervalRestrictedArrayJsonItem<int> {
    2433    public override JObject GenerateJObject() {
     
    3948      base.SetJObject(jObject);
    4049    }
     50
     51    public IntArrayJsonItem() { }
     52
     53    [StorableConstructor]
     54    protected IntArrayJsonItem(StorableConstructorFlag _) : base(_) { }
    4155  }
     56
     57  [StorableType("A6FBA509-FC37-4E54-9578-5AFB764CFB89")]
    4258  public class IntRangeJsonItem : RangedJsonItem<int> {
    4359    public override JObject GenerateJObject() {
     
    5874      base.SetJObject(jObject);
    5975    }
     76
     77    public IntRangeJsonItem() { }
     78
     79    [StorableConstructor]
     80    protected IntRangeJsonItem(StorableConstructorFlag _) : base(_) { }
    6081  }
     82
     83  [StorableType("3CFF8D3E-8608-41BA-85A5-42CD4DA45685")]
    6184  public class IntMatrixJsonItem : IntervalRestrictedMatrixJsonItem<int> {
    6285    public override JObject GenerateJObject() {
     
    77100      base.SetJObject(jObject);
    78101    }
     102
     103    public IntMatrixJsonItem() { }
     104
     105    [StorableConstructor]
     106    protected IntMatrixJsonItem(StorableConstructorFlag _) : base(_) { }
    79107  }
    80108}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedArrayJsonItem.cs

    r17519 r18055  
    22using System.Collections.Generic;
    33using Newtonsoft.Json.Linq;
     4using HEAL.Attic;
    45
    56namespace HeuristicLab.JsonInterface {
     7  [StorableType("97466581-CCF1-45BD-B5F8-87B8660DBE13")]
    68  public abstract class IntervalRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IIntervalRestrictedJsonItem<T>
    7     where T : IComparable {
     9      where T : IComparable {
    810    public T Minimum { get; set; }
    911    public T Maximum { get; set; }
     
    3133      if (maxProp != null) Maximum = maxProp.ToObject<T>();
    3234    }
     35
     36    public IntervalRestrictedArrayJsonItem() { }
     37
     38    [StorableConstructor]
     39    protected IntervalRestrictedArrayJsonItem(StorableConstructorFlag _) : base(_) { }
    3340  }
    3441}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedJsonItem.cs

    r18043 r18055  
    11using System;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
     6  [StorableType("4D76601B-9627-4ABD-A24B-49179D59AB11")]
    57  public abstract class IntervalRestrictedJsonItem<T> : JsonItem, IIntervalRestrictedJsonItem<T>
    6     where T : IComparable {
     8      where T : IComparable {
    79    public T Minimum { get; set; }
    810    public T Maximum { get; set; }
     
    1719      if (maxProp != null) Maximum = maxProp.ToObject<T>();
    1820    }
     21
     22    public IntervalRestrictedJsonItem() { }
     23
     24    [StorableConstructor]
     25    protected IntervalRestrictedJsonItem(StorableConstructorFlag _) : base(_) { }
    1926  }
    2027}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedMatrixJsonItem.cs

    r17519 r18055  
    22using System.Collections.Generic;
    33using Newtonsoft.Json.Linq;
     4using HEAL.Attic;
    45
    56namespace HeuristicLab.JsonInterface {
     7  [StorableType("4FEDB1E0-B4B7-4EAD-8D5E-B2AA13C37F40")]
    68  public abstract class IntervalRestrictedMatrixJsonItem<T> : MatrixJsonItem<T>, IIntervalRestrictedJsonItem<T>
    7     where T : IComparable {
     9      where T : IComparable {
    810    public T Minimum { get; set; }
    911    public T Maximum { get; set; }
     
    3335      if (maxProp != null) Maximum = maxProp.ToObject<T>();
    3436    }
     37
     38    public IntervalRestrictedMatrixJsonItem() { }
     39
     40    [StorableConstructor]
     41    protected IntervalRestrictedMatrixJsonItem(StorableConstructorFlag _) : base(_) { }
    3542  }
    3643}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedValueJsonItem.cs

    r18040 r18055  
    11using System;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace 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 {
    79    public T Minimum { get; set; }
    810    public T Maximum { get; set; }
     
    2325      if (maxProp != null) Maximum = maxProp.ToObject<T>();
    2426    }
     27
     28    public IntervalRestrictedValueJsonItem() { }
     29
     30    [StorableConstructor]
     31    protected IntervalRestrictedValueJsonItem(StorableConstructorFlag _) : base(_) { }
    2532  }
    2633}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/JsonItem.cs

    r17843 r18055  
    66using Newtonsoft.Json;
    77using Newtonsoft.Json.Linq;
     8using HEAL.Attic;
    89
    910namespace HeuristicLab.JsonInterface {
     
    3233  }
    3334
     35  [StorableType("B1270D98-B0D9-40FB-B089-F6E70C65CD65")]
    3436  /// <summary>
    3537  /// Main data class for json interface.
     
    3840
    3941    public class JsonItemValidator : IJsonItemValidator {
    40       private IDictionary<int, bool> Cache = new Dictionary<int, bool>();
     42      //private IDictionary<int, bool> Cache = new Dictionary<int, bool>();
    4143      private JsonItem Root { get; set; }
    4244      public JsonItemValidator(JsonItem root) {
     
    4749        List<string> errors = new List<string>();
    4850        bool success = true;
    49         foreach(var x in Root) {
     51        foreach (var x in Root) {
    5052          JsonItem item = x as JsonItem;
    51           if(item.Active) {
     53          if (item.Active) {
    5254            var res = ((JsonItem)x).Validate();
    5355            //if one success is false -> whole validation is false
     
    6870        IJsonItem tmp = Parent;
    6971        StringBuilder builder = new StringBuilder(this.Name);
    70         while(tmp != null) {
     72        while (tmp != null) {
    7173          builder.Insert(0, tmp.Name + ".");
    7274          tmp = tmp.Parent;
     
    8688
    8789    #region Constructors
     90    [StorableConstructor]
     91    protected JsonItem(StorableConstructorFlag _) { }
     92
    8893    public JsonItem() { }
    8994
     
    9297    }
    9398    #endregion
    94    
     99
    95100    #region Public Methods
    96     public void AddChildren(params IJsonItem[] childs) => 
     101    public void AddChildren(params IJsonItem[] childs) =>
    97102      AddChildren(childs as IEnumerable<IJsonItem>);
    98103
     
    101106      if (Children == null)
    102107        Children = new List<IJsonItem>();
    103       if(Children is IList<IJsonItem> list) {
     108      if (Children is IList<IJsonItem> list) {
    104109        foreach (var child in childs) {
    105110          list.Add(child);
     
    131136    public virtual IEnumerator<IJsonItem> GetEnumerator() {
    132137      yield return this;
    133      
     138
    134139      if (Children != null) {
    135140        foreach (var x in Children) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/LookupJsonItem.cs

    r17519 r18055  
    11using Newtonsoft.Json.Linq;
     2using HEAL.Attic;
    23
    34namespace HeuristicLab.JsonInterface {
     5  [StorableType("DE16C5EB-998D-4D34-BD98-7BF0E02A56BC")]
    46  public class LookupJsonItem : JsonItem, ILookupJsonItem {
    57    public virtual string ActualName { get; set; }
     
    1113
    1214    protected override ValidationResult Validate() => ValidationResult.Successful();
     15
     16    public LookupJsonItem() { }
     17
     18    [StorableConstructor]
     19    protected LookupJsonItem(StorableConstructorFlag _) : base(_) { }
    1320  }
    1421}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/MatrixJsonItem.cs

    r17519 r18055  
    11using System.Collections.Generic;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
     6  [StorableType("2DCBBBA5-B29F-4E97-A3BC-99F7C9E15759")]
    57  public abstract class MatrixJsonItem<T> : ValueJsonItem<T[][]>, IMatrixJsonItem {
    68    public virtual bool RowsResizable { get; set; }
     
    2628      ColumnNames = jObject[nameof(IMatrixJsonItem.ColumnNames)]?.ToObject<IEnumerable<string>>();
    2729    }
     30
     31    public MatrixJsonItem() { }
     32
     33    [StorableConstructor]
     34    protected MatrixJsonItem(StorableConstructorFlag _) : base(_) { }
    2835  }
    2936}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/RangedJsonItem.cs

    r18040 r18055  
    22using System.Collections.Generic;
    33using Newtonsoft.Json.Linq;
     4using HEAL.Attic;
    45
    56namespace HeuristicLab.JsonInterface {
     7  [StorableType("856DE916-D830-43A8-9B40-37E512A177DB")]
    68  public abstract class RangedJsonItem<T> : IntervalRestrictedJsonItem<T>, IRangedJsonItem<T>
    7     where T : IComparable {
     9      where T : IComparable {
    810    public T MinValue { get; set; }
    9    
     11
    1012    public T MaxValue { get; set; }
    1113
     
    3032    }
    3133
     34    public RangedJsonItem() { }
     35
     36    [StorableConstructor]
     37    protected RangedJsonItem(StorableConstructorFlag _) : base(_) { }
     38
    3239  }
    3340}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ResultJsonItem.cs

    r17843 r18055  
    11using System;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
     6  [StorableType("AA00656C-56D5-4F4E-9843-BA15636FC399")]
    57  public class ResultJsonItem : JsonItem, IResultJsonItem {
    68    public string ResultFormatterType { get; set; }
     
    1517    }
    1618
     19    public ResultJsonItem() { }
     20
     21    [StorableConstructor]
     22    protected ResultJsonItem(StorableConstructorFlag _) : base(_) { }
     23
    1724  }
    1825}
  • 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> { }
     1using HEAL.Attic;
     2
     3namespace 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  }*/
    423}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/UnsupportedJsonItem.cs

    r18043 r18055  
    33using System.Linq;
    44using Newtonsoft.Json;
     5using HEAL.Attic;
    56
    67namespace HeuristicLab.JsonInterface {
     8  [StorableType("0E2CA132-AA19-4FC7-B2FD-09572F2E0967")]
    79  public class UnsupportedJsonItem : JsonItem {
    810
     
    1416
    1517    protected override ValidationResult Validate() => ValidationResult.Successful();
     18
     19    public UnsupportedJsonItem() { }
     20
     21    [StorableConstructor]
     22    protected UnsupportedJsonItem(StorableConstructorFlag _) : base(_) { }
    1623  }
    1724}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ValueJsonItem.cs

    r17519 r18055  
    11using System;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
     6  [StorableType("29139288-7ABB-4391-926E-5975CF38141E")]
    57  public abstract class ValueJsonItem : JsonItem, IValueJsonItem {
    68    public object Value { get; set; }
     
    1012    }
    1113
     14    public ValueJsonItem() { }
     15
     16    [StorableConstructor]
     17    protected ValueJsonItem(StorableConstructorFlag _) : base(_) {
     18    }
     19
    1220  }
    1321
     22  [StorableType("86085358-50D6-4486-9265-F6CEA8C8FA19")]
    1423  public abstract class ValueJsonItem<T> : ValueJsonItem, IValueJsonItem<T> {
    1524    public new T Value {
     
    2938
    3039    public override void SetJObject(JObject jObject) {
    31       if(jObject[nameof(IValueJsonItem<T>.Value)] != null)
     40      if (jObject[nameof(IValueJsonItem<T>.Value)] != null)
    3241        Value = jObject[nameof(IValueJsonItem<T>.Value)].ToObject<T>();
    3342    }
     43
     44    public ValueJsonItem() { }
     45
     46    [StorableConstructor]
     47    protected ValueJsonItem(StorableConstructorFlag _) : base(_) { }
    3448  }
    3549}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ValueLookupJsonItem.cs

    r17519 r18055  
    11using System.Collections.Generic;
    22using Newtonsoft.Json.Linq;
     3using HEAL.Attic;
    34
    45namespace HeuristicLab.JsonInterface {
     6  [StorableType("D2521F37-3968-4FAC-AEE9-F083AA86C06C")]
    57  public class ValueLookupJsonItem : LookupJsonItem, IValueLookupJsonItem {
    68    public IJsonItem ActualValue { get; set; }
     
    1315    public override JObject GenerateJObject() {
    1416      var obj = base.GenerateJObject();
    15       if(ActualValue != null) {
     17      if (ActualValue != null) {
    1618        obj.Add(nameof(IValueLookupJsonItem.ActualValue), ActualValue.Path);
    1719      }
     
    2123    public override IEnumerator<IJsonItem> GetEnumerator() {
    2224      using (var it = base.GetEnumerator()) {
    23         while(it.MoveNext()) {
     25        while (it.MoveNext()) {
    2426          yield return it.Current;
    2527        }
    2628      }
    27       if(ActualValue != null) {
     29      if (ActualValue != null) {
    2830        using (var it = ActualValue.GetEnumerator()) {
    2931          while (it.MoveNext()) {
     
    3335      }
    3436    }
     37
     38    public ValueLookupJsonItem() { }
     39
     40    [StorableConstructor]
     41    protected ValueLookupJsonItem(StorableConstructorFlag _) : base(_) { }
    3542  }
    3643}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateGenerator.cs

    r18050 r18055  
    1919    /// <param name="optimizer">the optimizer object to serialize</param>
    2020    /// <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<IResultCollectionProcessor> resultCollectionProcessors) {
     21    public static void GenerateTemplate(string templatePath, IOptimizer optimizer, IJsonItem rootItem, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    2222      // clear all runs
    2323      if (optimizer.ExecutionState == ExecutionState.Paused)
     
    3434      JArray parameterItems = new JArray();
    3535      JArray resultItems = new JArray();
    36       JArray resultCollectionProcessorItems = new JArray();
     36      JArray runCollectionModifierItems = new JArray();
    3737      string templateName = Path.GetFileName(templatePath);
    3838      string templateDirectory = Path.GetDirectoryName(templatePath);
     
    6060      #endregion
    6161
    62       #region ResultCollectionProcessor Serialization
    63       foreach (var proc in resultCollectionProcessors) {
     62      #region RunCollectionModifiers Serialization
     63      foreach (var proc in runCollectionModifiers) {
    6464        JArray rcpParameterItems = new JArray();
    6565        var guid = StorableTypeAttribute.GetStorableTypeAttribute(proc.GetType()).Guid.ToString();
     
    7777        processorObj.Add("GUID", guid);
    7878        processorObj.Add(Constants.Parameters, rcpParameterItems);
    79         resultCollectionProcessorItems.Add(processorObj);
     79        runCollectionModifierItems.Add(processorObj);
    8080      }
    8181      #endregion
     
    8686      template[Constants.Parameters] = parameterItems;
    8787      template[Constants.Results] = resultItems;
    88       template[Constants.ResultCollectionProcessorItems] = resultCollectionProcessorItems;
     88      template[Constants.RunCollectionModifiers] = runCollectionModifierItems;
    8989      #endregion
    9090
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs

    r18050 r18055  
    1414      Optimizer = optimizer;
    1515      ConfiguredResultItems = configuredResultItems;
    16       PostProcessors = Enumerable.Empty<IResultCollectionProcessor>();
     16      RunCollectionModifiers = Enumerable.Empty<IRunCollectionModifier>();
    1717    }
    1818
    19     public InstantiatorResult(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IResultCollectionProcessor> postProcessors) {
     19    public InstantiatorResult(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    2020      Optimizer = optimizer;
    2121      ConfiguredResultItems = configuredResultItems;
    22       PostProcessors = postProcessors;
     22      RunCollectionModifiers = runCollectionModifiers;
    2323    }
    2424
    2525    public IOptimizer Optimizer { get; }
    2626    public IEnumerable<IResultJsonItem> ConfiguredResultItems { get; }
    27     public IEnumerable<IResultCollectionProcessor> PostProcessors { get; }
     27    public IEnumerable<IRunCollectionModifier> RunCollectionModifiers { get; }
    2828  }
    2929
     
    9494      JsonItemConverter.Inject(optimizer, rootItem);
    9595
    96       return new InstantiatorResult(optimizer, CollectResults(), CollectResultCollectionProcessors());
     96      return new InstantiatorResult(optimizer, CollectResults(), CollectRunCollectionModifiers());
    9797    }
    9898
     
    100100    /// Instantiates all defined (in template) ResultCollectionProcessors and injects the configured parameters.
    101101    /// </summary>
    102     private IEnumerable<IResultCollectionProcessor> CollectResultCollectionProcessors() {
    103       IList<IResultCollectionProcessor> postProcessorList = new List<IResultCollectionProcessor>();
    104       foreach (JObject obj in Template[Constants.ResultCollectionProcessorItems]) {
     102    private IEnumerable<IRunCollectionModifier> CollectRunCollectionModifiers() {
     103      IList<IRunCollectionModifier> runCollectionModifiers = new List<IRunCollectionModifier>();
     104      foreach (JObject obj in Template[Constants.RunCollectionModifiers]) {
    105105        var guid = obj["GUID"].ToString();
    106106        var parameters = obj[Constants.Parameters];
    107107        var type = Mapper.StaticCache.GetType(new Guid(guid));
    108         var rcp = (IResultCollectionProcessor)Activator.CreateInstance(type);
     108        var rcp = (IRunCollectionModifier)Activator.CreateInstance(type);
    109109        var rcpItem = JsonItemConverter.Extract(rcp);
    110110
     
    117117
    118118        JsonItemConverter.Inject(rcp, rcpItem);
    119         postProcessorList.Add(rcp);
     119        runCollectionModifiers.Add(rcp);
    120120      }
    121       return postProcessorList;
     121      return runCollectionModifiers;
    122122    }
    123123
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultCollectionProcessors/FilterResultCollectionProcessor.cs

    r18050 r18055  
    1212
    1313namespace HeuristicLab.JsonInterface {
     14  /*
    1415  [StorableType("4AF9EF94-2EF3-4F54-8B8D-942454CF8DDF")]
    15   public class FilterResultCollectionProcessor : ParameterizedNamedItem, IResultCollectionProcessor {
     16  public class FilterResultCollectionProcessor : ParameterizedNamedItem, IRunCollectionModifier {
    1617
    1718    #region Constants
    1819    private const string FilterStringParameterName = "Filters";
     20    private const string Filter2StringParameterName = "Filters2";
    1921    #endregion
    2022
     
    2224    public IFixedValueParameter<StringValue> FilterStringParameter =>
    2325      (IFixedValueParameter<StringValue>)Parameters[FilterStringParameterName];
     26    public IFixedValueParameter<ItemList<StringValue>> Filter2StringParameter =>
     27      (IFixedValueParameter<ItemList<StringValue>>)Parameters[Filter2StringParameterName];
    2428    #endregion
    2529
     
    2933    public FilterResultCollectionProcessor() {
    3034      Parameters.Add(new FixedValueParameter<StringValue>(FilterStringParameterName, "", new StringValue()));
     35      Parameters.Add(new FixedValueParameter<ItemList<StringValue>>(Filter2StringParameterName, "", new ItemList<StringValue>()));
    3136    }
    3237    public FilterResultCollectionProcessor(FilterResultCollectionProcessor original, Cloner cloner) : base(original, cloner) { }
     
    3944      var filters = FilterStringParameter.Value.Value.Split(';');
    4045     
    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      }
    4750    }
    48   }
     51  }*/
    4952}
  • 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;
     1using HeuristicLab.Common;
     2using HeuristicLab.Problems.DataAnalysis.Symbolic;
     3using HEAL.Attic;
     4using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    85using 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;
    146
    157namespace HeuristicLab.JsonInterface {
     8  [Item(Name = "RunCollection SymbolicRegressionSolution Python Formatter")]
    169  [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();
    1813
    1914    #region Constructors & Cloning
    2015    [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) { }
    2419
    2520    public override IDeepCloneable Clone(Cloner cloner) {
    26       return new SymRegPythonProcessor(this, cloner);
     21      return new RunCollectionSRSolutionPythonFormatter(this, cloner);
    2722    }
    2823    #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     }
    3924  }
    4025}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Optimization/3.3/RunCollectionModification/RunCollectionValueRemover.cs

    r17180 r18055  
    2727using HeuristicLab.Parameters;
    2828using HEAL.Attic;
     29using HeuristicLab.Collections;
    2930
    3031namespace HeuristicLab.Optimization {
     
    3839    }
    3940
     41    public IFixedValueParameter<BoolValue> InvertParameter {
     42      get { return (IFixedValueParameter<BoolValue>)Parameters["Invert"]; }
     43    }
     44
    4045    public IEnumerable<string> Values {
    4146      get { return ValuesParameter.Value.CheckedItems.Select(v => v.Value); }
    4247    }
     48
     49    public bool Invert => InvertParameter.Value.Value;
    4350
    4451    #region Construction & Cloning   
     
    4956    }
    5057    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)));
    5260    }
    5361    public override IDeepCloneable Clone(Cloner cloner) {
     
    5664    #endregion   
    5765
    58     public void Modify(List<IRun> runs) {     
     66    public void Modify(List<IRun> runs) {
    5967      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      }   
    6584    }
    6685   
Note: See TracChangeset for help on using the changeset viewer.