Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/16/21 21:15:16 (4 years ago)
Author:
gkronber
Message:

#3087: updated native dlls for NativeInterpreter to a version that runs on Hive infrastructure. Some smaller changes because of deviations in the independently developed implementations (in particular enum types).

Location:
branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/NativeInterpreter.cs

    r17853 r17989  
    3131using HeuristicLab.Data;
    3232using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     33using HeuristicLab.NativeInterpreter;
    3334using HeuristicLab.Parameters;
    3435using HeuristicLab.Problems.DataAnalysis;
     
    173174
    174175      var summary = new OptimizationSummary(); // also not used
    175       NativeWrapper.GetValues(code, rows, result, null, options, ref summary);
     176      NativeWrapper.GetValues(code, rows, options, result, target: null, out summary);
    176177
    177178      // when evaluation took place without any error, we can increment the counter
  • branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/ParameterOptimizer.cs

    r17853 r17989  
    77using HeuristicLab.Data;
    88using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     9using HeuristicLab.NativeInterpreter;
    910using HeuristicLab.Parameters;
    1011
     
    8485      set { UseNonmonotonicStepsParameter.Value.Value = value; }
    8586    }
    86     private int Minimizer {
    87       get { return Array.IndexOf(MinimizerType, MinimizerTypeParameter.Value.Value); }
    88     }
    89     private int LinearSolver {
    90       get { return Array.IndexOf(LinerSolverType, LinearSolverTypeParameter.Value.Value); }
    91     }
    92     private int TrustRegionStrategy {
    93       get { return Array.IndexOf(TrustRegionStrategyType, TrustRegionStrategyTypeParameter.Value.Value); }
    94     }
    95     private int Dogleg {
    96       get { return Array.IndexOf(DoglegType, DogLegTypeParameter.Value.Value); }
    97     }
    98     private int LineSearchDirection {
    99       get { return Array.IndexOf(LinearSearchDirectionType, LineSearchDirectionTypeParameter.Value.Value); }
     87    private CeresTypes.MinimizerType Minimizer {
     88      get { return (CeresTypes.MinimizerType)Enum.Parse(typeof(CeresTypes.MinimizerType), MinimizerTypeParameter.Value.Value); }
     89    }
     90    private CeresTypes.LinearSolverType LinearSolver {
     91      get { return (CeresTypes.LinearSolverType)Enum.Parse(typeof(CeresTypes.LinearSolverType), LinearSolverTypeParameter.Value.Value); }
     92    }
     93    private CeresTypes.TrustRegionStrategyType TrustRegionStrategy {
     94      get { return (CeresTypes.TrustRegionStrategyType)Enum.Parse(typeof(CeresTypes.TrustRegionStrategyType), TrustRegionStrategyTypeParameter.Value.Value); }
     95    }
     96    private CeresTypes.DoglegType Dogleg {
     97      get { return (CeresTypes.DoglegType)Enum.Parse(typeof(CeresTypes.DoglegType), DogLegTypeParameter.Value.Value); }
     98    }
     99    private CeresTypes.LineSearchDirectionType LineSearchDirection {
     100      get { return (CeresTypes.LineSearchDirectionType)Enum.Parse(typeof(CeresTypes.LineSearchDirectionType), LineSearchDirectionTypeParameter.Value.Value); }
    100101    }
    101102    #endregion
     
    147148        var result = new double[rowsArray.Length];
    148149
    149         NativeWrapper.GetValues(code, rowsArray, result, target, options, ref summary);
     150        NativeWrapper.GetValues(code, rowsArray, options, result, target, out summary);
    150151      }
    151152      return Enumerable.Range(0, code.Length).Where(i => nodes[i] is SymbolicExpressionTreeTerminalNode).ToDictionary(i => nodes[i], i => code[i].Value);
     
    201202      var codeArray = totalCode.ToArray();
    202203
    203       NativeWrapper.GetValuesVarPro(codeArray, termIndices, rowsArray, coeff, result, target, options, ref summary);
     204      NativeWrapper.GetValuesVarPro(codeArray, termIndices,rowsArray, coeff, options, result, target, out summary);
    204205      return Enumerable.Range(0, totalCodeSize).Where(i => codeArray[i].Optimize).ToDictionary(i => totalNodes[i], i => codeArray[i].Value);
    205206    }
  • branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs

    r17844 r17989  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     30using HeuristicLab.NativeInterpreter;
    3031using HeuristicLab.Parameters;
    3132using HEAL.Attic;
     
    7071      var code = new NativeInstruction[root.GetLength()];
    7172      if (root.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
    72       code[0] = new NativeInstruction { narg = (ushort)root.SubtreeCount, opcode = opCodeMapper(root) };
    73       int c = 1, i = 0;
    74       foreach (var node in root.IterateNodesBreadth()) {
    75         for (int j = 0; j < node.SubtreeCount; ++j) {
    76           var s = node.GetSubtree(j);
    77           if (s.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
    78           code[c + j] = new NativeInstruction { narg = (ushort)s.SubtreeCount, opcode = opCodeMapper(s) };
     73      int i = code.Length - 1;
     74      foreach (var n in root.IterateNodesPrefix()) {
     75        code[i] = new NativeInstruction { Arity = (ushort)n.SubtreeCount, OpCode = opCodeMapper(n), Length = 1, Optimize = false };
     76        if (n is VariableTreeNode variable) {
     77          code[i].Value = variable.Weight;
     78          code[i].Data = cachedData[variable.VariableName].AddrOfPinnedObject();
     79        } else if (n is ConstantTreeNode constant) {
     80          code[i].Value = constant.Value;
    7981        }
     82        --i;
     83      }
     84      // second pass to calculate lengths
     85      for (i = 0; i < code.Length; i++) {
     86        var c = i - 1;
     87        for (int j = 0; j < code[i].Arity; ++j) {
     88          code[i].Length += code[c].Length;
     89          c -= code[c].Length;
     90        }
     91      }
    8092
    81         if (node is VariableTreeNode variable) {
    82           code[i].weight = variable.Weight;
    83           code[i].data = cachedData[variable.VariableName].AddrOfPinnedObject();
    84         } else if (node is ConstantTreeNode constant) {
    85           code[i].value = constant.Value;
    86         }
    87 
    88         code[i].childIndex = c;
    89         c += node.SubtreeCount;
    90         ++i;
    91       }
    9293      return code;
    9394    }
     
    114115      (byte)OpCode.Tan,
    115116      (byte)OpCode.Tanh,
    116       (byte)OpCode.Power,
    117       (byte)OpCode.Root,
     117      // (byte)OpCode.Power,
     118      // (byte)OpCode.Root,
    118119      (byte)OpCode.SquareRoot,
    119120      (byte)OpCode.Square,
     
    131132      }
    132133
    133       byte mapSupportedSymbols(ISymbolicExpressionTreeNode node) {       
     134      byte mapSupportedSymbols(ISymbolicExpressionTreeNode node) {
    134135        var opCode = OpCodes.MapSymbolToOpCode(node);
    135136        if (supportedOpCodes.Contains(opCode)) return opCode;
     
    140141      var rowsArray = rows.ToArray();
    141142      var result = new double[rowsArray.Length];
    142 
    143       NativeWrapper.GetValuesVectorized(code, code.Length, rowsArray, rowsArray.Length, result);
     143      // prevent optimization of parameters
     144      var options = new SolverOptions {
     145        Iterations = 0
     146      };
     147      NativeWrapper.GetValues(code, rowsArray, options, result, target: null, optSummary: out var optSummary); // target is only used when optimizing parameters
    144148
    145149      // when evaluation took place without any error, we can increment the counter
Note: See TracChangeset for help on using the changeset viewer.