Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/19 14:20:06 (5 years ago)
Author:
msemenki
Message:

#2988: New version of class structure.

Location:
branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs

    r16565 r16899  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Runtime.InteropServices;
     22using HEAL.Attic;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    2926using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3027using HeuristicLab.Parameters;
    31 using HEAL.Attic;
     28using System;
     29using System.Collections.Generic;
     30using System.Linq;
     31using System.Runtime.InteropServices;
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    101101    private IDataset dataset;
    102102
     103    private static readonly HashSet<byte> supportedOpCodes = new HashSet<byte>() {
     104      (byte)OpCode.Constant,
     105      (byte)OpCode.Variable,
     106      (byte)OpCode.Add,
     107      (byte)OpCode.Sub,
     108      (byte)OpCode.Mul,
     109      (byte)OpCode.Div,
     110      (byte)OpCode.Exp,
     111      (byte)OpCode.Log,
     112      (byte)OpCode.Sin,
     113      (byte)OpCode.Cos,
     114      (byte)OpCode.Tan,
     115      (byte)OpCode.Tanh,
     116      (byte)OpCode.Power,
     117      (byte)OpCode.Root,
     118      (byte)OpCode.SquareRoot,
     119      (byte)OpCode.Square,
     120      (byte)OpCode.CubeRoot,
     121      (byte)OpCode.Cube,
     122      (byte)OpCode.Absolute,
     123      (byte)OpCode.AnalyticQuotient
     124    };
     125
    103126    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
    104127      if (!rows.Any()) return Enumerable.Empty<double>();
     
    108131      }
    109132
    110       var code = Compile(tree, OpCodes.MapSymbolToOpCode);
     133      byte mapSupportedSymbols(ISymbolicExpressionTreeNode node) {
     134        var opCode = OpCode.MapSymbolToOpCode(node);
     135        if (supportedOpCodes.Contains(opCode)) return opCode;
     136        else throw new NotSupportedException($"The native interpreter does not support {node.Symbol.Name}");
     137      };
     138      var code = Compile(tree, mapSupportedSymbols);
    111139
    112140      var rowsArray = rows.ToArray();
Note: See TracChangeset for help on using the changeset viewer.