Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17339 for branches


Ignore:
Timestamp:
10/21/19 16:14:49 (4 years ago)
Author:
dpiringe
Message:

#3026 fixed a bug with path generation

Location:
branches/3026_IntegrationIntoSymSpace
Files:
7 edited

Legend:

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

    r17330 r17339  
    1414      IAlgorithm alg = instantiator.Instantiate(template, config);
    1515 
    16       //alg.Start();
    1716      Task task = alg.StartAsync();
    1817      while(!task.IsCompleted) {
    1918        WriteResultsToFile(outputFile, alg);
    20         Thread.Sleep(1000);
     19        Thread.Sleep(100);
    2120      }
    2221      WriteResultsToFile(outputFile, alg);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/FileManager.cs

    r17331 r17339  
    4545          JCGenerator gen = new JCGenerator();
    4646          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));
    5048        }
    5149      }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs

    r17284 r17339  
    3232      return list.ToArray();
    3333    }
    34     // id = kombi aus path + default
     34
    3535    private IList<JsonItem> GetParameterizedChilds(IParameter value) {
    3636      List<JsonItem> list = new List<JsonItem>();
     
    3939        if (x is IParameterizedItem) {
    4040          JsonItem tmp = JsonItemConverter.Extract(x);
    41           tmp.PrependPath(value.Name);
    4241          list.Add(tmp);
    4342        }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs

    r17330 r17339  
    2222      item.Name = value.ItemName;
    2323      item.Type = value.GetType().AssemblyQualifiedName;
    24       item.Path = value.ItemName;
    2524
    2625      foreach (var param in value.Cast<IParameterizedItem>().Parameters) {
    2726        JsonItem data = JsonItemConverter.Extract(param);
    2827        data.Name = param.Name;
    29         data.Path = data.Name;
    30         data.PrependPath(item.Path);
    31         data.UpdatePaths();
    3228       
    3329        if (item.Parameters == null)
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs

    r17330 r17339  
    1010namespace HeuristicLab.JsonInterface {
    1111  public class JCGenerator {
    12 
    1312    private JObject template = JObject.Parse(Constants.Template);
    1413    private Dictionary<string, string> TypeList = new Dictionary<string, string>();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCInstantiator.cs

    r17330 r17339  
    5252      //7. get problem data and object
    5353      JsonItem problemData = GetData(problemName);
    54      
    5554      IProblem problem = CreateObject<IProblem>(problemData);
    5655      algorithm.Problem = problem;
     
    5857      //8. inject configuration
    5958      JsonItemConverter.Inject(algorithm, algorithmData);
    60       //JsonItemConverter.Inject(problem, problemData);
     59      JsonItemConverter.Inject(problem, problemData);
    6160
    62       if (algorithm is EngineAlgorithm) {
     61      if (algorithm is EngineAlgorithm)
    6362        algorithm.Cast<EngineAlgorithm>().Engine = new SequentialEngine.SequentialEngine();
    64         File.WriteAllText(@"C:\Workspace\test2.txt", "test");
    65       }
    6663
    6764      return algorithm;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItem.cs

    r17324 r17339  
    1010namespace HeuristicLab.JsonInterface {
    1111  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    }
    1622    public string Type { get; set; }
    1723    public string Path { get; set; }
     
    1925    public IList<JsonItem> Operators { get; set; }
    2026
     27    private object defaultValue;
    2128    public object Default {
    2229      get => defaultValue;
     
    2835    }
    2936
     37    private IList<object> range;
    3038    public IList<object> Range {
    3139      get => range;
     
    6573      IsInNumericRange<double>(data.Default, data.Range[0], data.Range[1]));
    6674
    67     public void UpdatePaths() {
     75    public void UpdatePath() {
    6876      if (Parameters != null)
    69         foreach (var p in Parameters)
    70           p.Path = $"{Path}.{p.Name}";
     77        UpdatePathHelper(Parameters);
    7178
    72       if (Operators != null)
    73         foreach (var p in Operators)
    74           p.Path = $"{Path}.{p.Name}";
    75     }
     79      if (Operators != null)
     80        UpdatePathHelper(Operators);
    7681
    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);
    8184    }
    8285
    8386    #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
    8497    private static bool IsInRangeList(IEnumerable<object> list, object value) {
    8598      foreach (var x in list)
     
    92105        (((T)min).CompareTo(value) == -1 || ((T)min).CompareTo(value) == 0) &&
    93106        (((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     }
    100107    #endregion
    101108  }
Note: See TracChangeset for help on using the changeset viewer.