Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/28/19 11:22:24 (6 years ago)
Author:
msemenki
Message:

#2988: Add first version of GP for Evolvment models of models.

Location:
branches/2988_ModelsOfModels2
Files:
6 added
1 deleted
23 edited
3 copied

Legend:

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

  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs

    r16565 r16722  
    2020#endregion
    2121
     22using AutoDiff;
     23using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2224using System;
    2325using System.Collections.Generic;
    2426using System.Linq;
    2527using System.Runtime.Serialization;
    26 using AutoDiff;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    7676      eval: Math.Tan,
    7777      diff: x => 1 + Math.Tan(x) * Math.Tan(x));
    78 
     78    private static readonly Func<Term, UnaryFunc> tanh = UnaryFunc.Factory(
     79      eval: Math.Tanh,
     80      diff: x => 1 - Math.Tanh(x) * Math.Tanh(x));
    7981    private static readonly Func<Term, UnaryFunc> erf = UnaryFunc.Factory(
    8082      eval: alglib.errorfunction,
     
    249251      if (node.Symbol is CubeRoot) {
    250252        return AutoDiff.TermBuilder.Power(
    251           ConvertToAutoDiff(node.GetSubtree(0)), 1.0/3.0);
     253          ConvertToAutoDiff(node.GetSubtree(0)), 1.0 / 3.0);
    252254      }
    253255      if (node.Symbol is Sine) {
     
    261263      if (node.Symbol is Tangent) {
    262264        return tan(
     265          ConvertToAutoDiff(node.GetSubtree(0)));
     266      }
     267      if (node.Symbol is HyperbolicTangent) {
     268        return tanh(
    263269          ConvertToAutoDiff(node.GetSubtree(0)));
    264270      }
     
    321327          !(n.Symbol is Cosine) &&
    322328          !(n.Symbol is Tangent) &&
     329          !(n.Symbol is HyperbolicTangent) &&
    323330          !(n.Symbol is Erf) &&
    324331          !(n.Symbol is Norm) &&
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs

    r16565 r16722  
    5151    }
    5252
    53     public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     53    /// <summary>
     54    /// Produces an infix expression for a given expression tree.
     55    /// </summary>
     56    /// <param name="symbolicExpressionTree">The tree representation of the expression.</param>
     57    /// <param name="numberFormat">Number format that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param>
     58    /// <param name="formatString">The format string for numeric parameters (e.g. \"G4\" to limit to 4 digits, default is \"G\")</param>
     59    /// <returns>Infix expression</returns>
     60    public string Format(ISymbolicExpressionTree symbolicExpressionTree, NumberFormatInfo numberFormat, string formatString="G") {
    5461      // skip root and start symbols
    5562      StringBuilder strBuilder = new StringBuilder();
    56       FormatRecursively(symbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0), strBuilder);
     63      FormatRecursively(symbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0), strBuilder, numberFormat, formatString);
    5764      return strBuilder.ToString();
    5865    }
    5966
    60     private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     67    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     68      return Format(symbolicExpressionTree, NumberFormatInfo.InvariantInfo);
     69    }
     70
     71    private static void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, NumberFormatInfo numberFormat, string formatString) {
    6172      if (node.SubtreeCount > 1) {
    6273        var token = GetToken(node.Symbol);
     
    6677            token == "^") {
    6778          strBuilder.Append("(");
    68           FormatRecursively(node.Subtrees.First(), strBuilder);
     79          FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString);
    6980
    7081          foreach (var subtree in node.Subtrees.Skip(1)) {
    7182            strBuilder.Append(" ").Append(token).Append(" ");
    72             FormatRecursively(subtree, strBuilder);
     83            FormatRecursively(subtree, strBuilder, numberFormat, formatString);
    7384          }
    7485          strBuilder.Append(")");
     
    7687          // function with multiple arguments
    7788          strBuilder.Append(token).Append("(");
    78           FormatRecursively(node.Subtrees.First(), strBuilder);
     89          FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString);
    7990          foreach (var subtree in node.Subtrees.Skip(1)) {
    8091            strBuilder.Append(", ");
    81             FormatRecursively(subtree, strBuilder);
     92            FormatRecursively(subtree, strBuilder, numberFormat, formatString);
    8293          }
    8394          strBuilder.Append(")");
     
    8798        if (token == "-" || token == "NOT") {
    8899          strBuilder.Append("(").Append(token).Append("(");
    89           FormatRecursively(node.GetSubtree(0), strBuilder);
     100          FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString);
    90101          strBuilder.Append("))");
    91102        } else if (token == "/") {
    92103          strBuilder.Append("1/");
    93           FormatRecursively(node.GetSubtree(0), strBuilder);
     104          FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString);
    94105        } else if (token == "+" || token == "*") {
    95           FormatRecursively(node.GetSubtree(0), strBuilder);
     106          FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString);
    96107        } else {
    97108          // function with only one argument
    98109          strBuilder.Append(token).Append("(");
    99           FormatRecursively(node.GetSubtree(0), strBuilder);
     110          FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString);
    100111          strBuilder.Append(")");
    101112        }
     
    106117          if (!varNode.Weight.IsAlmost(1.0)) {
    107118            strBuilder.Append("(");
    108             strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Weight);
     119            strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat));
    109120            strBuilder.Append("*");
    110121          }
     
    116127          }
    117128          strBuilder.Append(", ")
    118             .AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Lag)
     129            .AppendFormat(numberFormat, "{0}", varNode.Lag)
    119130            .Append(")");
    120131        } else if (node.Symbol is Variable) {
     
    122133          if (!varNode.Weight.IsAlmost(1.0)) {
    123134            strBuilder.Append("(");
    124             strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Weight);
     135            strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat));
    125136            strBuilder.Append("*");
    126137          }
     
    141152          }
    142153          strBuilder.AppendFormat("[{0}]",
    143             string.Join(", ", factorNode.Weights.Select(w => w.ToString(CultureInfo.InvariantCulture))));
     154            string.Join(", ", factorNode.Weights.Select(w => w.ToString(formatString, numberFormat))));
    144155        } else if (node.Symbol is BinaryFactorVariable) {
    145156          var factorNode = node as BinaryFactorVariableTreeNode;
    146157          if (!factorNode.Weight.IsAlmost(1.0)) {
    147158            strBuilder.Append("(");
    148             strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", factorNode.Weight);
     159            strBuilder.Append(factorNode.Weight.ToString(formatString, numberFormat));
    149160            strBuilder.Append("*");
    150161          }
     
    168179          var constNode = node as ConstantTreeNode;
    169180          if (constNode.Value >= 0.0)
    170             strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", constNode.Value);
     181            strBuilder.Append(constNode.Value.ToString(formatString, numberFormat));
    171182          else
    172             strBuilder.AppendFormat(CultureInfo.InvariantCulture, "({0})", constNode.Value); // (-1
     183            strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)).Append(")"); // (-1
    173184        }
    174185      }
    175186    }
    176187
    177     private string GetToken(ISymbol symbol) {
     188    private static string GetToken(ISymbol symbol) {
    178189      var tok = InfixExpressionParser.knownSymbols.GetBySecond(symbol).FirstOrDefault();
    179190      if (tok == null)
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs

    r16565 r16722  
    2626using System.Text;
    2727using System.Text.RegularExpressions;
     28using HEAL.Attic;
    2829using HeuristicLab.Common;
    2930using HeuristicLab.Core;
    3031using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    31 using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    5656    }
    5757
    58     private string VariableName2Identifier(string name) {     
     58    private string VariableName2Identifier(string name) {
    5959      /*
    6060       * identifier-start-character:
     
    131131        } else if (node.Symbol is Tangent) {
    132132          FormatFunction(node, "Math.Tan", strBuilder);
     133        } else if (node.Symbol is HyperbolicTangent) {
     134          FormatFunction(node, "Math.Tanh", strBuilder);
    133135        } else if (node.Symbol is Square) {
    134136          FormatSquare(node, strBuilder);
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs

    r16565 r16722  
    2525using System.Linq;
    2626using System.Text;
     27using HEAL.Attic;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Core;
    2930using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    30 using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    192192        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    193193        stringBuilder.Append(")");
    194 
     194      } else if (symbol is HyperbolicTangent) {
     195        stringBuilder.Append("TANH(");
     196        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     197        stringBuilder.Append(")");
    195198      } else if (symbol is Variable) {
    196199        VariableTreeNode variableTreeNode = node as VariableTreeNode;
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r16565 r16722  
    2424using System.Linq;
    2525using System.Text;
     26using HEAL.Attic;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    137137      } else if (node.Symbol is Tangent) {
    138138        strBuilder.Append(@"\tan \left( ");
     139      } else if (node.Symbol is HyperbolicTangent) {
     140        strBuilder.Append(@"\tanh \left( ");
    139141      } else if (node.Symbol is AiryA) {
    140142        strBuilder.Append(@"\operatorname{airy}_a \left( ");
     
    303305      } else if (node.Symbol is Tangent) {
    304306        throw new InvalidOperationException();
     307      } else if (node.Symbol is HyperbolicTangent) {
     308        throw new InvalidOperationException();
    305309      } else if (node.Symbol is AiryA) {
    306310        throw new InvalidOperationException();
     
    399403      } else if (node.Symbol is Tangent) {
    400404        strBuilder.Append(@" \right) ");
     405      } else if (node.Symbol is HyperbolicTangent) {
     406        strBuilder.Append(@" \right) ");
    401407      } else if (node.Symbol is AiryA) {
    402408        strBuilder.Append(@" \right) ");
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs

    r16565 r16722  
    2323using System.Linq;
    2424using System.Text;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    252252      } else if (symbol is Tangent) {
    253253        stringBuilder.Append("tan(");
     254        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     255        stringBuilder.Append(")");
     256      } else if (symbol is HyperbolicTangent) {
     257        stringBuilder.Append("tanh(");
    254258        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    255259        stringBuilder.Append(")");
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs

    r16565 r16722  
    2424using System.Linq;
    2525using System.Text;
     26using HEAL.Attic;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    7070        } else if (node.Symbol is Tangent) {
    7171          FormatFunction(node, "Tan", strBuilder);
     72        } else if (node.Symbol is HyperbolicTangent) {
     73          FormatFunction(node, "Tanh", strBuilder);
    7274        } else if (node.Symbol is Exponential) {
    7375          FormatFunction(node, "Exp", strBuilder);
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs

    r16565 r16722  
    160160        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    161161        stringBuilder.Append(" tan");
     162      } else if (symbol is HyperbolicTangent) {
     163        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     164        stringBuilder.Append(" tanh");
    162165      } else if (symbol is Variable) {
    163166        VariableTreeNode variableTreeNode = node as VariableTreeNode;
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r16565 r16722  
    5555      var log = new Logarithm();
    5656      var abs = new Absolute();
     57      var tanh = new HyperbolicTangent();
    5758      var pow = new Power();
    5859      pow.InitialFrequency = 0.0;
     
    120121      constant.MinValue = -20;
    121122      constant.MaxValue = 20;
     123
     124      var treeModel = new TreeModel();
     125
    122126      var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable();
    123127      var binFactorVariable = new BinaryFactorVariable();
     
    129133      autoregressiveVariable.Enabled = false;
    130134
    131       var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp,
     135      var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp, tanh,
    132136        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
    133137        @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition };
    134       var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, not, timeLag, integral, derivative,
     138      var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, tanh, not, timeLag, integral, derivative,
    135139        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
    136140      };
     
    138142      var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, aq, variableCondition };
    139143      var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or, xor };
    140       var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, constant, laggedVariable, autoregressiveVariable };
     144      var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, constant, laggedVariable, autoregressiveVariable, treeModel };
    141145
    142146      foreach (var symb in allSymbols)
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r16565 r16722  
    8585      var gamma = new Gamma();
    8686      var hypCosineIntegral = new HyperbolicCosineIntegral();
     87      var tanh = new HyperbolicTangent();
    8788      var hypSineIntegral = new HyperbolicSineIntegral();
    8889      var norm = new Norm();
     
    107108      constant.MinValue = -20;
    108109      constant.MaxValue = 20;
     110
    109111      var variableSymbol = new Variable();
    110112      var binFactorVariable = new BinaryFactorVariable();
     
    112114      var laggedVariable = new LaggedVariable();
    113115      var autoregressiveVariable = new AutoregressiveTargetVariable();
     116
     117      var treeModel = new TreeModel();
    114118      #endregion
    115119
    116120      #region group symbol declaration
    117121      var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean });
    118       var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan });
    119       var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log });
     122      var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan, tanh});
     123      var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log});
    120124      var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi,
    121125        fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient});
    122       var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol, binFactorVariable, factorVariable });
     126      var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol, binFactorVariable, factorVariable, treeModel });
    123127      var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols });
    124128
     
    242246      Symbols.First(s => s is Average).Enabled = false;
    243247      Symbols.First(s => s is Absolute).Enabled = false;
     248      Symbols.First(s => s is HyperbolicTangent).Enabled = false;
    244249      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    245250      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
     
    254259      Symbols.First(s => s is Xor).Enabled = false;
    255260      Symbols.First(s => s is Absolute).Enabled = false;
     261      Symbols.First(s => s is HyperbolicTangent).Enabled = false;
    256262      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    257263      Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false;
     
    264270      Symbols.First(s => s is Average).Enabled = false;
    265271      Symbols.First(s => s is Absolute).Enabled = false;
     272      Symbols.First(s => s is HyperbolicTangent).Enabled = false;
    266273      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    267274      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r16568 r16722  
    4141    <DebugType>full</DebugType>
    4242    <Optimize>false</Optimize>
    43     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     43    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    4444    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4545    <ErrorReport>prompt</ErrorReport>
     
    5151    <DebugType>pdbonly</DebugType>
    5252    <Optimize>true</Optimize>
    53     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     53    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    5454    <DefineConstants>TRACE</DefineConstants>
    5555    <ErrorReport>prompt</ErrorReport>
     
    100100  <ItemGroup>
    101101    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    102       <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath>
     102      <HintPath>..\..\..\..\trunk\bin\ALGLIB-3.7.0.dll</HintPath>
    103103      <Private>False</Private>
    104104    </Reference>
    105105    <Reference Include="AutoDiff-1.0, Version=1.0.0.14388, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    106       <HintPath>..\..\bin\AutoDiff-1.0.dll</HintPath>
    107       <Private>False</Private>
    108     </Reference>
    109     <Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
    110       <HintPath>..\..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
     106      <HintPath>..\..\..\..\trunk\bin\AutoDiff-1.0.dll</HintPath>
     107      <Private>False</Private>
    111108    </Reference>
    112109    <Reference Include="HEAL.Attic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    113110      <HintPath>..\..\packages\HEAL.Attic.1.0.0-pre02\lib\net461\HEAL.Attic.dll</HintPath>
     111      <Private>False</Private>
     112    </Reference>
     113    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     114      <SpecificVersion>False</SpecificVersion>
     115      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     116      <Private>False</Private>
     117    </Reference>
     118    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     119      <SpecificVersion>False</SpecificVersion>
     120      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     121      <Private>False</Private>
     122    </Reference>
     123    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     124      <SpecificVersion>False</SpecificVersion>
     125      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common-3.3.dll</HintPath>
     126      <Private>False</Private>
     127    </Reference>
     128    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     129      <SpecificVersion>False</SpecificVersion>
     130      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     131      <Private>False</Private>
     132    </Reference>
     133    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     134      <SpecificVersion>False</SpecificVersion>
     135      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
     136      <Private>False</Private>
     137    </Reference>
     138    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     139      <SpecificVersion>False</SpecificVersion>
     140      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
     141      <Private>False</Private>
     142    </Reference>
     143    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     144      <SpecificVersion>False</SpecificVersion>
     145      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     146    </Reference>
     147    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     148      <SpecificVersion>False</SpecificVersion>
     149      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     150      <Private>False</Private>
     151    </Reference>
     152    <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     153      <SpecificVersion>False</SpecificVersion>
     154      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     155      <Private>False</Private>
     156    </Reference>
     157    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     158      <SpecificVersion>False</SpecificVersion>
     159      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     160      <Private>False</Private>
     161    </Reference>
     162    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     163      <SpecificVersion>False</SpecificVersion>
     164      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     165      <Private>False</Private>
     166    </Reference>
     167    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     168      <SpecificVersion>False</SpecificVersion>
     169      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     170      <Private>False</Private>
     171    </Reference>
     172    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     173      <SpecificVersion>False</SpecificVersion>
     174      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
     175      <Private>False</Private>
    114176    </Reference>
    115177    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1, Version=0.0.0.1, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    116178      <SpecificVersion>False</SpecificVersion>
    117       <HintPath>..\..\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1.dll</HintPath>
     179      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1.dll</HintPath>
     180      <Private>False</Private>
     181    </Reference>
     182    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     183      <SpecificVersion>False</SpecificVersion>
     184      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     185      <Private>False</Private>
     186    </Reference>
     187    <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     188      <SpecificVersion>False</SpecificVersion>
     189      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Random-3.3.dll</HintPath>
     190      <Private>False</Private>
     191    </Reference>
     192    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     193      <SpecificVersion>False</SpecificVersion>
     194      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Selection-3.3.dll</HintPath>
    118195      <Private>False</Private>
    119196    </Reference>
     
    136213  </ItemGroup>
    137214  <ItemGroup>
     215    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs" />
     216    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs" />
     217    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs" />
    138218    <Compile Include="Analyzers\SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs" />
    139219    <Compile Include="Analyzers\SymbolicDataAnalysisBuildingBlockAnalyzer.cs" />
     
    176256    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" />
    177257    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" />
     258    <Compile Include="Selectors\DiversitySelector.cs" />
    178259    <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" />
    179260    <Compile Include="SymbolicDataAnalysisModelComplexityCalculator.cs" />
     
    239320    <Compile Include="Symbols\Absolute.cs" />
    240321    <Compile Include="Symbols\CubeRoot.cs" />
     322    <Compile Include="Symbols\HyperbolicTangent.cs" />
     323    <Compile Include="Symbols\ModelTreeNode.cs" />
    241324    <Compile Include="Symbols\VariableBase.cs" />
    242325    <Compile Include="Symbols\VariableTreeNodeBase.cs" />
     
    293376    <Compile Include="TreeMatching\SymbolicExpressionTreeNodeEqualityComparer.cs" />
    294377    <Compile Include="TreeMatching\SymbolicExpressionTreePhenotypicSimilarityCalculator.cs" />
     378    <Compile Include="Symbols\TreeModel.cs" />
    295379    <None Include="HeuristicLab.snk" />
    296380    <None Include="packages.config" />
     
    328412  </ItemGroup>
    329413  <ItemGroup>
    330     <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
    331       <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
    332       <Name>HeuristicLab.Analysis-3.3</Name>
    333       <Private>False</Private>
    334     </ProjectReference>
    335     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    336       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    337       <Name>HeuristicLab.Collections-3.3</Name>
    338       <Private>False</Private>
    339     </ProjectReference>
    340     <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    341       <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    342       <Name>HeuristicLab.Common.Resources-3.3</Name>
    343       <Private>False</Private>
    344     </ProjectReference>
    345     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    346       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    347       <Name>HeuristicLab.Common-3.3</Name>
    348       <Private>False</Private>
    349     </ProjectReference>
    350     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    351       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    352       <Name>HeuristicLab.Core-3.3</Name>
    353       <Private>False</Private>
    354     </ProjectReference>
    355     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    356       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    357       <Name>HeuristicLab.Data-3.3</Name>
    358       <Private>False</Private>
    359     </ProjectReference>
    360414    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
    361415      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
    362416      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
    363       <Private>False</Private>
    364     </ProjectReference>
    365     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    366       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    367       <Name>HeuristicLab.Operators-3.3</Name>
    368       <Private>False</Private>
    369     </ProjectReference>
    370     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    371       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    372       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    373       <Private>False</Private>
    374     </ProjectReference>
    375     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    376       <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    377       <Name>HeuristicLab.Optimization-3.3</Name>
    378     </ProjectReference>
    379     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    380       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    381       <Name>HeuristicLab.Parameters-3.3</Name>
    382       <Private>False</Private>
    383     </ProjectReference>
    384     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    385       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    386       <Name>HeuristicLab.Persistence-3.3</Name>
    387       <Private>False</Private>
    388     </ProjectReference>
    389     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    390       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    391       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    392       <Private>False</Private>
    393     </ProjectReference>
    394     <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
    395       <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
    396       <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
    397       <Private>False</Private>
    398     </ProjectReference>
    399     <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
    400       <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
    401       <Name>HeuristicLab.Problems.Instances-3.3</Name>
    402       <Private>False</Private>
    403     </ProjectReference>
    404     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    405       <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
    406       <Name>HeuristicLab.Random-3.3</Name>
    407417      <Private>False</Private>
    408418    </ProjectReference>
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs

    r16565 r16722  
    8484    private Constant constant = new Constant();
    8585    private Variable variable = new Variable();
     86    private TreeModel treeModel = new TreeModel();
    8687    private BinaryFactorVariable binaryFactorVar = new BinaryFactorVariable();
    8788    private FactorVariable factorVar = new FactorVariable();
     
    111112        { "COS", new Cosine()},
    112113        { "TAN", new Tangent()},
     114        { "TANH", new HyperbolicTangent()},
    113115        { "AIRYA", new AiryA()},
    114116        { "AIRYB", new AiryB()},
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs

    r16565 r16722  
    5353        {"COS", new Cosine()},
    5454        {"TAN", new Tangent()},
     55        {"TANH", new HyperbolicTangent ()},
    5556        {"AIRYA", new AiryA()},
    5657        {"AIRYB", new AiryB()},
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs

    r16356 r16722  
    6969        a[i] = Math.Tan(b[i]);
    7070    }
     71    public static void Tanh(double[] a, double[] b) {
     72      for (int i = 0; i < BATCHSIZE; ++i)
     73        a[i] = Math.Tanh(b[i]);
     74    }
    7175
    7276    public static void Pow(double[] a, double[] b) {
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs

    r16565 r16722  
    8888      var outputInterval = Evaluate(instructions, ref instructionCount);
    8989
    90       return outputInterval;
     90      // because of numerical errors the bounds might be incorrect
     91      if (outputInterval.LowerBound <= outputInterval.UpperBound)
     92        return outputInterval;
     93      else
     94        return new Interval(outputInterval.UpperBound, outputInterval.LowerBound);
    9195    }
    9296
     
    102106      var outputInterval = Evaluate(instructions, ref instructionCount, intervals);
    103107
    104       nodeIntervals = intervals;
    105 
    106       return outputInterval;
     108      // fix incorrect intervals if necessary (could occur because of numerical errors)
     109      nodeIntervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>();
     110      foreach(var kvp in intervals) {
     111        var interval = kvp.Value;
     112        if (interval.IsInfiniteOrUndefined || interval.LowerBound <= interval.UpperBound)
     113          nodeIntervals.Add(kvp.Key, interval);
     114        else
     115          nodeIntervals.Add(kvp.Key, new Interval(interval.UpperBound, interval.LowerBound));
     116      }
     117
     118      // because of numerical errors the bounds might be incorrect
     119      if (outputInterval.IsInfiniteOrUndefined || outputInterval.LowerBound <= outputInterval.UpperBound)
     120        return outputInterval;
     121      else
     122        return new Interval(outputInterval.UpperBound, outputInterval.LowerBound);
    107123    }
    108124
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r16565 r16722  
    9090    public const byte CubeRoot = 51;
    9191
     92    public const byte Tanh = 52;
     93    public const byte TreeModel = 53;
     94
    9295
    9396    private static Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() {
     
    99102      { typeof(Cosine), OpCodes.Cos },
    100103      { typeof(Tangent), OpCodes.Tan },
     104      { typeof (HyperbolicTangent), OpCodes.Tanh},
    101105      { typeof(Logarithm), OpCodes.Log },
    102106      { typeof(Exponential), OpCodes.Exp },
     
    114118      { typeof(AutoregressiveTargetVariable),OpCodes.LagVariable},
    115119      { typeof(Constant), OpCodes.Constant },
     120      { typeof(TreeModel), OpCodes.TreeModel },
    116121      { typeof(Argument), OpCodes.Arg },
    117122      { typeof(Power),OpCodes.Power},
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs

    r16565 r16722  
    4545    private static readonly MethodInfo Cos = typeof(Math).GetMethod("Cos", new[] { typeof(double) });
    4646    private static readonly MethodInfo Tan = typeof(Math).GetMethod("Tan", new[] { typeof(double) });
     47    private static readonly MethodInfo Tanh = typeof(Math).GetMethod("Tanh", new[] { typeof(double) });
    4748    private static readonly MethodInfo Sqrt = typeof(Math).GetMethod("Sqrt", new[] { typeof(double) });
    4849    private static readonly MethodInfo Floor = typeof(Math).GetMethod("Floor", new[] { typeof(double) });
     
    223224            return Expression.Call(Tan, arg);
    224225          }
     226        case OpCodes.Tanh: {
     227            var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns);
     228            return Expression.Call(Tanh, arg);
     229          }
    225230        case OpCodes.Square: {
    226231            var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns);
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs

    r16565 r16722  
    5151      }
    5252    }
    53 
     53    private void SubTreeEvoluate(BatchInstruction instr, int[] rows, int rowIndex, int batchSize) {
     54      for (int i = 0; i < batchSize; ++i) {
     55        var row = rows[rowIndex] + i;
     56        instr.buf[i] = instr.data[row];  // не забыть заполнить
     57      }
     58    }
    5459    private void Evaluate(BatchInstruction[] code, int[] rows, int rowIndex, int batchSize) {
    5560      for (int i = code.Length - 1; i >= 0; --i) {
     
    6166          case OpCodes.Variable: {
    6267              LoadData(instr, rows, rowIndex, batchSize);
     68              break;
     69            }
     70          case OpCodes.TreeModel: {
     71              SubTreeEvoluate(instr, rows, rowIndex, batchSize);
    6372              break;
    6473            }
     
    159168              break;
    160169            }
    161 
     170          case OpCodes.Tanh: {
     171              Tanh(instr.buf, code[c].buf);
     172              break;
     173            }
    162174          case OpCodes.Absolute: {
    163175              Absolute(instr.buf, code[c].buf);
     
    201213      }
    202214
    203       var code = Compile(tree, dataset, OpCodes.MapSymbolToOpCode);
     215      var code = Compile(tree, dataset, OpCodes.MapSymbolToOpCode, rows);
    204216      var remainingRows = rows.Length % BATCHSIZE;
    205217      var roundedTotal = rows.Length - remainingRows;
     
    233245    }
    234246
    235     private BatchInstruction[] Compile(ISymbolicExpressionTree tree, IDataset dataset, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper) {
     247    private BatchInstruction[] Compile(ISymbolicExpressionTree tree, IDataset dataset, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper, int[] rows) {
    236248      var root = tree.Root.GetSubtree(0).GetSubtree(0);
    237249      var code = new BatchInstruction[root.GetLength()];
    238250      if (root.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
    239251      int c = 1, i = 0;
     252      var allRows = Enumerable.Range(0, dataset.Rows).ToArray();
    240253      foreach (var node in root.IterateNodesBreadth()) {
    241254        if (node.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
     
    258271          for (int j = 0; j < BATCHSIZE; ++j)
    259272            code[i].buf[j] = code[i].value;
     273        } else if (node is TreeModelTreeNode subtree) {
     274          code[i].data = GetValues(subtree.Tree, dataset, allRows);
     275          EvaluatedSolutions--;
    260276        }
    261277        c += node.SubtreeCount;
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r16565 r16722  
    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) });
     
    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);
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r16565 r16722  
    205205            return Math.Abs(Evaluate(dataset, ref row, state));
    206206          }
     207        case OpCodes.Tanh: {
     208            return Math.Tanh(Evaluate(dataset, ref row, state));
     209          }
    207210        case OpCodes.Cos: {
    208211            return Math.Cos(Evaluate(dataset, ref row, state));
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r16565 r16722  
    226226        } else if (instr.opCode == OpCodes.Absolute) {
    227227          instr.value = Math.Abs(code[instr.childIndex].value);
     228        } else if (instr.opCode == OpCodes.Tanh) {
     229          instr.value = Math.Tanh(code[instr.childIndex].value);
    228230        } else if (instr.opCode == OpCodes.Cos) {
    229231          instr.value = Math.Cos(code[instr.childIndex].value);
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame

    r16565 r16722  
    4242  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    4343  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    44   [PluginDependency("HeuristicLab.Persistence", "3.3")]
     44  [PluginDependency("HeuristicLab.Attic", "1.0")]
    4545  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    4646  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4747  [PluginDependency("HeuristicLab.Random", "3.3")]
     48  [PluginDependency("HeuristicLab.Selection", "3.3")]
    4849  public class HeuristicLabProblemsDataAnalysisSymbolicPlugin : PluginBase {
    4950  }
  • branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Selectors/DiversitySelector.cs

    r16623 r16722  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using HEAL.Attic;
    2523using HeuristicLab.Common;
     
    3028using HeuristicLab.Parameters;
    3129using HeuristicLab.Selection;
     30using System;
     31using System.Collections.Generic;
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
Note: See TracChangeset for help on using the changeset viewer.