Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5384


Ignore:
Timestamp:
01/27/11 10:26:09 (13 years ago)
Author:
mkommend
Message:

ticket #1374 - Implemented root symbol and changed power as well as root symbol to use a rounded exponent.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj

    r5373 r5384  
    108108  </ItemGroup>
    109109  <ItemGroup>
     110    <Compile Include="Symbolic\Symbols\Root.cs" />
    110111    <Compile Include="Symbolic\Symbols\Derivative.cs" />
    111112    <Compile Include="Symbolic\Symbols\Integral.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs

    r5373 r5384  
    5454      var log = new Logarithm();
    5555      var pow = new Power();
     56      pow.InitialFrequency = 0.0;
     57      var root = new Root();
     58      root.InitialFrequency = 0.0;
    5659      var exp = new Exponential();
    5760      var @if = new IfThenElse();
     
    7679      laggedVariable.InitialFrequency = 0.0;
    7780
    78       var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, exp, @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable };
     81      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, root, exp, @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable };
    7982      var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not, timeLag, integral, derivative };
    8083
    81       var binaryFunctionSymbols = new List<Symbol>() { pow, gt, lt };
     84      var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt };
    8285      var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };
    8386      var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable };
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r5373 r5384  
    6767
    6868      public const byte Power = 22;
    69       public const byte TimeLag = 23;
    70       public const byte Integral = 24;
    71       public const byte Derivative = 25;
     69      public const byte Root = 23;
     70      public const byte TimeLag = 24;
     71      public const byte Integral = 25;
     72      public const byte Derivative = 26;
    7273    }
    7374
     
    9596      { typeof(Argument), OpCodes.Arg },
    9697      { typeof(Power),OpCodes.Power},
     98      { typeof(Root),OpCodes.Root},
    9799      { typeof(TimeLag), OpCodes.TimeLag},
    98100      { typeof(Integral), OpCodes.Integral},
    99       {typeof(Derivative), OpCodes.Derivative},
     101      { typeof(Derivative), OpCodes.Derivative},
    100102    };
    101103    private const int ARGUMENT_STACK_SIZE = 1024;
     
    196198        case OpCodes.Power: {
    197199            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
    198             double y = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     200            double y = Math.Round(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
    199201            return Math.Pow(x, y);
     202          }
     203        case OpCodes.Root: {
     204            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     205            double y = Math.Round(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     206            return Math.Pow(x, 1 / y);
    200207          }
    201208        case OpCodes.Exp: {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Root.cs

    r5378 r5384  
    2626namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
    2727  [StorableClass]
    28   [Item("Power", "Symbol that represents the power function.")]
    29   public sealed class Power : Symbol {
     28  [Item("Root", "Symbol that represents the n-th root function.")]
     29  public sealed class Root : Symbol {
    3030    [StorableConstructor]
    31     private Power(bool deserializing) : base(deserializing) { }
    32     private Power(Power original, Cloner cloner) : base(original, cloner) { }
     31    private Root(bool deserializing) : base(deserializing) { }
     32    private Root(Root original, Cloner cloner) : base(original, cloner) { }
    3333    public override IDeepCloneable Clone(Cloner cloner) {
    34       return new Power(this, cloner);
     34      return new Root(this, cloner);
    3535    }
    36     public Power() : base("Power", "Symbol that represents the power function.") { }
     36    public Root() : base("Root", "Symbol that represents the n-th root function.") { }
    3737  }
    3838}
Note: See TracChangeset for help on using the changeset viewer.