Changeset 17339
- Timestamp:
- 10/21/19 16:14:49 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs
r17330 r17339 14 14 IAlgorithm alg = instantiator.Instantiate(template, config); 15 15 16 //alg.Start();17 16 Task task = alg.StartAsync(); 18 17 while(!task.IsCompleted) { 19 18 WriteResultsToFile(outputFile, alg); 20 Thread.Sleep(100 0);19 Thread.Sleep(100); 21 20 } 22 21 WriteResultsToFile(outputFile, alg); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/FileManager.cs
r17331 r17339 45 45 JCGenerator gen = new JCGenerator(); 46 46 IAlgorithm alg = namedItem as IAlgorithm; 47 Task.Run(() => { 48 File.WriteAllText(saveFileDialog.FileName, gen.GenerateTemplate(alg)); 49 }); 47 File.WriteAllText(saveFileDialog.FileName, gen.GenerateTemplate(alg)); 50 48 } 51 49 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r17284 r17339 32 32 return list.ToArray(); 33 33 } 34 // id = kombi aus path + default 34 35 35 private IList<JsonItem> GetParameterizedChilds(IParameter value) { 36 36 List<JsonItem> list = new List<JsonItem>(); … … 39 39 if (x is IParameterizedItem) { 40 40 JsonItem tmp = JsonItemConverter.Extract(x); 41 tmp.PrependPath(value.Name);42 41 list.Add(tmp); 43 42 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs
r17330 r17339 22 22 item.Name = value.ItemName; 23 23 item.Type = value.GetType().AssemblyQualifiedName; 24 item.Path = value.ItemName;25 24 26 25 foreach (var param in value.Cast<IParameterizedItem>().Parameters) { 27 26 JsonItem data = JsonItemConverter.Extract(param); 28 27 data.Name = param.Name; 29 data.Path = data.Name;30 data.PrependPath(item.Path);31 data.UpdatePaths();32 28 33 29 if (item.Parameters == null) -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs
r17330 r17339 10 10 namespace HeuristicLab.JsonInterface { 11 11 public class JCGenerator { 12 13 12 private JObject template = JObject.Parse(Constants.Template); 14 13 private Dictionary<string, string> TypeList = new Dictionary<string, string>(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCInstantiator.cs
r17330 r17339 52 52 //7. get problem data and object 53 53 JsonItem problemData = GetData(problemName); 54 55 54 IProblem problem = CreateObject<IProblem>(problemData); 56 55 algorithm.Problem = problem; … … 58 57 //8. inject configuration 59 58 JsonItemConverter.Inject(algorithm, algorithmData); 60 //JsonItemConverter.Inject(problem, problemData);59 JsonItemConverter.Inject(problem, problemData); 61 60 62 if (algorithm is EngineAlgorithm) {61 if (algorithm is EngineAlgorithm) 63 62 algorithm.Cast<EngineAlgorithm>().Engine = new SequentialEngine.SequentialEngine(); 64 File.WriteAllText(@"C:\Workspace\test2.txt", "test");65 }66 63 67 64 return algorithm; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItem.cs
r17324 r17339 10 10 namespace HeuristicLab.JsonInterface { 11 11 public class JsonItem { 12 private IList<object> range; 13 private object defaultValue; 14 15 public string Name { get; set; } 12 13 private string name; 14 public string Name { 15 get => name; 16 set { 17 name = value; 18 Path = Name; 19 UpdatePath(); 20 } 21 } 16 22 public string Type { get; set; } 17 23 public string Path { get; set; } … … 19 25 public IList<JsonItem> Operators { get; set; } 20 26 27 private object defaultValue; 21 28 public object Default { 22 29 get => defaultValue; … … 28 35 } 29 36 37 private IList<object> range; 30 38 public IList<object> Range { 31 39 get => range; … … 65 73 IsInNumericRange<double>(data.Default, data.Range[0], data.Range[1])); 66 74 67 public void UpdatePath s() {75 public void UpdatePath() { 68 76 if (Parameters != null) 69 foreach (var p in Parameters) 70 p.Path = $"{Path}.{p.Name}"; 77 UpdatePathHelper(Parameters); 71 78 72 if (Operators != null) 73 foreach (var p in Operators) 74 p.Path = $"{Path}.{p.Name}"; 75 } 79 if (Operators != null) 80 UpdatePathHelper(Operators); 76 81 77 public void PrependPath(string str) { 78 Path = $"{str}.{Path}"; 79 PrependPathHelper(Parameters, str); 80 PrependPathHelper(Operators, str); 82 if(Reference != null) 83 UpdatePathHelper(Reference); 81 84 } 82 85 83 86 #region Helper 87 private void UpdatePathHelper(params JsonItem[] items) => 88 UpdatePathHelper((IEnumerable<JsonItem>)items); 89 90 private void UpdatePathHelper(IEnumerable<JsonItem> items) { 91 foreach (var item in items) { 92 item.Path = $"{Path}.{item.Name}"; 93 item.UpdatePath(); 94 } 95 } 96 84 97 private static bool IsInRangeList(IEnumerable<object> list, object value) { 85 98 foreach (var x in list) … … 92 105 (((T)min).CompareTo(value) == -1 || ((T)min).CompareTo(value) == 0) && 93 106 (((T)max).CompareTo(value) == 1 || ((T)max).CompareTo(value) == 0)); 94 95 private void PrependPathHelper(IEnumerable<JsonItem> items, string str) {96 if (items != null)97 foreach (var p in items)98 p.PrependPath(str);99 }100 107 #endregion 101 108 }
Note: See TracChangeset
for help on using the changeset viewer.