- Timestamp:
- 02/12/21 15:24:18 (4 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 9 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/HeuristicLab.JsonInterface.App.csproj
r17599 r17834 102 102 <Private>False</Private> 103 103 </ProjectReference> 104 <ProjectReference Include="..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">105 <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>106 <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>107 <Private>False</Private>108 </ProjectReference>109 104 <ProjectReference Include="..\HeuristicLab.JsonInterface\HeuristicLab.JsonInterface.csproj"> 110 105 <Project>{0e3aab5e-f152-44e0-a054-4d9a83ecee08}</Project> … … 125 120 <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project> 126 121 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 127 <Private>False</Private>128 </ProjectReference>129 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj">130 <Project>{5AC82412-911B-4FA2-A013-EDC5E3F3FCC2}</Project>131 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name>132 <Private>False</Private>133 </ProjectReference>134 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">135 <Project>{3d28463f-ec96-4d82-afee-38be91a0ca00}</Project>136 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>137 <Private>False</Private>138 </ProjectReference>139 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">140 <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>141 <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>142 122 <Private>False</Private> 143 123 </ProjectReference> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
r17828 r17834 3 3 using System.IO; 4 4 using System.Linq; 5 using System.Text;6 5 using System.Threading; 7 6 using System.Threading.Tasks; 8 7 using HeuristicLab.Optimization; 9 using HeuristicLab.ParallelEngine;10 using HeuristicLab.Problems.DataAnalysis.Symbolic;11 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;12 using HeuristicLab.SequentialEngine;13 8 using Newtonsoft.Json.Linq; 14 9 … … 42 37 File.WriteAllText(file, FetchResults(optimizer, configuredResultItem)); 43 38 44 private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItem) { 39 private static IEnumerable<IResultFormatter> ResultFormatter { get; } = 40 PluginInfrastructure.ApplicationManager.Manager.GetInstances<IResultFormatter>(); 41 42 private static IResultFormatter GetResultFormatter(string fullName) => 43 ResultFormatter?.Where(x => x.GetType().FullName == fullName).Last(); 44 45 private static string FetchResults(IOptimizer optimizer, IEnumerable<IResultJsonItem> configuredResultItems) { 45 46 JArray arr = new JArray(); 46 IEnumerable<string> configuredResults = configuredResultItem .Select(x => x.Name);47 IEnumerable<string> configuredResults = configuredResultItems.Select(x => x.Name); 47 48 48 49 foreach (var run in optimizer.Runs) { … … 51 52 obj.Add("Run", JToken.FromObject(run.ToString())); 52 53 53 // add empty values for configured results 54 var emptyToken = JToken.FromObject(""); 55 foreach (var cr in configuredResults) { 56 obj.Add(cr, emptyToken); 57 } 54 // zip and filter the results with the ResultJsonItems 55 var filteredResults = configuredResultItems.Zip( 56 run.Results.Where(x => configuredResultItems.Any(y => y.Name == x.Key)), 57 (x, y) => new { Item = x, Value = y.Value }); 58 58 59 // change empty values with calculated values 60 var formatter = new SymbolicDataAnalysisExpressionMATLABFormatter(); 61 foreach (var res in run.Results) { 62 if(obj.ContainsKey(res.Key)) { 63 if (res.Value is ISymbolicRegressionSolution solution) { 64 var formattedModel = formatter.Format(solution.Model.SymbolicExpressionTree); 65 obj[res.Key] = JToken.FromObject(formattedModel); 66 } else { 67 obj[res.Key] = JToken.FromObject(res.Value.ToString()); 68 } 69 } 59 // add results to the JObject 60 foreach(var result in filteredResults) { 61 var formatter = GetResultFormatter(result.Item.ResultFormatterType); 62 obj.Add(result.Item.Name, formatter.Format(result.Value)); 70 63 } 71 64 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj
r17829 r17834 155 155 <Compile Include="Plugin.cs" /> 156 156 <Compile Include="Properties\AssemblyInfo.cs" /> 157 <Compile Include="Views\ResultJsonItemControl.cs"> 158 <SubType>UserControl</SubType> 159 </Compile> 160 <Compile Include="Views\ResultJsonItemControl.Designer.cs"> 161 <DependentUpon>ResultJsonItemControl.cs</DependentUpon> 162 </Compile> 157 163 <Compile Include="Views\ValueLookupJsonItemControl.cs"> 158 164 <SubType>UserControl</SubType> … … 229 235 <EmbeddedResource Include="Views\ExportJsonDialog.resx"> 230 236 <DependentUpon>ExportJsonDialog.cs</DependentUpon> 237 </EmbeddedResource> 238 <EmbeddedResource Include="Views\ResultJsonItemControl.resx"> 239 <DependentUpon>ResultJsonItemControl.cs</DependentUpon> 231 240 </EmbeddedResource> 232 241 <EmbeddedResource Include="Views\ValueLookupJsonItemControl.resx"> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs
r17473 r17834 9 9 public class ResultItemVM : JsonItemVMBase<ResultJsonItem> { 10 10 public override Type TargetedJsonItemType => typeof(ResultJsonItem); 11 public override UserControl Control => 12 new JsonItemBaseControl(this); 11 public override UserControl Control => ResultJsonItemControl.Create(this); 12 13 public string ResultFormatterType { 14 get => Item.ResultFormatterType; 15 set { 16 Item.ResultFormatterType = value; 17 OnPropertyChange(this, nameof(ResultFormatterType)); 18 } 19 } 13 20 } 14 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs
r17828 r17834 30 30 IAlgorithm algorithm = value as IAlgorithm; 31 31 foreach (var res in algorithm.Results) { 32 item.AddChildren(root.Extract(res, root)); 33 /* 32 34 item.AddChildren(new ResultJsonItem() { 33 35 Name = res.Name, 34 36 Description = res.Description 35 }); 37 });*/ 36 38 } 37 39 item.AddChildren(root.Extract(algorithm.Problem, root)); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs
r17828 r17834 20 20 public abstract IJsonItem Extract(IItem value, IJsonItemConverter root); 21 21 22 22 23 #region Helper 23 24 24 protected IItem Instantiate(Type type, params object[] args) => 25 25 (IItem)Activator.CreateInstance(type,args); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17828 r17834 66 66 67 67 // check data 68 if(!dataset. RowNames.Any(x => x == targetVariable.Value)) {68 if(!dataset.ColumnNames.Any(x => x == targetVariable.Value)) { 69 69 throw new Exception($"The value of the target variable ('{targetVariable.Value}') has no matching row name value of the dataset."); 70 70 } 71 71 72 72 foreach(var v in allowedInputVariables.Value) { 73 if(!dataset. RowNames.Any(x => x == v))73 if(!dataset.ColumnNames.Any(x => x == v)) 74 74 throw new Exception($"The value of the input variable ('{v}') has no matching row name value of the dataset."); 75 75 } … … 106 106 var dictTmp = new Dictionary<string, IList>(); 107 107 int c = 0; 108 foreach (var col in item. RowNames) {108 foreach (var col in item.ColumnNames) { 109 109 dictTmp.Add(col, new List<double>(item.Value[c])); 110 110 ++c; … … 116 116 117 117 var variableNames = dataset.GetType().GetField(VariableNames, flags); 118 variableNames.SetValue(dataset, item. RowNames);118 variableNames.SetValue(dataset, item.ColumnNames); 119 119 120 120 var dataInfo = dataset.GetType().GetField(VariableValues, flags); … … 162 162 163 163 // add list items and set their check state (based on allowed input variables) 164 foreach(var i in matrix. RowNames) {164 foreach(var i in matrix.ColumnNames) { 165 165 bool isChecked = false; 166 166 foreach(var x in item.Value) -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs
r17828 r17834 1 1 using System; 2 using System.Collections.Generic;3 2 using System.Linq; 4 using System.Text;5 using System.Threading.Tasks;6 3 using HeuristicLab.Core; 7 4 using HeuristicLab.Optimization; … … 14 11 15 12 public override bool CanConvertType(Type t) => 16 t.GetInterfaces().Any(x => x == typeof(IResultParameter));13 t.GetInterfaces().Any(x => x == ConvertableType); 17 14 18 15 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { 19 16 IResultParameter res = value as IResultParameter; 17 var formatter = ResultFormatter.ForType(res.DataType).Last(); 20 18 return new ResultJsonItem() { 21 19 Name = res.ActualName, 22 Description = res.Description 20 Description = res.Description, 21 ResultFormatterType = formatter.GetType().FullName, 22 ValueType = res.DataType 23 23 }; 24 24 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r17829 r17834 66 66 <Compile Include="Converters\ExperimentConverter.cs" /> 67 67 <Compile Include="Converters\RegressionProblemDataConverter.cs" /> 68 <Compile Include="Converters\ResultConverter.cs" /> 68 69 <Compile Include="Converters\ResultParameterConverter.cs" /> 70 <Compile Include="Converters\SymbolicRegressionSolutionConverter.cs" /> 69 71 <Compile Include="Converters\ValueLookupParameterConverter.cs" /> 70 72 <Compile Include="Converters\ValueRangeConverter.cs" /> … … 77 79 <Compile Include="Interfaces\IMatrixJsonItem.cs" /> 78 80 <Compile Include="Interfaces\IRangedJsonItem.cs" /> 81 <Compile Include="Interfaces\IResultFormatter.cs" /> 79 82 <Compile Include="Interfaces\IResultJsonItem.cs" /> 80 83 <Compile Include="Interfaces\IValueJsonItem.cs" /> … … 100 103 <Compile Include="JsonItems\ValueJsonItem.cs" /> 101 104 <Compile Include="JsonItems\ValueLookupJsonItem.cs" /> 105 <Compile Include="ResultFormatter\MatlabResultFormatter.cs" /> 106 <Compile Include="ResultFormatter\ResultFormatter.cs" /> 107 <Compile Include="ResultFormatter\StringResultFormatter.cs" /> 102 108 <Compile Include="SingleLineArrayJsonWriter.cs" /> 103 109 <Compile Include="JsonTemplateGenerator.cs" /> … … 142 148 <Name>HeuristicLab.Data-3.3</Name> 143 149 </ProjectReference> 150 <ProjectReference Include="..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj"> 151 <Project>{06d4a186-9319-48a0-bade-a2058d462eea}</Project> 152 <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name> 153 </ProjectReference> 144 154 <ProjectReference Include="..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 145 155 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> … … 153 163 <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project> 154 164 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 165 </ProjectReference> 166 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj"> 167 <Project>{5ac82412-911b-4fa2-a013-edc5e3f3fcc2}</Project> 168 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name> 169 </ProjectReference> 170 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj"> 171 <Project>{3d28463f-ec96-4d82-afee-38be91a0ca00}</Project> 172 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name> 155 173 </ProjectReference> 156 174 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj"> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IResultJsonItem.cs
r17519 r17834 1 namespace HeuristicLab.JsonInterface { 1 using System; 2 using Newtonsoft.Json; 3 4 namespace HeuristicLab.JsonInterface { 2 5 /// <summary> 3 /// EmptyJsonItem, which indicates a result. For example 'BestQuality'.6 /// JsonItem, which indicates a result. For example 'BestQuality'. 4 7 /// Types of this JsonItems are stored in the result section of the template. 5 8 /// </summary> 6 public interface IResultJsonItem : IJsonItem { } 9 public interface IResultJsonItem : IJsonItem { 10 /// <summary> 11 /// the result formatter type's fullname 12 /// </summary> 13 string ResultFormatterType { get; set; } 14 15 /// <summary> 16 /// the type of the result value 17 /// </summary> 18 [JsonIgnore] 19 Type ValueType { get; set; } 20 } 7 21 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/JsonItem.cs
r17828 r17834 125 125 }); 126 126 127 public virtual void SetJObject(JObject jObject) { } 127 public virtual void SetJObject(JObject jObject) { 128 Name = (jObject[nameof(IJsonItem.Name)]?.ToObject<string>()); 129 Description = (jObject[nameof(IJsonItem.Description)]?.ToObject<string>()); 130 } 128 131 #endregion 129 132 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ResultJsonItem.cs
r17828 r17834 1 namespace HeuristicLab.JsonInterface { 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using Newtonsoft.Json.Linq; 5 6 namespace HeuristicLab.JsonInterface { 2 7 public class ResultJsonItem : JsonItem, IResultJsonItem { 8 public string ResultFormatterType { get; set; } 9 10 public Type ValueType { get; set; } 11 3 12 protected override ValidationResult Validate() => ValidationResult.Successful(); 4 13 5 public string Converter { get; set; } 14 public override void SetJObject(JObject jObject) { 15 base.SetJObject(jObject); 16 ResultFormatterType = (jObject[nameof(IResultJsonItem.ResultFormatterType)]?.ToObject<string>()); 17 } 18 6 19 } 7 20 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r17828 r17834 81 81 IList<IResultJsonItem> res = new List<IResultJsonItem>(); 82 82 foreach(JObject obj in Template[Constants.Results]) { 83 string name = obj.Property("Name").Value.ToString(); 84 res.Add(new ResultJsonItem() { Name = name }); 83 //string name = obj.Property("Name").Value.ToString(); 84 var resultItem = new ResultJsonItem(); 85 resultItem.SetJObject(obj); 86 res.Add(resultItem); 87 //res.Add(new ResultJsonItem() { Name = name }); 85 88 } 86 89 return res; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Plugin.cs.frame
r17330 r17834 34 34 [PluginDependency("HeuristicLab.Parameters", "3.3")] 35 35 [PluginDependency("HeuristicLab.SequentialEngine", "3.3")] 36 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] 37 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 38 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")] 39 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")] 40 [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")] 36 41 public class HeuristicLabJsonInterfacePlugin : PluginBase { 37 42 }
Note: See TracChangeset
for help on using the changeset viewer.