Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17271 for branches


Ignore:
Timestamp:
09/26/19 10:14:35 (5 years ago)
Author:
dpiringe
Message:

#3026

  • renamed ParameterData to Component
  • renamed File Template.cs to Component.cs
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture
Files:
18 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Component.cs

    r17270 r17271  
    1717  }*/
    1818
    19   public class ParameterData {
     19  public class Component {
    2020    public string Name { get; set; }
    2121    public string Type { get; set; }
     
    2424    public IList<object> Range { get; set; }
    2525
    26     public IList<ParameterData> Parameters { get; set; }
    27     public IList<ParameterData> Operators { get; set; }
     26    public IList<Component> Parameters { get; set; }
     27    public IList<Component> Operators { get; set; }
    2828
    2929    [JsonIgnore]
    30     public ParameterData this[string index] {
     30    public Component this[string index] {
    3131      get {
    3232        if (Parameters == null) return null;
     
    3737      set {
    3838        if (Parameters == null)
    39           Parameters = new List<ParameterData>();
    40         ParameterData data = this[index];
     39          Parameters = new List<Component>();
     40        Component data = this[index];
    4141        if (data != null && CheckConstraints(value))
    4242          Merge(data, value);
     
    4747
    4848    public override bool Equals(object obj) {
    49       if (!(obj is ParameterData))
     49      if (!(obj is Component))
    5050        return false;
    5151      else
    52         return obj.Cast<ParameterData>().Name == this.Name;
     52        return obj.Cast<Component>().Name == this.Name;
    5353    }
    5454
     
    5858
    5959    [JsonIgnore]
    60     public IList<ParameterData> ParameterizedItems { get; set; }
     60    public IList<Component> ParameterizedItems { get; set; }
    6161
    6262    [JsonIgnore]
    63     public ParameterData Reference { get; set; }
     63    public Component Reference { get; set; }
    6464
    6565    #region Helper
    66     public static void Merge(ParameterData target, ParameterData from) {
     66    public static void Merge(Component target, Component from) {
    6767      target.Name = from.Name ?? target.Name;
    6868      target.Type = from.Type ?? target.Type;
     
    7575    }
    7676
    77     private bool CheckConstraints(ParameterData data) =>
     77    private bool CheckConstraints(Component data) =>
    7878      data.Range != null && data.Default != null && (
    7979      IsInRangeList(data.Range, data.Default) ||
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/HeuristicLab.Manufacture.csproj

    r17269 r17271  
    7070    <Compile Include="Program.cs" />
    7171    <Compile Include="Properties\AssemblyInfo.cs" />
    72     <Compile Include="Template.cs" />
     72    <Compile Include="Component.cs" />
    7373    <Compile Include="Interfaces\ITypeTransformer.cs" />
    7474    <Compile Include="Transformer.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Interfaces/ITypeTransformer.cs

    r17266 r17271  
    1010  //IDataProcessor?
    1111  public interface ITypeTransformer {
    12     ParameterData Extract(IItem value);
    13     void Inject(IItem item, ParameterData data);
     12    Component Extract(IItem value);
     13    void Inject(IItem item, Component data);
    1414  }
    1515}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/JCGenerator.cs

    r17269 r17271  
    6262    public string GenerateTemplate(IAlgorithm algorithm, IProblem problem, params string[] freeParameters) {
    6363      algorithm.Problem = problem;
    64       ParameterData algorithmData = Transformer.Extract(algorithm);
    65       ParameterData problemData = Transformer.Extract(problem);
    66       IList<ParameterData> items = algorithmData.ParameterizedItems;
     64      Component algorithmData = Transformer.Extract(algorithm);
     65      Component problemData = Transformer.Extract(problem);
     66      IList<Component> items = algorithmData.ParameterizedItems;
    6767      foreach (var pItem in problemData.ParameterizedItems) items.Add(pItem);
    6868      JArray jsonItems = new JArray();
     
    9393      IList<JObject> objToRemove = new List<JObject>();
    9494      TransformNodes(x => {
    95         var p = x.ToObject<ParameterData>();
     95        var p = x.ToObject<Component>();
    9696
    9797        /*bool isSelected = false;
     
    114114      IList<JObject> objToRemove = new List<JObject>();
    115115      TransformNodes(x => {
    116         var p = x.ToObject<ParameterData>();
     116        var p = x.ToObject<Component>();
    117117        x.Property("Range")?.Remove();
    118118        if (p.Default == null) objToRemove.Add(x);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/JCInstantiator.cs

    r17269 r17271  
    2222      Config = JToken.Parse(File.ReadAllText(configFile));
    2323
    24       ParameterData algorithmData = GetData(Config["Metadata"]["Algorithm"].ToString());
     24      Component algorithmData = GetData(Config["Metadata"]["Algorithm"].ToString());
    2525      ResolveReferences(algorithmData);
    2626      IAlgorithm algorithm = CreateObject<IAlgorithm>(algorithmData);
    2727     
    28       ParameterData problemData = GetData(Config["Metadata"]["Problem"].ToString());
     28      Component problemData = GetData(Config["Metadata"]["Problem"].ToString());
    2929      ResolveReferences(problemData);
    3030      IProblem problem = CreateObject<IProblem>(problemData);
     
    4141     */
    4242
    43     private void ResolveReferences(ParameterData data) {
     43    private void ResolveReferences(Component data) {
    4444      foreach (var p in data.Parameters) {
    4545        if (p.Default is string && p.Reference == null) {
     
    4949    }
    5050
    51     private ParameterData GetData(string key)
     51    private Component GetData(string key)
    5252    {
    5353      foreach(JObject item in Config["Objects"])
    5454      {
    55         ParameterData data = BuildDataFromJObject(item);
     55        Component data = BuildDataFromJObject(item);
    5656        if (data.Name == key) return data;
    5757      }
     
    5959    }
    6060
    61     private ParameterData BuildDataFromJObject(JObject obj) {
    62       ParameterData data = new ParameterData() {
     61    private Component BuildDataFromJObject(JObject obj) {
     62      Component data = new Component() {
    6363        Name = obj["Name"]?.ToString(),
    6464        Default = obj["Default"]?.ToObject<object>(),
     
    7676
    7777      if (obj["Operators"] != null) {
    78         data.Operators = new List<ParameterData>();
     78        data.Operators = new List<Component>();
    7979        foreach (JObject sp in obj["Operators"])
    8080          data.Operators.Add(BuildDataFromJObject(sp));
     
    8484    }
    8585
    86     private T CreateObject<T>(ParameterData data) {
     86    private T CreateObject<T>(Component data) {
    8787      Type type = Type.GetType(data.Type);
    8888      return (T)Activator.CreateInstance(type);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/ParameterTransformer/ConstrainedValueParameterTransformer.cs

    r17269 r17271  
    88namespace HeuristicLab.Manufacture {
    99  public class ConstrainedValueParameterTransformer : ParameterBaseTransformer {
    10     public override void InjectData(IParameter parameter, ParameterData data) {
     10    public override void InjectData(IParameter parameter, Component data) {
    1111      foreach (var x in parameter.Cast<dynamic>().ValidValues)
    1212        if (x.GetType().Name == CastValue<string>(data.Default))
     
    1717    }
    1818
    19     public override ParameterData ExtractData(IParameter value) {
     19    public override Component ExtractData(IParameter value) {
    2020
    21       return new ParameterData() {
     21      return new Component() {
    2222        Name = value.Name,
    2323        Default = value.ActualValue?.GetType().Name,
     
    3535    }
    3636
    37     private IList<ParameterData> GetParameterizedChilds(IParameter value) {
    38       List<ParameterData> list = new List<ParameterData>();
     37    private IList<Component> GetParameterizedChilds(IParameter value) {
     38      List<Component> list = new List<Component>();
    3939      var values = value.Cast<dynamic>().ValidValues;
    4040      foreach(var x in values) {
    4141        if (x is IParameterizedItem &&
    4242            ((IParameterizedItem)x).Parameters.Any(p => !p.Hidden)) {
    43           ParameterData tmp = Transformer.Extract(x);
     43          Component tmp = Transformer.Extract(x);
    4444          if (tmp.ParameterizedItems != null)
    4545            list.AddRange(tmp.ParameterizedItems);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/ParameterTransformer/LookupParameterTransformer.cs

    r17266 r17271  
    88namespace HeuristicLab.Manufacture {
    99  public class LookupParameterTransformer : ParameterBaseTransformer {
    10     public override ParameterData ExtractData(IParameter value) {
    11       return new ParameterData() { Name = value.Name };
     10    public override Component ExtractData(IParameter value) {
     11      return new Component() { Name = value.Name };
    1212    }
    1313
    14     public override void InjectData(IParameter parameter, ParameterData data) {
     14    public override void InjectData(IParameter parameter, Component data) {
    1515     
    1616    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/ParameterTransformer/ParameterBaseTransformer.cs

    r17266 r17271  
    88namespace HeuristicLab.Manufacture {
    99  public abstract class ParameterBaseTransformer : BaseTransformer {
    10     public override ParameterData ExtractData(IItem value) => ExtractData(value.Cast<IParameter>());
    11     public abstract ParameterData ExtractData(IParameter value);
     10    public override Component ExtractData(IItem value) => ExtractData(value.Cast<IParameter>());
     11    public abstract Component ExtractData(IParameter value);
    1212
    13     public override void InjectData(IItem item, ParameterData data) => InjectData(item.Cast<IParameter>(), data);
     13    public override void InjectData(IItem item, Component data) => InjectData(item.Cast<IParameter>(), data);
    1414
    15     public abstract void InjectData(IParameter parameter, ParameterData data);
     15    public abstract void InjectData(IParameter parameter, Component data);
    1616  }
    1717}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/ParameterTransformer/ParameterizedItemTransformer.cs

    r17269 r17271  
    1010  public class ParameterizedItemTransformer : BaseTransformer {
    1111   
    12     public override void InjectData(IItem item, ParameterData data) {
     12    public override void InjectData(IItem item, Component data) {
    1313      IParameterizedItem pItem = item.Cast<IParameterizedItem>();
    1414
     
    1818    }
    1919
    20     public override ParameterData ExtractData(IItem value) {
    21       List<ParameterData> list = new List<ParameterData>();
     20    public override Component ExtractData(IItem value) {
     21      List<Component> list = new List<Component>();
    2222
    23       ParameterData obj = new ParameterData();
     23      Component obj = new Component();
    2424      obj.Name = value.ItemName;
    2525      obj.Type = value.GetType().AssemblyQualifiedName;
     
    2929      foreach (var param in value.Cast<IParameterizedItem>().Parameters) {
    3030        if (!param.Hidden) {
    31           ParameterData data = Transformer.Extract(param);
     31          Component data = Transformer.Extract(param);
    3232          obj[data.Name] = data;
    3333          if(data.ParameterizedItems != null)
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/ParameterTransformer/ValueParameterTransformer.cs

    r17269 r17271  
    99  public class ValueParameterTransformer : ParameterBaseTransformer {
    1010
    11     public override void InjectData(IParameter parameter, ParameterData data) =>
     11    public override void InjectData(IParameter parameter, Component data) =>
    1212      Transformer.Inject(parameter.ActualValue, data);
    1313
    14     public override ParameterData ExtractData(IParameter value) {
    15       ParameterData data = null;
     14    public override Component ExtractData(IParameter value) {
     15      Component data = null;
    1616      if (value.ActualValue == null)
    17         data = new ParameterData();
     17        data = new Component();
    1818      else
    1919        data = Transformer.Extract(value.ActualValue);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Transformer.cs

    r17269 r17271  
    4949    }
    5050
    51     internal static void Inject(IItem item, ParameterData data) {
     51    internal static void Inject(IItem item, Component data) {
    5252      IEnumerable<ITypeTransformer> arr = Get(item.GetType());
    5353      foreach (var transformer in arr)
     
    5555    }
    5656
    57     internal static ParameterData Extract(IItem item) {
     57    internal static Component Extract(IItem item) {
    5858      IEnumerable<ITypeTransformer> arr = Get(item.GetType());
    59       ParameterData data = new ParameterData();
     59      Component data = new Component();
    6060      foreach (var transformer in arr)
    61         ParameterData.Merge(data, transformer.Extract(item));
     61        Component.Merge(data, transformer.Extract(item));
    6262      return data;
    6363    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/BaseTransformer.cs

    r17266 r17271  
    1010  public abstract class BaseTransformer : ITypeTransformer
    1111  {
    12     public ParameterData Extract(IItem value) {
    13       ParameterData data = ExtractData(value);
     12    public Component Extract(IItem value) {
     13      Component data = ExtractData(value);
    1414      data.Name = String.IsNullOrEmpty(data.Name) ? value.ItemName : data.Name;
    1515      return data;
    1616    }
    1717
    18     public void Inject(IItem item, ParameterData data) => InjectData(item, data);
     18    public void Inject(IItem item, Component data) => InjectData(item, data);
    1919
    20     public abstract void InjectData(IItem item, ParameterData data);
    21     public abstract ParameterData ExtractData(IItem value);
     20    public abstract void InjectData(IItem item, Component data);
     21    public abstract Component ExtractData(IItem value);
    2222
    2323    #region Helper
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/DummyTransformer.cs

    r17269 r17271  
    88namespace HeuristicLab.Manufacture {
    99  public class DummyTransformer : BaseTransformer {
    10     public override void InjectData(IItem item, ParameterData data) {
     10    public override void InjectData(IItem item, Component data) {
    1111      // do nothing because the instance already exists and
    1212      // there are no values to inject
    1313    }
    1414
    15     public override ParameterData ExtractData(IItem value) =>
    16       new ParameterData() { Default = value.GetType().Name };
     15    public override Component ExtractData(IItem value) =>
     16      new Component() { Default = value.GetType().Name };
    1717  }
    1818}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/EnumTypeTransformer.cs

    r17266 r17271  
    1010  public class EnumTypeTransformer : BaseTransformer {
    1111
    12     public override void InjectData(IItem item, ParameterData data) =>
     12    public override void InjectData(IItem item, Component data) =>
    1313      item.Cast<dynamic>().Value = Enum.Parse(
    1414        item.GetType().GenericTypeArguments.First(),
    1515        CastValue<string>(data.Default));
    1616
    17     public override ParameterData ExtractData(IItem value) {
    18       ParameterData data = new ParameterData();
     17    public override Component ExtractData(IItem value) {
     18      Component data = new Component();
    1919      object val = ((dynamic)value).Value;
    2020      Type enumType = val.GetType();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/MultiCheckedOperatorTransformer.cs

    r17269 r17271  
    88namespace HeuristicLab.Manufacture {
    99  public class MultiCheckedOperatorTransformer : ParameterizedItemTransformer {
    10     public override ParameterData ExtractData(IItem value) {
    11       ParameterData data = base.ExtractData(value);
     10    public override Component ExtractData(IItem value) {
     11      Component data = base.ExtractData(value);
    1212
    13       data.Operators = new List<ParameterData>();
     13      data.Operators = new List<Component>();
    1414      dynamic val = value.Cast<dynamic>();
    1515      foreach (var op in val.Operators) {
    16         data.Operators.Add(new ParameterData() {
     16        data.Operators.Add(new Component() {
    1717          Name = op.Name,
    1818          Default = val.Operators.ItemChecked(op),
     
    2323    }
    2424
    25     public override void InjectData(IItem item, ParameterData data) {
     25    public override void InjectData(IItem item, Component data) {
    2626      base.InjectData(item, data);
    2727
     
    3232    }
    3333
    34     private bool GetOperatorState(string name, ParameterData data) {
     34    private bool GetOperatorState(string name, Component data) {
    3535      foreach(var op in data.Operators) {
    3636        if (op.Name == name) return op.Default.Cast<bool>();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/StringValueTransformer.cs

    r17266 r17271  
    99namespace HeuristicLab.Manufacture {
    1010  public class StringValueTransformer : BaseTransformer {
    11     public override void InjectData(IItem item, ParameterData data) =>
     11    public override void InjectData(IItem item, Component data) =>
    1212      item.Cast<StringValue>().Value = CastValue<string>(data.Default);
    1313
    14     public override ParameterData ExtractData(IItem value) =>
    15       new ParameterData() {
     14    public override Component ExtractData(IItem value) =>
     15      new Component() {
    1616        Default = value.Cast<StringValue>().Value
    1717      };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/ValueTypeArrayTransformer.cs

    r17266 r17271  
    1313    where T : struct
    1414  {
    15     public override void InjectData(IItem item, ParameterData data) =>
     15    public override void InjectData(IItem item, Component data) =>
    1616      CopyArrayData(item.Cast<ArrayType>(), CastValue<T[]>(data.Default));
    1717
    18     public override ParameterData ExtractData(IItem value) =>
    19       new ParameterData() {
     18    public override Component ExtractData(IItem value) =>
     19      new Component() {
    2020        Default = value.Cast<ArrayType>().CloneAsArray()
    2121      };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/ValueTypeMatrixTransformer.cs

    r17266 r17271  
    1313    where T : struct
    1414  {
    15     public override void InjectData(IItem item, ParameterData data) =>
     15    public override void InjectData(IItem item, Component data) =>
    1616      CopyMatrixData(item.Cast<MatrixType>(), CastValue<T[,]>(data.Default));
    1717
    18     public override ParameterData ExtractData(IItem value) =>
    19       new ParameterData() {
     18    public override Component ExtractData(IItem value) =>
     19      new Component() {
    2020        Default = value.Cast<MatrixType>().CloneAsMatrix()
    2121      };
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/TypeTransformer/ValueTypeValueTransformer.cs

    r17266 r17271  
    1212    where T : struct {
    1313
    14     public override void InjectData(IItem item, ParameterData data) =>
     14    public override void InjectData(IItem item, Component data) =>
    1515      item.Cast<ValueType>().Value = CastValue<T>(data.Default);
    1616
    17     public override ParameterData ExtractData(IItem value) =>
    18       new ParameterData() {
     17    public override Component ExtractData(IItem value) =>
     18      new Component() {
    1919        Default = value.Cast<ValueType>().Value,
    2020        Range = new object[] { default(T), GetMaxValue() }
Note: See TracChangeset for help on using the changeset viewer.