Changeset 17404 for branches/3026_IntegrationIntoSymSpace
- Timestamp:
- 01/20/20 16:36:05 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 24 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/FileManager.cs
r17394 r17404 13 13 14 14 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 15 internal 15 internal static class FileManager { 16 16 private static SaveFileDialog saveFileDialog; 17 17 private static OpenFileDialog openFileDialog; 18 private static ExportJsonDialog exportDialog = new ExportJsonDialog(); 18 19 19 20 public static void ExportJsonTemplate() { … … 23 24 } 24 25 } 25 public static void ExportJsonTemplate(IContentView view) { 26 public static void ExportJsonTemplate(IContentView view) { 26 27 // TODO: view to select free params, warning if no results are generated 28 29 30 27 31 IStorableContent content = view.Content as IStorableContent; 28 32 if (!view.Locked && content != null) { 33 exportDialog.Content = content; 34 exportDialog.ShowDialog(); 35 /* 29 36 if (saveFileDialog == null) { 30 37 saveFileDialog = new SaveFileDialog(); … … 47 54 File.WriteAllText(saveFileDialog.FileName, JCGenerator.GenerateTemplate(alg)); 48 55 } 56 */ 49 57 } 50 58 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj
r17331 r17404 38 38 </PropertyGroup> 39 39 <ItemGroup> 40 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 41 <SpecificVersion>False</SpecificVersion> 42 <HintPath>..\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 43 </Reference> 44 <Reference Include="HeuristicLab.Analysis.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 45 <SpecificVersion>False</SpecificVersion> 46 <HintPath>..\bin\HeuristicLab.Analysis.Views-3.3.dll</HintPath> 47 </Reference> 48 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 49 <SpecificVersion>False</SpecificVersion> 50 <HintPath>..\bin\HeuristicLab.Collections-3.3.dll</HintPath> 51 </Reference> 52 <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 53 <SpecificVersion>False</SpecificVersion> 54 <HintPath>..\bin\HeuristicLab.Core.Views-3.3.dll</HintPath> 55 </Reference> 56 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 57 <SpecificVersion>False</SpecificVersion> 58 <HintPath>..\bin\HeuristicLab.Data-3.3.dll</HintPath> 59 </Reference> 60 <Reference Include="HeuristicLab.Optimization.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 61 <SpecificVersion>False</SpecificVersion> 62 <HintPath>..\bin\HeuristicLab.Optimization.Views-3.3.dll</HintPath> 63 </Reference> 40 64 <Reference Include="System" /> 41 65 <Reference Include="System.Core" /> 66 <Reference Include="System.Drawing" /> 42 67 <Reference Include="System.Windows.Forms" /> 43 68 <Reference Include="System.Xml.Linq" /> … … 49 74 </ItemGroup> 50 75 <ItemGroup> 76 <Compile Include="Properties\Resources.Designer.cs"> 77 <AutoGen>True</AutoGen> 78 <DesignTime>True</DesignTime> 79 <DependentUpon>Resources.resx</DependentUpon> 80 </Compile> 81 <Compile Include="Shared\JsonItemBaseControl.cs"> 82 <SubType>UserControl</SubType> 83 </Compile> 84 <Compile Include="Shared\JsonItemBaseControl.Designer.cs"> 85 <DependentUpon>JsonItemBaseControl.cs</DependentUpon> 86 </Compile> 87 <Compile Include="Views\ExportJsonDialog.cs"> 88 <SubType>Form</SubType> 89 </Compile> 90 <Compile Include="Views\ExportJsonDialog.Designer.cs"> 91 <DependentUpon>ExportJsonDialog.cs</DependentUpon> 92 </Compile> 51 93 <Compile Include="FileManager.cs" /> 94 <Compile Include="Views\JsonItemBoolControl.cs"> 95 <SubType>UserControl</SubType> 96 </Compile> 97 <Compile Include="Views\JsonItemBoolControl.Designer.cs"> 98 <DependentUpon>JsonItemBoolControl.cs</DependentUpon> 99 </Compile> 100 <Compile Include="Views\JsonItemRangeControl.cs"> 101 <SubType>UserControl</SubType> 102 </Compile> 103 <Compile Include="Views\JsonItemRangeControl.Designer.cs"> 104 <DependentUpon>JsonItemRangeControl.cs</DependentUpon> 105 </Compile> 106 <Compile Include="Views\JsonItemValueControl.cs"> 107 <SubType>UserControl</SubType> 108 </Compile> 109 <Compile Include="Views\JsonItemValueControl.Designer.cs"> 110 <DependentUpon>JsonItemValueControl.cs</DependentUpon> 111 </Compile> 112 <Compile Include="Views\JsonItemValidValuesControl.cs"> 113 <SubType>UserControl</SubType> 114 </Compile> 115 <Compile Include="Views\JsonItemValidValuesControl.Designer.cs"> 116 <DependentUpon>JsonItemValidValuesControl.cs</DependentUpon> 117 </Compile> 118 <Compile Include="ViewModels\JsonItemVM.cs" /> 52 119 <Compile Include="MenuItems\ImportJsonTemplateMenuItem.cs" /> 53 120 <Compile Include="MenuItems\ExportJsonTemplateMenuItem.cs" /> … … 93 160 </ProjectReference> 94 161 </ItemGroup> 162 <ItemGroup> 163 <EmbeddedResource Include="Properties\Resources.resx"> 164 <Generator>ResXFileCodeGenerator</Generator> 165 <LastGenOutput>Resources.Designer.cs</LastGenOutput> 166 </EmbeddedResource> 167 <EmbeddedResource Include="Shared\JsonItemBaseControl.resx"> 168 <DependentUpon>JsonItemBaseControl.cs</DependentUpon> 169 </EmbeddedResource> 170 <EmbeddedResource Include="Views\ExportJsonDialog.resx"> 171 <DependentUpon>ExportJsonDialog.cs</DependentUpon> 172 </EmbeddedResource> 173 <EmbeddedResource Include="Views\JsonItemBoolControl.resx"> 174 <DependentUpon>JsonItemBoolControl.cs</DependentUpon> 175 </EmbeddedResource> 176 <EmbeddedResource Include="Views\JsonItemRangeControl.resx"> 177 <DependentUpon>JsonItemRangeControl.cs</DependentUpon> 178 </EmbeddedResource> 179 <EmbeddedResource Include="Views\JsonItemValueControl.resx"> 180 <DependentUpon>JsonItemValueControl.cs</DependentUpon> 181 </EmbeddedResource> 182 <EmbeddedResource Include="Views\JsonItemValidValuesControl.resx"> 183 <DependentUpon>JsonItemValidValuesControl.cs</DependentUpon> 184 </EmbeddedResource> 185 </ItemGroup> 186 <ItemGroup /> 95 187 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 96 188 <PropertyGroup> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs
r17395 r17404 45 45 TypeCode typeCode = Type.GetTypeCode(t); 46 46 47 if (t ypeof(ValueType).IsEqualTo(typeof(PercentValue)))47 if (t.IsEqualTo(typeof(PercentValue))) 48 48 return 1.0d; 49 49 … … 67 67 TypeCode typeCode = Type.GetTypeCode(t); 68 68 69 if (t ypeof(ValueType).IsEqualTo(typeof(PercentValue)))69 if (t.IsEqualTo(typeof(PercentValue))) 70 70 return 0.0d; 71 71 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r17394 r17404 46 46 if (x is IParameterizedItem) { 47 47 JsonItem tmp = JsonItemConverter.Extract(x); 48 list.Add(tmp); 48 if(!(tmp is UnsupportedJsonItem)) 49 list.Add(tmp); 49 50 } 50 51 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs
r17394 r17404 25 25 26 26 foreach (var param in parameterizedItem.Parameters) { 27 if(!param.Hidden) 28 item.AddChilds(root.Extract(param, root)); 27 if (!param.Hidden) { 28 JsonItem tmp = root.Extract(param, root); 29 if(!(tmp is UnsupportedJsonItem)) 30 item.AddChilds(tmp); 31 } 32 29 33 } 30 34 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r17394 r17404 21 21 if (value.ActualValue != null) { 22 22 JsonItem tmp = root.Extract(value.ActualValue, root); 23 if(tmp.Name == "[OverridableParamName]") { 24 tmp.Name = value.Name; 25 JsonItem.Merge(item, tmp); 23 if(!(tmp is UnsupportedJsonItem)) { 24 if (tmp.Name == "[OverridableParamName]") { 25 tmp.Name = value.Name; 26 JsonItem.Merge(item, tmp); 27 } else 28 item.AddChilds(tmp); 26 29 } 27 else28 item.AddChilds(tmp);29 30 } 30 31 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs
r17395 r17404 12 12 namespace HeuristicLab.JsonInterface { 13 13 /// <summary> 14 /// Static class to generate json interface templates.14 /// Class to generate json interface templates. 15 15 /// </summary> 16 public staticclass JCGenerator {17 private struct GenData {18 public JObject Template{ get; set; }19 public JArrayJsonItems { get; set; }20 }21 22 public st atic string GenerateTemplate(IOptimizer optimizer) {16 public class JCGenerator { 17 private JObject Template { get; set; } 18 private JArray JArrayItems { get; set; } 19 private IList<JsonItem> JsonItems { get; set; } 20 private IOptimizer Optimizer { get; set; } 21 22 public string GenerateTemplate(IOptimizer optimizer) { 23 23 // data container 24 GenData genData = new GenData() { 25 Template = JObject.Parse(Constants.Template), 26 JsonItems = new JArray() 27 }; 24 JArrayItems = new JArray(); 25 JsonItems = new List<JsonItem>(); 28 26 29 27 ProtoBufSerializer serializer = new ProtoBufSerializer(); 30 28 serializer.Serialize(optimizer, @"C:\Workspace\template.hl"); 31 genData.Template[Constants.Metadata][Constants.HLFileLocation] = @"C:\Workspace\template.hl";29 Template[Constants.Metadata][Constants.HLFileLocation] = @"C:\Workspace\template.hl"; 32 30 33 31 // extract JsonItem, save the name in the metadata section of the 34 32 // template and save it an JArray incl. all parameters of the JsonItem, 35 33 // which have parameters aswell 36 AddI nstantiableIItem(Constants.Optimizer, optimizer, genData);34 AddIItem(optimizer); 37 35 38 36 // save the JArray with JsonItems (= IParameterizedItems) 39 genData.Template[Constants.Parameters] = genData.JsonItems;37 Template[Constants.Parameters] = JArrayItems; 40 38 // serialize template and return string 41 return SingleLineArrayJsonWriter.Serialize(genData.Template); 39 return SingleLineArrayJsonWriter.Serialize(Template); 40 } 41 42 public string GenerateTemplate(IEnumerable<JsonItem> items) { 43 ProtoBufSerializer serializer = new ProtoBufSerializer(); 44 serializer.Serialize(Optimizer, @"C:\Workspace\template.hl"); 45 Template[Constants.Metadata][Constants.HLFileLocation] = @"C:\Workspace\template.hl"; 46 47 JArrayItems = new JArray(); 48 foreach (var item in items) { 49 JArrayItems.Add(Serialize(item)); 50 } 51 Template[Constants.Parameters] = JArrayItems; 52 53 // serialize template and return string 54 return SingleLineArrayJsonWriter.Serialize(Template); 55 } 56 57 public IEnumerable<JsonItem> FetchJsonItems(IOptimizer optimizer) { 58 // data container 59 Template = JObject.Parse(Constants.Template); 60 JsonItems = new List<JsonItem>(); 61 Optimizer = optimizer; 62 63 // extract JsonItem, save the name in the metadata section of the 64 // template and save it an JArray incl. all parameters of the JsonItem, 65 // which have parameters aswell 66 AddIItem(optimizer); 67 68 // serialize template and return string 69 return JsonItems; 42 70 } 43 71 44 72 #region Helper 45 73 46 private static void AddInstantiableIItem(string metaDataTagName, IItem item, GenData genData) {74 private void AddIItem(IItem item) { 47 75 JsonItem jsonItem = JsonItemConverter.Extract(item); 48 49 genData.Template[Constants.Metadata][metaDataTagName] = item.ItemName; 50 PopulateJsonItems(jsonItem, genData); 76 Template[Constants.Metadata][Constants.Optimizer] = item.ItemName; 77 PopulateJsonItems(jsonItem); 51 78 } 52 79 53 80 // serializes ParameterizedItems and saves them in list "JsonItems". 54 private static void PopulateJsonItems(JsonItem item, GenData genData) {81 private void PopulateJsonItems(JsonItem item) { 55 82 IEnumerable<JsonItem> tmpParameter = item.Children; 56 83 57 84 if (item.Value != null || item.Range != null) { 58 genData.JsonItems.Add(Serialize(item));85 JsonItems.Add(item); 59 86 } 60 87 61 88 if (tmpParameter != null) { 62 89 foreach (var p in tmpParameter) { 63 PopulateJsonItems(p , genData);90 PopulateJsonItems(p); 64 91 } 65 92 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItem.cs
r17394 r17404 110 110 111 111 #region Helper 112 113 114 112 protected bool IsInRange() { 115 113 bool b1 = true, b2 = true;
Note: See TracChangeset
for help on using the changeset viewer.