Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/HeuristicLab.JsonInterface.App.csproj
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/HeuristicLab.JsonInterface.App.csproj (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/HeuristicLab.JsonInterface.App.csproj (revision 17834)
@@ -102,9 +102,4 @@
False
-
- {06D4A186-9319-48A0-BADE-A2058D462EEA}
- HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4
- False
-
{0e3aab5e-f152-44e0-a054-4d9a83ecee08}
@@ -125,19 +120,4 @@
{94186a6a-5176-4402-ae83-886557b53cca}
HeuristicLab.PluginInfrastructure-3.3
- False
-
-
- {5AC82412-911B-4FA2-A013-EDC5E3F3FCC2}
- HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4
- False
-
-
- {3d28463f-ec96-4d82-afee-38be91a0ca00}
- HeuristicLab.Problems.DataAnalysis.Symbolic-3.4
- False
-
-
- {DF87C13E-A889-46FF-8153-66DCAA8C5674}
- HeuristicLab.Problems.DataAnalysis-3.4
False
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs (revision 17834)
@@ -3,12 +3,7 @@
using System.IO;
using System.Linq;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using HeuristicLab.Optimization;
-using HeuristicLab.ParallelEngine;
-using HeuristicLab.Problems.DataAnalysis.Symbolic;
-using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
-using HeuristicLab.SequentialEngine;
using Newtonsoft.Json.Linq;
@@ -42,7 +37,13 @@
File.WriteAllText(file, FetchResults(optimizer, configuredResultItem));
- private static string FetchResults(IOptimizer optimizer, IEnumerable configuredResultItem) {
+ private static IEnumerable ResultFormatter { get; } =
+ PluginInfrastructure.ApplicationManager.Manager.GetInstances();
+
+ private static IResultFormatter GetResultFormatter(string fullName) =>
+ ResultFormatter?.Where(x => x.GetType().FullName == fullName).Last();
+
+ private static string FetchResults(IOptimizer optimizer, IEnumerable configuredResultItems) {
JArray arr = new JArray();
- IEnumerable configuredResults = configuredResultItem.Select(x => x.Name);
+ IEnumerable configuredResults = configuredResultItems.Select(x => x.Name);
foreach (var run in optimizer.Runs) {
@@ -51,21 +52,13 @@
obj.Add("Run", JToken.FromObject(run.ToString()));
- // add empty values for configured results
- var emptyToken = JToken.FromObject("");
- foreach (var cr in configuredResults) {
- obj.Add(cr, emptyToken);
- }
+ // zip and filter the results with the ResultJsonItems
+ var filteredResults = configuredResultItems.Zip(
+ run.Results.Where(x => configuredResultItems.Any(y => y.Name == x.Key)),
+ (x, y) => new { Item = x, Value = y.Value });
- // change empty values with calculated values
- var formatter = new SymbolicDataAnalysisExpressionMATLABFormatter();
- foreach (var res in run.Results) {
- if(obj.ContainsKey(res.Key)) {
- if (res.Value is ISymbolicRegressionSolution solution) {
- var formattedModel = formatter.Format(solution.Model.SymbolicExpressionTree);
- obj[res.Key] = JToken.FromObject(formattedModel);
- } else {
- obj[res.Key] = JToken.FromObject(res.Value.ToString());
- }
- }
+ // add results to the JObject
+ foreach(var result in filteredResults) {
+ var formatter = GetResultFormatter(result.Item.ResultFormatterType);
+ obj.Add(result.Item.Name, formatter.Format(result.Value));
}
}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj (revision 17834)
@@ -155,4 +155,10 @@
+
+ UserControl
+
+
+ ResultJsonItemControl.cs
+
UserControl
@@ -229,4 +235,7 @@
ExportJsonDialog.cs
+
+
+ ResultJsonItemControl.cs
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs (revision 17834)
@@ -9,6 +9,13 @@
public class ResultItemVM : JsonItemVMBase {
public override Type TargetedJsonItemType => typeof(ResultJsonItem);
- public override UserControl Control =>
- new JsonItemBaseControl(this);
+ public override UserControl Control => ResultJsonItemControl.Create(this);
+
+ public string ResultFormatterType {
+ get => Item.ResultFormatterType;
+ set {
+ Item.ResultFormatterType = value;
+ OnPropertyChange(this, nameof(ResultFormatterType));
+ }
+ }
}
}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.Designer.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.Designer.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.Designer.cs (revision 17834)
@@ -0,0 +1,89 @@
+
+namespace HeuristicLab.JsonInterface.OptimizerIntegration {
+ partial class ResultJsonItemControl {
+ ///
+ /// Erforderliche Designervariable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Verwendete Ressourcen bereinigen.
+ ///
+ /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Vom Komponenten-Designer generierter Code
+
+ ///
+ /// Erforderliche Methode für die Designerunterstützung.
+ /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
+ ///
+ private void InitializeComponent() {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.comboBoxFormatter = new System.Windows.Forms.ComboBox();
+ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+ this.groupBox1.SuspendLayout();
+ this.tableLayoutPanel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.comboBoxFormatter);
+ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.groupBox1.Location = new System.Drawing.Point(0, 0);
+ this.groupBox1.Margin = new System.Windows.Forms.Padding(0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(526, 41);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Formatter";
+ //
+ // comboBoxFormatter
+ //
+ this.comboBoxFormatter.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.comboBoxFormatter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxFormatter.FormattingEnabled = true;
+ this.comboBoxFormatter.Location = new System.Drawing.Point(3, 16);
+ this.comboBoxFormatter.Name = "comboBoxFormatter";
+ this.comboBoxFormatter.Size = new System.Drawing.Size(520, 21);
+ this.comboBoxFormatter.TabIndex = 0;
+ //
+ // tableLayoutPanel1
+ //
+ this.tableLayoutPanel1.ColumnCount = 1;
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0);
+ this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
+ this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+ this.tableLayoutPanel1.RowCount = 2;
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 41F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(526, 41);
+ this.tableLayoutPanel1.TabIndex = 1;
+ //
+ // ResultJsonItemControl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.tableLayoutPanel1);
+ this.Name = "ResultJsonItemControl";
+ this.Size = new System.Drawing.Size(526, 41);
+ this.groupBox1.ResumeLayout(false);
+ this.tableLayoutPanel1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.ComboBox comboBoxFormatter;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+ }
+}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.cs (revision 17834)
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HeuristicLab.JsonInterface.OptimizerIntegration {
+ public partial class ResultJsonItemControl : UserControl {
+ public ResultJsonItemControl() {
+ InitializeComponent();
+ }
+
+ public static ResultJsonItemControl Create(ResultItemVM vm) {
+ var control = new ResultJsonItemControl();
+ var formatters = ResultFormatter.ForType(vm.Item.ValueType).ToList();
+ control.comboBoxFormatter.DataSource = formatters;
+ control.comboBoxFormatter.DisplayMember = "Name";
+
+ // set action to override the ResultFormatterType property for changing the selected value
+ control.comboBoxFormatter.SelectedValueChanged += (s, e) => vm.ResultFormatterType = control.comboBoxFormatter.SelectedValue.GetType().FullName;
+ control.comboBoxFormatter.SelectedItem = formatters.Last();
+
+ return control;
+ }
+ }
+}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.resx
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.resx (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.resx (revision 17834)
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs (revision 17834)
@@ -30,8 +30,10 @@
IAlgorithm algorithm = value as IAlgorithm;
foreach (var res in algorithm.Results) {
+ item.AddChildren(root.Extract(res, root));
+ /*
item.AddChildren(new ResultJsonItem() {
Name = res.Name,
Description = res.Description
- });
+ });*/
}
item.AddChildren(root.Extract(algorithm.Problem, root));
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs (revision 17834)
@@ -20,6 +20,6 @@
public abstract IJsonItem Extract(IItem value, IJsonItemConverter root);
+
#region Helper
-
protected IItem Instantiate(Type type, params object[] args) =>
(IItem)Activator.CreateInstance(type,args);
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs (revision 17834)
@@ -66,10 +66,10 @@
// check data
- if(!dataset.RowNames.Any(x => x == targetVariable.Value)) {
+ if(!dataset.ColumnNames.Any(x => x == targetVariable.Value)) {
throw new Exception($"The value of the target variable ('{targetVariable.Value}') has no matching row name value of the dataset.");
}
foreach(var v in allowedInputVariables.Value) {
- if(!dataset.RowNames.Any(x => x == v))
+ if(!dataset.ColumnNames.Any(x => x == v))
throw new Exception($"The value of the input variable ('{v}') has no matching row name value of the dataset.");
}
@@ -106,5 +106,5 @@
var dictTmp = new Dictionary();
int c = 0;
- foreach (var col in item.RowNames) {
+ foreach (var col in item.ColumnNames) {
dictTmp.Add(col, new List(item.Value[c]));
++c;
@@ -116,5 +116,5 @@
var variableNames = dataset.GetType().GetField(VariableNames, flags);
- variableNames.SetValue(dataset, item.RowNames);
+ variableNames.SetValue(dataset, item.ColumnNames);
var dataInfo = dataset.GetType().GetField(VariableValues, flags);
@@ -162,5 +162,5 @@
// add list items and set their check state (based on allowed input variables)
- foreach(var i in matrix.RowNames) {
+ foreach(var i in matrix.ColumnNames) {
bool isChecked = false;
foreach(var x in item.Value)
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultConverter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultConverter.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultConverter.cs (revision 17834)
@@ -0,0 +1,31 @@
+using System;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab.JsonInterface {
+ public class ResultConverter : BaseConverter {
+ public override int Priority => 1;
+
+ public override Type ConvertableType => typeof(IResult);
+
+ public override bool CanConvertType(Type t) =>
+ t.GetInterfaces().Any(x => x == ConvertableType);
+
+ public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
+ IResult res = value as IResult;
+ var formatter = ResultFormatter.ForType(res.Value.GetType()).Last();
+ return new ResultJsonItem() {
+ Name = res.Name,
+ Description = res.Description,
+ ResultFormatterType = formatter.GetType().FullName,
+ ValueType = res.DataType
+ };
+ }
+
+ public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
+ IResult res = item as IResult;
+ res.Name = data.Name;
+ }
+ }
+}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs (revision 17834)
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using HeuristicLab.Core;
using HeuristicLab.Optimization;
@@ -14,11 +11,14 @@
public override bool CanConvertType(Type t) =>
- t.GetInterfaces().Any(x => x == typeof(IResultParameter));
+ t.GetInterfaces().Any(x => x == ConvertableType);
public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
IResultParameter res = value as IResultParameter;
+ var formatter = ResultFormatter.ForType(res.DataType).Last();
return new ResultJsonItem() {
Name = res.ActualName,
- Description = res.Description
+ Description = res.Description,
+ ResultFormatterType = formatter.GetType().FullName,
+ ValueType = res.DataType
};
}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj (revision 17834)
@@ -66,5 +66,7 @@
+
+
@@ -77,4 +79,5 @@
+
@@ -100,4 +103,7 @@
+
+
+
@@ -142,4 +148,8 @@
HeuristicLab.Data-3.3
+
+ {06d4a186-9319-48a0-bade-a2058d462eea}
+ HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4
+
{14ab8d24-25bc-400c-a846-4627aa945192}
@@ -153,4 +163,12 @@
{94186a6a-5176-4402-ae83-886557b53cca}
HeuristicLab.PluginInfrastructure-3.3
+
+
+ {5ac82412-911b-4fa2-a013-edc5e3f3fcc2}
+ HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4
+
+
+ {3d28463f-ec96-4d82-afee-38be91a0ca00}
+ HeuristicLab.Problems.DataAnalysis.Symbolic-3.4
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultFormatter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultFormatter.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultFormatter.cs (revision 17834)
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HeuristicLab.JsonInterface {
+ public interface IResultFormatter {
+ int Priority { get; }
+
+ bool CanFormatType(Type t);
+
+ string Format(object o);
+ }
+}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultJsonItem.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultJsonItem.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultJsonItem.cs (revision 17834)
@@ -1,7 +1,21 @@
-namespace HeuristicLab.JsonInterface {
+using System;
+using Newtonsoft.Json;
+
+namespace HeuristicLab.JsonInterface {
///
- /// Empty JsonItem, which indicates a result. For example 'BestQuality'.
+ /// JsonItem, which indicates a result. For example 'BestQuality'.
/// Types of this JsonItems are stored in the result section of the template.
///
- public interface IResultJsonItem : IJsonItem { }
+ public interface IResultJsonItem : IJsonItem {
+ ///
+ /// the result formatter type's fullname
+ ///
+ string ResultFormatterType { get; set; }
+
+ ///
+ /// the type of the result value
+ ///
+ [JsonIgnore]
+ Type ValueType { get; set; }
+ }
}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/JsonItem.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/JsonItem.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/JsonItem.cs (revision 17834)
@@ -125,5 +125,8 @@
});
- public virtual void SetJObject(JObject jObject) { }
+ public virtual void SetJObject(JObject jObject) {
+ Name = (jObject[nameof(IJsonItem.Name)]?.ToObject());
+ Description = (jObject[nameof(IJsonItem.Description)]?.ToObject());
+ }
#endregion
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ResultJsonItem.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ResultJsonItem.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ResultJsonItem.cs (revision 17834)
@@ -1,7 +1,20 @@
-namespace HeuristicLab.JsonInterface {
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json.Linq;
+
+namespace HeuristicLab.JsonInterface {
public class ResultJsonItem : JsonItem, IResultJsonItem {
+ public string ResultFormatterType { get; set; }
+
+ public Type ValueType { get; set; }
+
protected override ValidationResult Validate() => ValidationResult.Successful();
- public string Converter { get; set; }
+ public override void SetJObject(JObject jObject) {
+ base.SetJObject(jObject);
+ ResultFormatterType = (jObject[nameof(IResultJsonItem.ResultFormatterType)]?.ToObject());
+ }
+
}
}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs (revision 17834)
@@ -81,6 +81,9 @@
IList res = new List();
foreach(JObject obj in Template[Constants.Results]) {
- string name = obj.Property("Name").Value.ToString();
- res.Add(new ResultJsonItem() { Name = name });
+ //string name = obj.Property("Name").Value.ToString();
+ var resultItem = new ResultJsonItem();
+ resultItem.SetJObject(obj);
+ res.Add(resultItem);
+ //res.Add(new ResultJsonItem() { Name = name });
}
return res;
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Plugin.cs.frame
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Plugin.cs.frame (revision 17833)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Plugin.cs.frame (revision 17834)
@@ -34,4 +34,9 @@
[PluginDependency("HeuristicLab.Parameters", "3.3")]
[PluginDependency("HeuristicLab.SequentialEngine", "3.3")]
+ [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
+ [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
+ [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
+ [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
+ [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")]
public class HeuristicLabJsonInterfacePlugin : PluginBase {
}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/MatlabResultFormatter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/MatlabResultFormatter.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/MatlabResultFormatter.cs (revision 17834)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
+
+namespace HeuristicLab.JsonInterface {
+ public class MatlabResultFormatter : ResultFormatter {
+ public override int Priority => 5;
+
+ public override bool CanFormatType(Type t) {
+ var interfaces = t.GetInterfaces();
+ return t.GetInterfaces().Any(x => x == typeof(ISymbolicRegressionSolution));
+ }
+
+ private ISymbolicExpressionTreeStringFormatter MatlabFormatter => new SymbolicDataAnalysisExpressionMATLABFormatter();
+
+ public override string Format(object o) => MatlabFormatter.Format((ISymbolicExpressionTree)((ISymbolicRegressionSolution)o).Model.SymbolicExpressionTree);
+ }
+}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/ResultFormatter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/ResultFormatter.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/ResultFormatter.cs (revision 17834)
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HeuristicLab.JsonInterface {
+
+ ///
+ /// Base Class for ResultFormatter
+ ///
+ public abstract class ResultFormatter : IResultFormatter {
+ public abstract int Priority { get; }
+
+ public abstract bool CanFormatType(Type t);
+ public abstract string Format(object o);
+
+ ///
+ /// static property to get all existing result formatters
+ ///
+ public static IEnumerable All { get; } =
+ PluginInfrastructure.ApplicationManager.Manager.GetInstances();
+
+ ///
+ /// static method to get all existing result formatters for a specific type
+ ///
+ /// target type
+ /// collection of found result formatters or null if none was found
+ public static IEnumerable ForType(Type t) =>
+ All?.Where(x => x.CanFormatType(t)).OrderBy(x => x.Priority);
+ }
+}
Index: /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/StringResultFormatter.cs
===================================================================
--- /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/StringResultFormatter.cs (revision 17834)
+++ /branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatter/StringResultFormatter.cs (revision 17834)
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HeuristicLab.JsonInterface {
+ public class StringResultFormatter : ResultFormatter {
+ public override int Priority => 1;
+
+ public override bool CanFormatType(Type t) => true;
+
+ public override string Format(object o) => o.ToString();
+ }
+}