Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/12/11 13:19:53 (13 years ago)
Author:
mkommend
Message:

Implemented Power symbol for GP (ticket #1374).

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

    r5163 r5288  
    1212    <AssemblyName>HeuristicLab.Problems.DataAnalysis-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    107108  </ItemGroup>
    108109  <ItemGroup>
     110    <Compile Include="Symbolic\Symbols\Power.cs" />
    109111    <Compile Include="TableFileParser.cs" />
    110112    <None Include="HeuristicLab.snk" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs

    r4722 r5288  
    5353      var tan = new Tangent();
    5454      var log = new Logarithm();
     55      var pow = new Power();
    5556      var exp = new Exponential();
    5657      var @if = new IfThenElse();
     
    6768      laggedVariable.InitialFrequency = 0.0;
    6869
    69       var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, exp, @if, gt, lt, and, or, not, constant, variableSymbol, laggedVariable };
     70      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, exp, @if, gt, lt, and, or, not, constant, variableSymbol, laggedVariable };
    7071      var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not };
    71       var binaryFunctionSymbols = new List<Symbol>() { gt, lt };
     72      var binaryFunctionSymbols = new List<Symbol>() { pow, gt, lt };
    7273      var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };
    7374      var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable };
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r5223 r5288  
    6565      public const byte Constant = 20;
    6666      public const byte Arg = 21;
     67
     68      public const byte Power = 22;
    6769    }
    6870
     
    8991      { typeof(Constant), OpCodes.Constant },
    9092      { typeof(Argument), OpCodes.Arg },
     93      { typeof(Power),OpCodes.Power},
    9194    };
    9295    private const int ARGUMENT_STACK_SIZE = 1024;
     
    185188            return Math.Tan(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
    186189          }
     190        case OpCodes.Power: {
     191            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     192            double y = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     193            return Math.Pow(x, y);
     194          }
    187195        case OpCodes.Exp: {
    188196            return Math.Exp(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Power.cs

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