Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18059


Ignore:
Timestamp:
09/23/21 13:03:53 (3 years ago)
Author:
dpiringe
Message:

#3026

  • removed/renamed all interfaces, classes and views related to results (are replaced by RunCollectionModifiers)
  • fixed a bug in JsonTemplateInstantiator to prevent errors for opening templates without a defined property for RunCollectionModifiers
Location:
branches/3026_IntegrationIntoSymSpace
Files:
9 deleted
11 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs

    r18055 r18059  
    1414      InstantiatorResult instantiatorResult = JsonTemplateInstantiator.Instantiate(template, config);
    1515      IOptimizer optimizer = instantiatorResult.Optimizer;
    16       IEnumerable<IResultJsonItem> configuredResultItem = instantiatorResult.ConfiguredResultItems;
    1716
    1817      optimizer.Runs.Clear();
     
    2221      Task task = optimizer.StartAsync();
    2322      while (!task.IsCompleted) {
    24         WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.RunCollectionModifiers);
     23        WriteResultsToFile(outputFile, optimizer, instantiatorResult.RunCollectionModifiers);
    2524        Thread.Sleep(100);
    2625      }
    2726
    28       WriteResultsToFile(outputFile, optimizer, configuredResultItem, instantiatorResult.RunCollectionModifiers);
     27      WriteResultsToFile(outputFile, optimizer, instantiatorResult.RunCollectionModifiers);
    2928    }
    3029
    31     private static void WriteResultsToFile(string file, IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItem, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
     30    private static void WriteResultsToFile(string file, IOptimizer optimizer, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    3231      if (optimizer.Runs.Count > 0)
    33         File.WriteAllText(file, FetchResults(optimizer, configuredResultItem, runCollectionModifiers));
     32        File.WriteAllText(file, FetchResults(optimizer, runCollectionModifiers));
    3433    }
     34
     35    private static string FetchResults(IOptimizer optimizer, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
     36      JArray arr = new JArray();
    3537     
    36 
    37     private static IEnumerable<IResultFormatter> ResultFormatter { get; } =
    38       PluginInfrastructure.ApplicationManager.Manager.GetInstances<IResultFormatter>();
    39 
    40     private static IResultFormatter GetResultFormatter(string fullName) =>
    41       ResultFormatter?.Where(x => x.GetType().FullName == fullName).Last();
    42 
    43     private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    44       JArray arr = new JArray();
    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()));
     38      foreach (var modifier in runCollectionModifiers)
     39        modifier.Modify(new List<IRun>(optimizer.Runs.ToArray()));
    4940     
    5041      foreach (var run in optimizer.Runs) {
     
    5445        foreach (var result in run.Results)
    5546          obj.Add(result.Key, result.Value.ToString());
    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         }
    7347      }
    74       /*
    75       foreach (var run in optimizer.Runs) {
    76         JObject obj = new JObject();
    77         arr.Add(obj);
    78         obj.Add("Run", JToken.FromObject(run.ToString()));
    79 
    80         // zip and filter the results with the ResultJsonItems
    81         var filteredResults = new List<Tuple<IResultJsonItem, IItem>>();
    82         foreach(var resultItem in configuredResultItems) {
    83           foreach(var result in run.Results) {
    84             if(resultItem.Name == result.Key) {
    85               filteredResults.Add(Tuple.Create(resultItem, result.Value));
    86             }
    87           }
    88         }
    89 
    90         // add results to the JObject
    91         foreach(var result in filteredResults) {
    92           var formatter = GetResultFormatter(result.Item1.ResultFormatterType);
    93           if(!obj.ContainsKey(result.Item1.Name)) // to prevent duplicates
    94             obj.Add(result.Item1.Name, formatter.Format(result.Item2));
    95         }
    96       }*/
    9748      return SingleLineArrayJsonWriter.Serialize(arr);
    9849    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj

    r18047 r18059  
    134134    <Compile Include="ViewModels\RangedValueBaseVM.cs" />
    135135    <Compile Include="ViewModels\RangeVM.cs" />
    136     <Compile Include="ViewModels\ResultItemVM.cs" />
    137136    <Compile Include="ViewModels\SingleValueVM.cs" />
    138137    <Compile Include="ViewModels\StringValueVM.cs" />
     
    155154    <Compile Include="Plugin.cs" />
    156155    <Compile Include="Properties\AssemblyInfo.cs" />
    157     <Compile Include="Views\ResultCollectionPostProcessorControl.cs">
    158       <SubType>UserControl</SubType>
    159     </Compile>
    160     <Compile Include="Views\ResultCollectionPostProcessorControl.Designer.cs">
    161       <DependentUpon>ResultCollectionPostProcessorControl.cs</DependentUpon>
    162     </Compile>
    163     <Compile Include="Views\ResultJsonItemControl.cs">
    164       <SubType>UserControl</SubType>
    165     </Compile>
    166     <Compile Include="Views\ResultJsonItemControl.Designer.cs">
    167       <DependentUpon>ResultJsonItemControl.cs</DependentUpon>
     156    <Compile Include="Views\RunCollectionModifierControl.cs">
     157      <SubType>UserControl</SubType>
     158    </Compile>
     159    <Compile Include="Views\RunCollectionModifierControl.Designer.cs">
     160      <DependentUpon>RunCollectionModifierControl.cs</DependentUpon>
    168161    </Compile>
    169162    <Compile Include="Views\ValueLookupJsonItemControl.cs">
     
    241234    <EmbeddedResource Include="Views\ExportJsonDialog.resx">
    242235      <DependentUpon>ExportJsonDialog.cs</DependentUpon>
    243     </EmbeddedResource>
    244     <EmbeddedResource Include="Views\ResultJsonItemControl.resx">
    245       <DependentUpon>ResultJsonItemControl.cs</DependentUpon>
    246236    </EmbeddedResource>
    247237    <EmbeddedResource Include="Views\ValueLookupJsonItemControl.resx">
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs

    r18055 r18059  
    3434      this.groupBoxDetails = new System.Windows.Forms.GroupBox();
    3535      this.panelParameterDetails = new System.Windows.Forms.Panel();
    36       this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    37       this.treeViewResults = new System.Windows.Forms.TreeView();
    38       this.groupBox = new System.Windows.Forms.GroupBox();
    39       this.panelResultDetails = new System.Windows.Forms.Panel();
    4036      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    4137      this.tabControl1 = new System.Windows.Forms.TabControl();
    4238      this.tabPage1 = new System.Windows.Forms.TabPage();
    4339      this.tabPage2 = new System.Windows.Forms.TabPage();
    44       this.tabPage3 = new System.Windows.Forms.TabPage();
    45       this.postProcessorListControl = new HeuristicLab.JsonInterface.OptimizerIntegration.ResultCollectionPostProcessorControl();
     40      this.postProcessorListControl = new HeuristicLab.JsonInterface.OptimizerIntegration.RunCollectionModifierControl();
    4641      this.label1 = new System.Windows.Forms.Label();
    4742      this.textBoxTemplateName = new System.Windows.Forms.TextBox();
     
    4944      this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
    5045      this.groupBoxDetails.SuspendLayout();
    51       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
    52       this.splitContainer1.Panel1.SuspendLayout();
    53       this.splitContainer1.Panel2.SuspendLayout();
    54       this.splitContainer1.SuspendLayout();
    55       this.groupBox.SuspendLayout();
    5646      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
    5747      this.splitContainer2.Panel1.SuspendLayout();
     
    6151      this.tabPage1.SuspendLayout();
    6252      this.tabPage2.SuspendLayout();
    63       this.tabPage3.SuspendLayout();
    6453      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6554      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit();
     
    113102      this.panelParameterDetails.TabIndex = 0;
    114103      //
    115       // splitContainer1
    116       //
    117       this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
    118       this.splitContainer1.Location = new System.Drawing.Point(3, 3);
    119       this.splitContainer1.Name = "splitContainer1";
    120       //
    121       // splitContainer1.Panel1
    122       //
    123       this.splitContainer1.Panel1.Controls.Add(this.treeViewResults);
    124       this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 1);
    125       //
    126       // splitContainer1.Panel2
    127       //
    128       this.splitContainer1.Panel2.Controls.Add(this.groupBox);
    129       this.splitContainer1.Size = new System.Drawing.Size(796, 499);
    130       this.splitContainer1.SplitterDistance = 380;
    131       this.splitContainer1.TabIndex = 7;
    132       //
    133       // treeViewResults
    134       //
    135       this.treeViewResults.CheckBoxes = true;
    136       this.treeViewResults.Dock = System.Windows.Forms.DockStyle.Fill;
    137       this.treeViewResults.Location = new System.Drawing.Point(0, 6);
    138       this.treeViewResults.Name = "treeViewResults";
    139       this.treeViewResults.Size = new System.Drawing.Size(380, 492);
    140       this.treeViewResults.TabIndex = 6;
    141       this.treeViewResults.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewResults_AfterCheck);
    142       this.treeViewResults.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewResults_AfterSelect);
    143       //
    144       // groupBox
    145       //
    146       this.groupBox.Controls.Add(this.panelResultDetails);
    147       this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    148       this.groupBox.Location = new System.Drawing.Point(0, 0);
    149       this.groupBox.Name = "groupBox";
    150       this.groupBox.Size = new System.Drawing.Size(412, 499);
    151       this.groupBox.TabIndex = 5;
    152       this.groupBox.TabStop = false;
    153       this.groupBox.Text = "Details";
    154       //
    155       // panelResultDetails
    156       //
    157       this.panelResultDetails.AutoScroll = true;
    158       this.panelResultDetails.Dock = System.Windows.Forms.DockStyle.Fill;
    159       this.panelResultDetails.Location = new System.Drawing.Point(3, 16);
    160       this.panelResultDetails.Name = "panelResultDetails";
    161       this.panelResultDetails.Size = new System.Drawing.Size(406, 480);
    162       this.panelResultDetails.TabIndex = 0;
    163       //
    164104      // splitContainer2
    165105      //
     
    187127      this.tabControl1.Controls.Add(this.tabPage1);
    188128      this.tabControl1.Controls.Add(this.tabPage2);
    189       this.tabControl1.Controls.Add(this.tabPage3);
    190129      this.tabControl1.Location = new System.Drawing.Point(12, 38);
    191130      this.tabControl1.Name = "tabControl1";
     
    207146      // tabPage2
    208147      //
    209       this.tabPage2.Controls.Add(this.splitContainer1);
     148      this.tabPage2.Controls.Add(this.postProcessorListControl);
    210149      this.tabPage2.Location = new System.Drawing.Point(4, 22);
    211150      this.tabPage2.Name = "tabPage2";
    212       this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
    213151      this.tabPage2.Size = new System.Drawing.Size(802, 505);
    214       this.tabPage2.TabIndex = 1;
    215       this.tabPage2.Text = "Results";
     152      this.tabPage2.TabIndex = 2;
     153      this.tabPage2.Text = "Result Collection Modifiers";
    216154      this.tabPage2.UseVisualStyleBackColor = true;
    217       //
    218       // tabPage3
    219       //
    220       this.tabPage3.Controls.Add(this.postProcessorListControl);
    221       this.tabPage3.Location = new System.Drawing.Point(4, 22);
    222       this.tabPage3.Name = "tabPage3";
    223       this.tabPage3.Size = new System.Drawing.Size(802, 505);
    224       this.tabPage3.TabIndex = 2;
    225       this.tabPage3.Text = "Result Collection Modifiers";
    226       this.tabPage3.UseVisualStyleBackColor = true;
    227155      //
    228156      // postProcessorListControl
     
    281209      this.Text = "Export Json";
    282210      this.groupBoxDetails.ResumeLayout(false);
    283       this.splitContainer1.Panel1.ResumeLayout(false);
    284       this.splitContainer1.Panel2.ResumeLayout(false);
    285       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
    286       this.splitContainer1.ResumeLayout(false);
    287       this.groupBox.ResumeLayout(false);
    288211      this.splitContainer2.Panel1.ResumeLayout(false);
    289212      this.splitContainer2.Panel2.ResumeLayout(false);
     
    293216      this.tabPage1.ResumeLayout(false);
    294217      this.tabPage2.ResumeLayout(false);
    295       this.tabPage3.ResumeLayout(false);
    296218      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    297219      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit();
     
    312234    private System.Windows.Forms.TabControl tabControl1;
    313235    private System.Windows.Forms.TabPage tabPage1;
    314     private System.Windows.Forms.TabPage tabPage2;
    315     private System.Windows.Forms.TreeView treeViewResults;
    316236    private System.Windows.Forms.Label label1;
    317237    private System.Windows.Forms.TextBox textBoxTemplateName;
    318238    private System.Windows.Forms.ErrorProvider errorProvider;
    319     private System.Windows.Forms.SplitContainer splitContainer1;
    320     private System.Windows.Forms.GroupBox groupBox;
    321     private System.Windows.Forms.Panel panelResultDetails;
    322     private System.Windows.Forms.TabPage tabPage3;
    323     private ResultCollectionPostProcessorControl postProcessorListControl;
     239    private System.Windows.Forms.TabPage tabPage2;
     240    private RunCollectionModifierControl postProcessorListControl;
    324241  }
    325242}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r18055 r18059  
    3030      set {
    3131        content = value;
    32         //CheckedItemListView
    3332        #region Clear
    3433        VMs = new List<IJsonItemVM>();
    3534        treeView.Nodes.Clear();
    36         treeViewResults.Nodes.Clear();
    3735        #endregion
    3836        Optimizer = content as IOptimizer;
     
    4644          treeView.ExpandAll();
    4745          panelParameterDetails.Controls.Clear();
    48           panelResultDetails.Controls.Clear();
    4946        }
    5047      }
     
    6158    public ExportJsonDialog() {
    6259      InitializeComponent();
    63       this.RunCollectionModifiers = this.postProcessorListControl.Content;
    64       this.Icon = HeuristicLab.Common.Resources.HeuristicLab.Icon;
     60      RunCollectionModifiers = postProcessorListControl.Content;
     61      Icon = Common.Resources.HeuristicLab.Icon;
    6562      InitCache();
    6663    }
     
    7471      if (FolderBrowserDialog.ShowDialog() == DialogResult.OK) {
    7572        try {
    76           //foreach(var x in PostProcessors.CheckedItems)
    77            
    7873          JsonTemplateGenerator.GenerateTemplate(
    7974            Path.Combine(FolderBrowserDialog.SelectedPath, textBoxTemplateName.Text),
     
    9287          if (IsDrawableItem(c)) {
    9388            TreeNode childNode = new TreeNode(c.Name);
    94             if (c is IResultJsonItem) {
    95               treeViewResults.Nodes.Add(childNode);
    96               IJsonItemVM vm = RegisterItem(childNode, c, treeViewResults);
    97               if (vm != null) vm.Selected = true;             
    98             } else {
    99               node.Nodes.Add(childNode);
    100               BuildTreeNode(childNode, c);
    101             }
     89            node.Nodes.Add(childNode);
     90            BuildTreeNode(childNode, c);
    10291          }
    10392        }
     
    128117    private bool IsDrawableItem(IJsonItem item) {
    129118      bool b = false;
    130       if (item.Children != null) {
    131         foreach (var c in item.Children) {
     119      if (item.Children != null)
     120        foreach (var c in item.Children)
    132121          b = b || IsDrawableItem(c);
    133         }
    134       }
    135122     
    136123      return b || !(item is EmptyJsonItem) || !(item is UnsupportedJsonItem);
     
    140127      if(Node2Control.TryGetValue(treeView.SelectedNode, out UserControl control)) {
    141128        SetControlOnPanel(control, panelParameterDetails);
    142       }
    143     }
    144 
    145     private void treeViewResults_AfterSelect(object sender, TreeViewEventArgs e) {
    146       if (Node2Control.TryGetValue(treeViewResults.SelectedNode, out UserControl control)) {
    147         SetControlOnPanel(control, panelResultDetails);
    148129      }
    149130    }
     
    171152
    172153    private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) {
    173       if (e.Action != TreeViewAction.Unknown) {
    174         if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) {
     154      if (e.Action != TreeViewAction.Unknown)
     155        if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm))
    175156          vm.Selected = e.Node.Checked;
    176         }
    177       }
    178157    }
    179158
    180159    private void treeViewResults_AfterCheck(object sender, TreeViewEventArgs e) {
    181       if (e.Action != TreeViewAction.Unknown) {
    182         if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) {
     160      if (e.Action != TreeViewAction.Unknown)
     161        if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm))
    183162          vm.Selected = e.Node.Checked;
    184         }
    185       }
    186163    }
    187164  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/RunCollectionModifierControl.Designer.cs

    r18058 r18059  
    11
    22namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    3   partial class ResultCollectionPostProcessorControl {
     3  partial class RunCollectionModifierControl {
    44    /// <summary>
    55    /// Erforderliche Designervariable.
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/RunCollectionModifierControl.cs

    r18058 r18059  
    1212
    1313namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    14   public partial class ResultCollectionPostProcessorControl : Core.Views.CheckedItemListView<IRunCollectionModifier> {
    15     public ResultCollectionPostProcessorControl() {
     14  public partial class RunCollectionModifierControl : Core.Views.CheckedItemListView<IRunCollectionModifier> {
     15    public RunCollectionModifierControl() {
    1616      InitializeComponent();
    1717    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Constants.cs

    r18056 r18059  
    1010    internal const string OptimizerDescription = "OptimizerDescription";
    1111    internal const string Parameters = "Parameters";
    12     internal const string Results = "Results";
    1312    internal const string RunCollectionModifiers = "RunCollectionModifiers";
    1413
     
    2019      },
    2120      '" + Parameters + @"': [],
    22       '" + Results + @"': [],
    2321      '" + RunCollectionModifiers + @"': []
    2422    }";
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs

    r18043 r18059  
    2424      IJsonItem item = base.Extract(value, root);
    2525      IAlgorithm algorithm = value as IAlgorithm;
    26       foreach (var res in algorithm.Results) {
    27         var resultItem = root.Extract(res, root);
    28         // fetch all result parameter items
    29         var resultParameterItems =
    30           item.Where(x => x
    31           .GetType()
    32           .GetInterfaces()
    33           .Any(y => y == typeof(IResultJsonItem)));
    34         // check for duplicates (to prevent double result items,
    35         // which can occur with result parameters)
    36         if(!resultParameterItems.Any(x => x.Name == resultItem.Name))
    37           item.AddChildren(resultItem);
    38       }
    3926      item.AddChildren(root.Extract(algorithm.Problem, root));
    4027      return item;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs

    r18043 r18059  
    66  {
    77    public abstract int Priority { get; }
    8 
    98    public abstract bool CanConvertType(Type t);
    10 
    119    public abstract void Inject(IItem item, IJsonItem data, IJsonItemConverter root);
    1210    public abstract IJsonItem Extract(IItem value, IJsonItemConverter root);
    13 
    1411
    1512    #region Helper
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs

    r17843 r18059  
    1212
    1313    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
    14       IResultParameter res = value as IResultParameter;
    15       var formatter = ResultFormatter.ForType(res.DataType).Last();
    16       return new ResultJsonItem() {
    17         Name = res.ActualName,
    18         Description = res.Description,
    19         ResultFormatterType = formatter.GetType().FullName,
    20         ValueType = res.DataType
    21       };
     14      return new UnsupportedJsonItem();
    2215    }
    2316
    24     public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    25       IResultParameter res = item as IResultParameter;
    26       res.ActualName = data.Name;
    27     }
     17    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {}
    2818  }
    2919}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj

    r18055 r18059  
    6868    <Compile Include="Converters\ItemCollectionConverter.cs" />
    6969    <Compile Include="Converters\RegressionProblemDataConverter.cs" />
    70     <Compile Include="Converters\ResultConverter.cs" />
    7170    <Compile Include="Converters\ResultParameterConverter.cs" />
    7271    <Compile Include="Converters\ValueLookupParameterConverter.cs" />
     
    8079    <Compile Include="Interfaces\IMatrixJsonItem.cs" />
    8180    <Compile Include="Interfaces\IRangedJsonItem.cs" />
    82     <Compile Include="Interfaces\IResultFormatter.cs" />
    83     <Compile Include="Interfaces\IResultJsonItem.cs" />
    8481    <Compile Include="Interfaces\IValueJsonItem.cs" />
    8582    <Compile Include="Interfaces\IValueLookupJsonItem.cs" />
     
    10299    <Compile Include="JsonItems\MatrixJsonItem.cs" />
    103100    <Compile Include="JsonItems\RangedJsonItem.cs" />
    104     <Compile Include="JsonItems\ResultJsonItem.cs" />
    105101    <Compile Include="JsonItems\StringJsonItem.cs" />
    106102    <Compile Include="JsonItems\UnsupportedJsonItem.cs" />
     
    112108    <Compile Include="ResultCollectionProcessors\RunCollectionSRSolutionLatexFormatter.cs" />
    113109    <Compile Include="ResultCollectionProcessors\RunCollectionSRSolutionPythonFormatter.cs" />
    114     <Compile Include="ResultFormatters\MatlabResultFormatter.cs" />
    115     <Compile Include="ResultFormatters\PythonResultFormatter.cs" />
    116     <Compile Include="ResultFormatters\ResultFormatter.cs" />
    117     <Compile Include="ResultFormatters\StringResultFormatter.cs" />
    118     <Compile Include="ResultFormatters\SymbolicRegressionSolutionFormatterBase.cs" />
    119110    <Compile Include="SingleLineArrayJsonWriter.cs" />
    120111    <Compile Include="JsonTemplateGenerator.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateGenerator.cs

    r18056 r18059  
    5353      #region Filter Items
    5454      foreach (var item in jsonItems) {
    55         if (item is IResultJsonItem)
    56           resultItems.Add(item.GenerateJObject());
    57         else
    58           parameterItems.Add(item.GenerateJObject());
     55        parameterItems.Add(item.GenerateJObject());
    5956      }
    6057      #endregion
    6158
    6259      #region RunCollectionModifiers Serialization
    63       foreach (var proc in runCollectionModifiers) {
    64         JArray rcpParameterItems = new JArray();
    65         var guid = StorableTypeAttribute.GetStorableTypeAttribute(proc.GetType()).Guid.ToString();
    66         var item = JsonItemConverter.Extract(proc);
     60      foreach (var rcModifier in runCollectionModifiers) {
     61        JArray rcModifierParameterItems = new JArray();
     62        var guid = StorableTypeAttribute.GetStorableTypeAttribute(rcModifier.GetType()).Guid.ToString();
     63        var item = JsonItemConverter.Extract(rcModifier);
    6764
    68         var rcpItems = item
     65        var rcModifierItems = item
    6966          .Where(x => !(x is EmptyJsonItem) && !(x is UnsupportedJsonItem))
    7067          .Select(x => x.GenerateJObject());
    7168
    72         foreach (var i in rcpItems)
    73           rcpParameterItems.Add(i);
     69        foreach (var i in rcModifierItems)
     70          rcModifierParameterItems.Add(i);
    7471
    75         JObject processorObj = new JObject();
    76         processorObj.Add(nameof(IJsonItem.Name), item.Name);
    77         processorObj.Add("GUID", guid);
    78         processorObj.Add(Constants.Parameters, rcpParameterItems);
    79         runCollectionModifierItems.Add(processorObj);
     72        JObject rcModifierObj = new JObject();
     73        rcModifierObj.Add(nameof(IJsonItem.Name), item.Name);
     74        rcModifierObj.Add("GUID", guid);
     75        rcModifierObj.Add(Constants.Parameters, rcModifierParameterItems);
     76        runCollectionModifierItems.Add(rcModifierObj);
    8077      }
    8178      #endregion
     
    8683      template[Constants.Metadata][Constants.OptimizerDescription] = optimizer.Description;
    8784      template[Constants.Parameters] = parameterItems;
    88       template[Constants.Results] = resultItems;
    8985      template[Constants.RunCollectionModifiers] = runCollectionModifierItems;
    9086      #endregion
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs

    r18055 r18059  
    1111namespace HeuristicLab.JsonInterface {
    1212  public readonly struct InstantiatorResult {
    13     public InstantiatorResult(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems) {
     13
     14    public InstantiatorResult(IOptimizer optimizer, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    1415      Optimizer = optimizer;
    15       ConfiguredResultItems = configuredResultItems;
    16       RunCollectionModifiers = Enumerable.Empty<IRunCollectionModifier>();
    17     }
    18 
    19     public InstantiatorResult(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems, IEnumerable<IRunCollectionModifier> runCollectionModifiers) {
    20       Optimizer = optimizer;
    21       ConfiguredResultItems = configuredResultItems;
    2216      RunCollectionModifiers = runCollectionModifiers;
    2317    }
    2418
    2519    public IOptimizer Optimizer { get; }
    26     public IEnumerable<IResultJsonItem> ConfiguredResultItems { get; }
    2720    public IEnumerable<IRunCollectionModifier> RunCollectionModifiers { get; }
    2821  }
     
    7568      ProtoBufSerializer serializer = new ProtoBufSerializer();
    7669      IOptimizer optimizer = (IOptimizer)serializer.Deserialize(hLFileLocation);
     70      optimizer.Prepare(true);
    7771      #endregion
    7872
     
    9488      JsonItemConverter.Inject(optimizer, rootItem);
    9589
    96       return new InstantiatorResult(optimizer, CollectResults(), CollectRunCollectionModifiers());
     90      return new InstantiatorResult(optimizer, CollectRunCollectionModifiers());
    9791    }
    9892
     
    10296    private IEnumerable<IRunCollectionModifier> CollectRunCollectionModifiers() {
    10397      IList<IRunCollectionModifier> runCollectionModifiers = new List<IRunCollectionModifier>();
     98
     99      if (Template is JObject o && !o.ContainsKey(Constants.RunCollectionModifiers))
     100        return Enumerable.Empty<IRunCollectionModifier>();
     101
    104102      foreach (JObject obj in Template[Constants.RunCollectionModifiers]) {
    105103        var guid = obj["GUID"].ToString();
    106104        var parameters = obj[Constants.Parameters];
    107105        var type = Mapper.StaticCache.GetType(new Guid(guid));
    108         var rcp = (IRunCollectionModifier)Activator.CreateInstance(type);
    109         var rcpItem = JsonItemConverter.Extract(rcp);
     106        var rcModifier = (IRunCollectionModifier)Activator.CreateInstance(type);
     107        var rcModifierItem = JsonItemConverter.Extract(rcModifier);
    110108
    111109        foreach (JObject param in parameters) {
    112110          var path = param[nameof(IJsonItem.Path)].ToString();
    113           foreach (var item in rcpItem)
     111          foreach (var item in rcModifierItem)
    114112            if (item.Path == path)
    115113              item.SetJObject(param);
    116114        }
    117115
    118         JsonItemConverter.Inject(rcp, rcpItem);
    119         runCollectionModifiers.Add(rcp);
     116        JsonItemConverter.Inject(rcModifier, rcModifierItem);
     117        runCollectionModifiers.Add(rcModifier);
    120118      }
    121119      return runCollectionModifiers;
    122     }
    123 
    124     private IEnumerable<IResultJsonItem> CollectResults() {
    125       IList<IResultJsonItem> res = new List<IResultJsonItem>();
    126       foreach(JObject obj in Template[Constants.Results]) {
    127         var resultItem = new ResultJsonItem();
    128         resultItem.SetJObject(obj);
    129         res.Add(resultItem);
    130       }
    131       return res;
    132120    }
    133121
Note: See TracChangeset for help on using the changeset viewer.