Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/19 16:23:42 (5 years ago)
Author:
dpiringe
Message:

#3026:

  • changed the namespace from ParameterTest to HeuristicLab.Manufacture
  • added an extension method for Type to get the distance of an interface based on the target type
  • renamed methods ToData, SetValue to Extract, Inject
  • new implementation of the template generation with transformers (not the final name)
  • started to use the new transformers for the instantiation of IOptimizer-objects (out of a template)
  • new transformers: LookupParameterTransformer and DummyTransformer
File:
1 edited

Legend:

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

    r17263 r17266  
    88using HeuristicLab.Core;
    99
    10 namespace ParameterTest {
     10namespace HeuristicLab.Manufacture {
    1111  public class ValueTypeMatrixTransformer<MatrixType, T> : BaseTransformer
    1212    where MatrixType : ValueTypeMatrix<T>
    1313    where T : struct
    1414  {
    15     public override IItem FromData(ParameterData obj, Type targetType) {
    16       /*T[,] arr = CastValue<T[,]>(obj.Default);
    17       MatrixType matrix = item.Cast<MatrixType>();
    18       for (int x = 0; x < arr.GetLength(0); ++x){
    19         for (int y = 0; y < arr.GetLength(1); ++y) {
    20           matrix[x, y] = arr[x, y];
    21         }
    22       }*/
    23       return Instantiate<MatrixType>(CastValue<T[,]>(obj.Default));
    24     }
     15    public override void InjectData(IItem item, ParameterData data) =>
     16      CopyMatrixData(item.Cast<MatrixType>(), CastValue<T[,]>(data.Default));
    2517
    26     public override void SetValue(IItem item, ParameterData data) {
    27       T[,] arr = CastValue<T[,]>(data.Default);
    28       MatrixType matrix = item.Cast<MatrixType>();
    29       for (int x = 0; x < arr.GetLength(0); ++x) {
    30         for (int y = 0; y < arr.GetLength(1); ++y) {
    31           matrix[x, y] = arr[x, y];
     18    public override ParameterData ExtractData(IItem value) =>
     19      new ParameterData() {
     20        Default = value.Cast<MatrixType>().CloneAsMatrix()
     21      };
     22
     23    #region Helper
     24    private void CopyMatrixData(MatrixType matrix, T[,] data) {
     25      for (int x = 0; x < data.GetLength(0); ++x) {
     26        for (int y = 0; y < data.GetLength(1); ++y) {
     27          matrix[x, y] = data[x, y];
    3228        }
    3329      }
    3430    }
    35 
    36     public override ParameterData ToData(IItem value) {
    37       ParameterData data = base.ToData(value);
    38       data.Default = value.Cast<MatrixType>().CloneAsMatrix();
    39       return data;
    40     }
     31    #endregion
    4132  }
    4233}
Note: See TracChangeset for help on using the changeset viewer.