Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/13/19 09:30:18 (5 years ago)
Author:
gkronber
Message:

#2974: merged r16478:16672 from trunk:HeuristicLab.Problems.DataAnalysis.Symbolic to branch:HeuristicLab.Problems.DataAnalysis.Symbolic

Location:
branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r16360 r16676  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3030using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3131using HeuristicLab.Parameters;
    32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HEAL.Attic;
    3333
    3434namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    35   [StorableClass]
     35  [StorableType("426718E3-2A57-4CA4-98A1-65EDD0B0BDBF")]
    3636  [Item("SymbolicDataAnalysisExpressionTreeILEmittingInterpreter", "Interpreter for symbolic expression trees.")]
    3737  public sealed class SymbolicDataAnalysisExpressionTreeILEmittingInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter {
     
    4545    private static MethodInfo sin = typeof(Math).GetMethod("Sin", new Type[] { typeof(double) });
    4646    private static MethodInfo tan = typeof(Math).GetMethod("Tan", new Type[] { typeof(double) });
     47    private static MethodInfo tanh = typeof(Math).GetMethod("Tanh", new Type[] { typeof(double) });
    4748    private static MethodInfo exp = typeof(Math).GetMethod("Exp", new Type[] { typeof(double) });
    4849    private static MethodInfo log = typeof(Math).GetMethod("Log", new Type[] { typeof(double) });
     
    104105
    105106    [StorableConstructor]
    106     private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(bool deserializing) : base(deserializing) { }
     107    private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(StorableConstructorFlag _) : base(_) { }
    107108
    108109    private SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(SymbolicDataAnalysisExpressionTreeILEmittingInterpreter original, Cloner cloner) : base(original, cloner) { }
     
    285286            return;
    286287          }
     288        case OpCodes.Tanh: {
     289            CompileInstructions(il, state, ds);
     290            il.Emit(System.Reflection.Emit.OpCodes.Call, tanh);
     291            return;
     292          }
    287293        case OpCodes.Power: {
    288294            CompileInstructions(il, state, ds);
     
    425431            Label c1 = il.DefineLabel();
    426432            CompileInstructions(il, state, ds);
    427             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0
     433            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0); // > 0
    428434            il.Emit(System.Reflection.Emit.OpCodes.Cgt);
    429435            il.Emit(System.Reflection.Emit.OpCodes.Brfalse, c1);
     
    440446            CompileInstructions(il, state, ds);
    441447            for (int i = 1; i < nArgs; i++) {
    442               il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0
     448              il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0); // > 0
    443449              il.Emit(System.Reflection.Emit.OpCodes.Cgt);
    444450              il.Emit(System.Reflection.Emit.OpCodes.Brfalse, falseBranch);
    445451              CompileInstructions(il, state, ds);
    446452            }
    447             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0
     453            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0); // > 0
    448454            il.Emit(System.Reflection.Emit.OpCodes.Cgt);
    449455            il.Emit(System.Reflection.Emit.OpCodes.Brfalse, falseBranch);
     
    465471              // complex definition because of special properties of NaN 
    466472              il.Emit(System.Reflection.Emit.OpCodes.Dup);
    467               il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // <= 0       
     473              il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0); // <= 0       
    468474              il.Emit(System.Reflection.Emit.OpCodes.Ble, nextArgBranch);
    469475              il.Emit(System.Reflection.Emit.OpCodes.Br, resultBranch);
     
    473479            }
    474480            il.MarkLabel(resultBranch);
    475             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0
     481            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0); // > 0
    476482            il.Emit(System.Reflection.Emit.OpCodes.Cgt);
    477483            il.Emit(System.Reflection.Emit.OpCodes.Brtrue, trueBranch);
     
    486492        case OpCodes.NOT: {
    487493            CompileInstructions(il, state, ds);
    488             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0
     494            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0); // > 0
    489495            il.Emit(System.Reflection.Emit.OpCodes.Cgt);
    490496            il.Emit(System.Reflection.Emit.OpCodes.Conv_R8); // convert to float64
     
    498504        case OpCodes.XOR: {
    499505            CompileInstructions(il, state, ds);
    500             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0);
     506            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0);
    501507            il.Emit(System.Reflection.Emit.OpCodes.Cgt);// > 0
    502508
    503509            for (int i = 1; i < nArgs; i++) {
    504510              CompileInstructions(il, state, ds);
    505               il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0);
     511              il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0);
    506512              il.Emit(System.Reflection.Emit.OpCodes.Cgt);// > 0
    507513              il.Emit(System.Reflection.Emit.OpCodes.Xor);
Note: See TracChangeset for help on using the changeset viewer.